1
0
mirror of https://github.com/bitwarden/server synced 2026-02-24 00:23:05 +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,29 @@
-- Populate DefaultCollectionSemaphore from existing Type=1 (DefaultUserCollection) collections
-- This migration is idempotent and can be run multiple times safely
INSERT INTO [dbo].[DefaultCollectionSemaphore]
(
[OrganizationId],
[OrganizationUserId],
[CreationDate]
)
SELECT DISTINCT
c.[OrganizationId],
cu.[OrganizationUserId],
c.[CreationDate]
FROM
[dbo].[Collection] c
INNER JOIN
[dbo].[CollectionUser] cu ON c.[Id] = cu.[CollectionId]
WHERE
c.[Type] = 1 -- CollectionType.DefaultUserCollection
AND NOT EXISTS
(
SELECT
1
FROM
[dbo].[DefaultCollectionSemaphore] dcs
WHERE
dcs.[OrganizationId] = c.[OrganizationId]
AND dcs.[OrganizationUserId] = cu.[OrganizationUserId]
);
GO