mirror of
https://github.com/bitwarden/server.git
synced 2026-02-08 09:53:14 +08:00
* Sso user table, model and repo stubbed out * switch to nullable org id, bigint id * update GetBySsoUserAsync * cleanup migrator file * fix EF user repo * fix pg repo * is `IS NULL` checks * unique indexes * update migration scripts * add another unique index * remove old script
23 lines
879 B
Transact-SQL
23 lines
879 B
Transact-SQL
CREATE TABLE [dbo].[SsoUser] (
|
|
[Id] BIGINT IDENTITY (1, 1) NOT NULL,
|
|
[UserId] UNIQUEIDENTIFIER NOT NULL,
|
|
[OrganizationId] UNIQUEIDENTIFIER NULL,
|
|
[ExternalId] NVARCHAR(50) NOT NULL,
|
|
[CreationDate] DATETIME2 (7) NOT NULL,
|
|
CONSTRAINT [PK_SsoUser] PRIMARY KEY CLUSTERED ([Id] ASC),
|
|
CONSTRAINT [FK_SsoUser_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) ON DELETE CASCADE,
|
|
CONSTRAINT [FK_SsoUser_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
|
|
);
|
|
|
|
|
|
GO
|
|
CREATE UNIQUE NONCLUSTERED INDEX [IX_SsoUser_OrganizationIdExternalId]
|
|
ON [dbo].[SsoUser]([OrganizationId] ASC, [ExternalId] ASC)
|
|
INCLUDE ([UserId]);
|
|
|
|
GO
|
|
CREATE UNIQUE NONCLUSTERED INDEX [IX_SsoUser_OrganizationIdUserId]
|
|
ON [dbo].[SsoUser]([OrganizationId] ASC, [UserId] ASC);
|
|
|
|
|