mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 01:22:50 -05:00
new grant cleanup sproc
This commit is contained in:
19
src/Sql/dbo/Stored Procedures/Grant_DeleteExpired.sql
Normal file
19
src/Sql/dbo/Stored Procedures/Grant_DeleteExpired.sql
Normal file
@ -0,0 +1,19 @@
|
||||
CREATE PROCEDURE [dbo].[Grant_DeleteExpired]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DECLARE @BatchSize INT = 100
|
||||
DECLARE @Now DATETIME2(7) = GETUTCDATE()
|
||||
|
||||
WHILE @BatchSize > 0
|
||||
BEGIN
|
||||
DELETE TOP(@BatchSize)
|
||||
FROM
|
||||
[dbo].[Grant]
|
||||
WHERE
|
||||
[ExpirationDate] < @Now
|
||||
|
||||
SET @BatchSize = @@ROWCOUNT
|
||||
END
|
||||
END
|
@ -14,3 +14,7 @@ GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Grant_SubjectId_ClientId_Type]
|
||||
ON [dbo].[Grant]([SubjectId] ASC, [ClientId] ASC, [Type] ASC);
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Grant_ExpirationDate]
|
||||
ON [dbo].[Grant]([ExpirationDate] ASC);
|
||||
|
||||
|
Reference in New Issue
Block a user