1
0
mirror of https://github.com/bitwarden/server synced 2026-02-28 02:13:19 +00:00

First pass at semaphore

This commit is contained in:
Thomas Rittson
2025-12-30 14:21:38 +10:00
parent 34b4dc3985
commit f069fafea1
13 changed files with 785 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
-- Create DefaultCollectionSemaphore table
-- Cascade behavior: Organization -> OrganizationUser (CASCADE) -> DefaultCollectionSemaphore (CASCADE)
-- OrganizationId FK has NO ACTION to avoid competing cascade paths
IF OBJECT_ID('[dbo].[DefaultCollectionSemaphore]') IS NULL
BEGIN
CREATE TABLE [dbo].[DefaultCollectionSemaphore]
(
[OrganizationId] UNIQUEIDENTIFIER NOT NULL,
[OrganizationUserId] UNIQUEIDENTIFIER NOT NULL,
[CreationDate] DATETIME2(7) NOT NULL,
CONSTRAINT [PK_DefaultCollectionSemaphore] PRIMARY KEY CLUSTERED
(
[OrganizationId] ASC,
[OrganizationUserId] ASC
),
CONSTRAINT [FK_DefaultCollectionSemaphore_Organization] FOREIGN KEY ([OrganizationId])
REFERENCES [dbo].[Organization] ([Id]), -- NO ACTION to avoid competing cascades
CONSTRAINT [FK_DefaultCollectionSemaphore_OrganizationUser] FOREIGN KEY ([OrganizationUserId])
REFERENCES [dbo].[OrganizationUser] ([Id])
ON DELETE CASCADE -- Cascades from OrganizationUser deletion
);
END
GO