mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 09:02:48 -05:00
u2f db updates
This commit is contained in:
19
src/Sql/dbo/Stored Procedures/U2f_DeleteOld.sql
Normal file
19
src/Sql/dbo/Stored Procedures/U2f_DeleteOld.sql
Normal file
@ -0,0 +1,19 @@
|
||||
CREATE PROCEDURE [dbo].[U2f_DeleteOld]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DECLARE @BatchSize INT = 100
|
||||
DECLARE @Threshold DATETIME2(7) = DATEADD (day, -7, GETUTCDATE())
|
||||
|
||||
WHILE @BatchSize > 0
|
||||
BEGIN
|
||||
DELETE TOP(@BatchSize)
|
||||
FROM
|
||||
[dbo].[U2f]
|
||||
WHERE
|
||||
[CreationDate] < @Threshold
|
||||
|
||||
SET @BatchSize = @@ROWCOUNT
|
||||
END
|
||||
END
|
@ -10,3 +10,13 @@
|
||||
CONSTRAINT [FK_U2f_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])
|
||||
);
|
||||
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_U2f_CreationDate]
|
||||
ON [dbo].[U2f]([CreationDate] ASC)
|
||||
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_U2f_UserId]
|
||||
ON [dbo].[U2f]([UserId] ASC);
|
||||
|
||||
|
Reference in New Issue
Block a user