mirror of
https://github.com/bitwarden/server.git
synced 2025-07-16 15:17:33 -05:00
job to delete trashed ciphers nightly (#1243)
* job to delete trashed items nightly * remove script from migration project file * admin setting for controlling trash deleting dates
This commit is contained in:
19
src/Sql/dbo/Stored Procedures/Cipher_DeleteDeleted.sql
Normal file
19
src/Sql/dbo/Stored Procedures/Cipher_DeleteDeleted.sql
Normal file
@ -0,0 +1,19 @@
|
||||
CREATE PROCEDURE [dbo].[Cipher_DeleteDeleted]
|
||||
@DeletedDateBefore DATETIME2 (7)
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DECLARE @BatchSize INT = 100
|
||||
|
||||
WHILE @BatchSize > 0
|
||||
BEGIN
|
||||
DELETE TOP(@BatchSize)
|
||||
FROM
|
||||
[dbo].[Cipher]
|
||||
WHERE
|
||||
[DeletedDate] < @DeletedDateBefore
|
||||
|
||||
SET @BatchSize = @@ROWCOUNT
|
||||
END
|
||||
END
|
@ -26,3 +26,8 @@ GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Cipher_OrganizationId]
|
||||
ON [dbo].[Cipher]([OrganizationId] ASC);
|
||||
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Cipher_DeletedDate]
|
||||
ON [dbo].[Cipher]([DeletedDate] ASC);
|
||||
|
||||
|
Reference in New Issue
Block a user