mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Remove EF migration scripts (#2550)
* Removed Scripts folders * Removed .csproj references. * Added back HelperScripts * Added back additional helper scripts. * Fixed extra ItemGroup
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
-- Split Manage Assigned Collections into edit and delete
|
||||
UPDATE `OrganizationUser`
|
||||
SET `Permissions` =
|
||||
JSON_INSERT(
|
||||
`Permissions`,
|
||||
'$.editAssignedCollections',
|
||||
IFNULL(
|
||||
IFNULL(
|
||||
JSON_EXTRACT(`Permissions`,'$.editAssignedCollections'),
|
||||
JSON_EXTRACT(`Permissions`, '$.manageAssignedCollections')),
|
||||
false),
|
||||
'$.deleteAssignedCollections',
|
||||
IFNULL(
|
||||
IFNULL(
|
||||
JSON_EXTRACT(`Permissions`, '$.deleteAssignedCollections'),
|
||||
JSON_EXTRACT(`Permissions`, '$.manageAssignedCollections')),
|
||||
false)
|
||||
)
|
||||
WHERE `Permissions` IS NOT NULL
|
||||
AND JSON_VALID(`Permissions`) > 0
|
||||
AND (
|
||||
JSON_EXTRACT(`Permissions`, '$.editAssignedCollections') IS NULL
|
||||
OR JSON_EXTRACT(`Permissions`, '$.deleteAssignedCollections') IS NULL
|
||||
);
|
||||
|
||||
-- Split Manage All Collections into create, edit, and delete
|
||||
UPDATE `OrganizationUser`
|
||||
SET `Permissions` =
|
||||
JSON_INSERT(
|
||||
`Permissions`,
|
||||
'$.createNewCollections',
|
||||
IFNULL(
|
||||
IFNULL(
|
||||
JSON_EXTRACT(`Permissions`, '$.createNewColletions'),
|
||||
JSON_EXTRACT(`Permissions`, '$.manageAllCollections')),
|
||||
false),
|
||||
'$.editAnyCollection',
|
||||
IFNULL(
|
||||
IFNULL(
|
||||
JSON_EXTRACT(`Permissions`, '$.editAnyCollection'),
|
||||
JSON_EXTRACT(`Permissions`, '$.manageAllCollections')),
|
||||
false),
|
||||
'$.deleteAnyCollection',
|
||||
IFNULL(
|
||||
IFNULL(
|
||||
JSON_EXTRACT(`Permissions`, '$.deleteAnyCollection'),
|
||||
JSON_EXTRACT(`Permissions`, '$.manageAllCollections')),
|
||||
false)
|
||||
)
|
||||
WHERE `Permissions` IS NOT NULL
|
||||
AND JSON_VALID(`Permissions`) > 0
|
||||
AND (
|
||||
JSON_EXTRACT(`Permissions`, '$.createNewCollections') IS NULL
|
||||
OR JSON_EXTRACT(`Permissions`, '$.editAnyCollection') IS NULL
|
||||
OR JSON_EXTRACT(`Permissions`, '$.deleteAnyCollection') IS NULL
|
||||
);
|
@ -0,0 +1,20 @@
|
||||
SET @run_migration_seats = 0;
|
||||
SELECT 1 FROM `Organization`
|
||||
WHERE `MaxAutoscaleSeats` IS NOT NULL
|
||||
LIMIT 1
|
||||
INTO @run_migration_seats;
|
||||
|
||||
SET @run_migration_email = 0;
|
||||
SELECT 1 FROM `Organization`
|
||||
WHERE `OwnersNotifiedOfAutoscaling` IS NOT NULL
|
||||
LIMIT 1
|
||||
INTO @run_migration_email;
|
||||
|
||||
SET @stmt = case @run_migration_seats + @run_migration_email
|
||||
WHEN 0 THEN 'UPDATE `Organization` SET `MaxAutoscaleSeats` = `Seats`'
|
||||
ELSE 'SELECT ''No migration necessary'''
|
||||
END;
|
||||
|
||||
PREPARE stmt FROM @stmt;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
Reference in New Issue
Block a user