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:
parent
8073d0e0c3
commit
6d4d7c7968
@ -1,24 +1,34 @@
|
|||||||
CREATE TABLE [dbo].[OpaqueKeyExchangeCredential]
|
|
||||||
(
|
|
||||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
|
||||||
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
|
||||||
[CipherConfiguration] VARCHAR(MAX) NOT NULL,
|
|
||||||
[CredentialBlob] VARCHAR(MAX) NOT NULL,
|
|
||||||
[EncryptedPublicKey] VARCHAR(MAX) NOT NULL,
|
|
||||||
[EncryptedPrivateKey] VARCHAR(MAX) NOT NULL,
|
|
||||||
[EncryptedUserKey] VARCHAR(MAX) NULL,
|
|
||||||
[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])
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IF OBJECT_ID('[dbo].[OpaqueKeyExchangeCredential]') IS NULL
|
||||||
|
BEGIN
|
||||||
|
CREATE TABLE [dbo].[OpaqueKeyExchangeCredential]
|
||||||
|
(
|
||||||
|
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||||
|
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
||||||
|
[CipherConfiguration] VARCHAR(MAX) NOT NULL,
|
||||||
|
[CredentialBlob] VARCHAR(MAX) NOT NULL,
|
||||||
|
[EncryptedPublicKey] VARCHAR(MAX) NOT NULL,
|
||||||
|
[EncryptedPrivateKey] VARCHAR(MAX) NOT NULL,
|
||||||
|
[EncryptedUserKey] VARCHAR(MAX) NULL,
|
||||||
|
[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
|
GO
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX [IX_OpaqueKeyExchangeCredential_UserId]
|
IF NOT EXISTS(SELECT name FROM sys.indexes WHERE name = 'IX_OpaqueKeyExchangeCredential_UserId')
|
||||||
ON [dbo].[OpaqueKeyExchangeCredential]([UserId] ASC);
|
BEGIN
|
||||||
|
CREATE NONCLUSTERED INDEX [IX_OpaqueKeyExchangeCredential_UserId]
|
||||||
|
ON [dbo].[OpaqueKeyExchangeCredential]([UserId] ASC);
|
||||||
|
END
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
|
||||||
CREATE OR ALTER PROCEDURE [dbo].[OpaqueKeyExchangeCredential_Create]
|
CREATE OR ALTER PROCEDURE [dbo].[OpaqueKeyExchangeCredential_Create]
|
||||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
@UserId UNIQUEIDENTIFIER,
|
@UserId UNIQUEIDENTIFIER,
|
Loading…
x
Reference in New Issue
Block a user