1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 13:08:17 -05:00

Move migration and prevent failure

This commit is contained in:
Bernd Schoolmann 2025-03-21 18:00:30 +01:00
parent 8073d0e0c3
commit 6d4d7c7968
No known key found for this signature in database

View File

@ -1,3 +1,10 @@
IF OBJECT_ID('[dbo].[OpaqueKeyExchangeCredential]') IS NULL
BEGIN
CREATE TABLE [dbo].[OpaqueKeyExchangeCredential]
(
[Id] UNIQUEIDENTIFIER NOT NULL,
@ -10,15 +17,18 @@ CREATE TABLE [dbo].[OpaqueKeyExchangeCredential]
[CreationDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_OpaqueKeyExchangeCredential] PRIMARY KEY CLUSTERED ([UserId]), -- using this as the primary key ensure users only have one credential
CONSTRAINT [FK_OpaqueKeyExchangeCredential_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])
);
)
END
GO
IF NOT EXISTS(SELECT name FROM sys.indexes WHERE name = 'IX_OpaqueKeyExchangeCredential_UserId')
BEGIN
CREATE NONCLUSTERED INDEX [IX_OpaqueKeyExchangeCredential_UserId]
ON [dbo].[OpaqueKeyExchangeCredential]([UserId] ASC);
END
GO
CREATE OR ALTER PROCEDURE [dbo].[OpaqueKeyExchangeCredential_Create]
@Id UNIQUEIDENTIFIER OUTPUT,
@UserId UNIQUEIDENTIFIER,