1
0
mirror of https://github.com/bitwarden/server synced 2025-12-15 15:53:59 +00:00

Fixup device table user FK cascade

This commit is contained in:
Matt Gibson
2025-10-09 16:47:47 -07:00
parent 44aef68c31
commit 3d863c0fd1
2 changed files with 11 additions and 1 deletions

View File

@@ -12,7 +12,7 @@
[EncryptedPrivateKey] VARCHAR (MAX) NULL,
[Active] BIT NOT NULL CONSTRAINT [DF_Device_Active] DEFAULT (1),
CONSTRAINT [PK_Device] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_Device_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])
CONSTRAINT [FK_Device_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) ON DELETE CASCADE
);
GO

View File

@@ -0,0 +1,10 @@
IF OBJECT_ID('[dbo].[FK_Device_User]', 'F') IS NOT NULL
BEGIN
ALTER TABLE [dbo].[Device]
DROP CONSTRAINT [FK_Device_User]
END
GO
ALTER TABLE [dbo].[Device]
ADD CONSTRAINT [FK_Device_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) ON DELETE CASCADE
GO