Files
server/util/MySqlMigrations/HelperScripts/2024-01-12_01_AccessAllCollectionUsers.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
766 B
MySQL
Raw Normal View History

2023-12-19 15:46:23 +00:00
-- Update existing rows in CollectionUsers
UPDATE CollectionUsers AS target
2023-12-19 19:49:57 +00:00
INNER JOIN Collection AS C ON target.CollectionId = C.Id
INNER JOIN OrganizationUser AS OU ON C.OrganizationId = OU.OrganizationId
2023-12-19 15:46:23 +00:00
SET
target.ReadOnly = 0,
target.HidePasswords = 0,
2023-12-19 19:49:57 +00:00
target.Manage = 0
WHERE OU.AccessAll = 1;
2023-12-17 21:26:12 +00:00
2023-12-19 15:46:23 +00:00
-- Insert new rows into CollectionUsers
INSERT INTO CollectionUsers (CollectionId, OrganizationUserId, ReadOnly, HidePasswords, Manage)
2023-12-19 19:49:57 +00:00
SELECT C.Id AS CollectionId, OU.Id AS OrganizationUserId, 0, 0, 0
FROM Collection AS C
INNER JOIN OrganizationUser AS OU ON C.OrganizationId = OU.OrganizationId
WHERE OU.AccessAll = 1
AND NOT EXISTS (
SELECT 1
FROM CollectionUsers AS CU
WHERE CU.CollectionId = C.Id AND CU.OrganizationUserId = OU.Id
);