коммит произвёл
GitHub
родитель
073bd3a6b7
Коммит
9408b98025
@@ -279,6 +279,12 @@ channels/db/migrations/mysql/000140_add_lastmemberssyncat_to_sharedchannelremote
|
||||
channels/db/migrations/mysql/000140_add_lastmemberssyncat_to_sharedchannelremotes.up.sql
|
||||
channels/db/migrations/mysql/000141_add_remoteid_channelid_to_post_acknowledgements.down.sql
|
||||
channels/db/migrations/mysql/000141_add_remoteid_channelid_to_post_acknowledgements.up.sql
|
||||
channels/db/migrations/mysql/000142_add_schemeid_to_roles.down.sql
|
||||
channels/db/migrations/mysql/000142_add_schemeid_to_roles.up.sql
|
||||
channels/db/migrations/mysql/000143_backfill_roles_schemeid.down.sql
|
||||
channels/db/migrations/mysql/000143_backfill_roles_schemeid.up.sql
|
||||
channels/db/migrations/mysql/000144_add_roles_schemeid_index.down.sql
|
||||
channels/db/migrations/mysql/000144_add_roles_schemeid_index.up.sql
|
||||
channels/db/migrations/postgres/000001_create_teams.down.sql
|
||||
channels/db/migrations/postgres/000001_create_teams.up.sql
|
||||
channels/db/migrations/postgres/000002_create_team_members.down.sql
|
||||
@@ -559,3 +565,9 @@ channels/db/migrations/postgres/000140_add_lastmemberssyncat_to_sharedchannelrem
|
||||
channels/db/migrations/postgres/000140_add_lastmemberssyncat_to_sharedchannelremotes.up.sql
|
||||
channels/db/migrations/postgres/000141_add_remoteid_channelid_to_post_acknowledgements.down.sql
|
||||
channels/db/migrations/postgres/000141_add_remoteid_channelid_to_post_acknowledgements.up.sql
|
||||
channels/db/migrations/postgres/000142_add_schemeid_to_roles.down.sql
|
||||
channels/db/migrations/postgres/000142_add_schemeid_to_roles.up.sql
|
||||
channels/db/migrations/postgres/000143_backfill_roles_schemeid.down.sql
|
||||
channels/db/migrations/postgres/000143_backfill_roles_schemeid.up.sql
|
||||
channels/db/migrations/postgres/000144_add_roles_schemeid_index.down.sql
|
||||
channels/db/migrations/postgres/000144_add_roles_schemeid_index.up.sql
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Roles'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeId'
|
||||
) > 0,
|
||||
'ALTER TABLE Roles DROP COLUMN SchemeId;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE dropColumnIfExists FROM @preparedStatement;
|
||||
EXECUTE dropColumnIfExists;
|
||||
DEALLOCATE PREPARE dropColumnIfExists;
|
||||
@@ -0,0 +1,14 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Roles'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'SchemeId'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE Roles ADD COLUMN SchemeId varchar(26);'
|
||||
));
|
||||
|
||||
PREPARE addColumnIfNotExists FROM @preparedStatement;
|
||||
EXECUTE addColumnIfNotExists;
|
||||
DEALLOCATE PREPARE addColumnIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
UPDATE Roles SET SchemeId = NULL;
|
||||
@@ -0,0 +1,19 @@
|
||||
UPDATE Roles r
|
||||
INNER JOIN (
|
||||
SELECT role_name, MIN(scheme_id) AS scheme_id
|
||||
FROM (
|
||||
SELECT Id AS scheme_id, DefaultTeamAdminRole AS role_name FROM Schemes
|
||||
UNION ALL SELECT Id, DefaultTeamUserRole FROM Schemes
|
||||
UNION ALL SELECT Id, DefaultTeamGuestRole FROM Schemes
|
||||
UNION ALL SELECT Id, DefaultChannelAdminRole FROM Schemes
|
||||
UNION ALL SELECT Id, DefaultChannelUserRole FROM Schemes
|
||||
UNION ALL SELECT Id, DefaultChannelGuestRole FROM Schemes
|
||||
UNION ALL SELECT Id, DefaultPlaybookAdminRole FROM Schemes
|
||||
UNION ALL SELECT Id, DefaultPlaybookMemberRole FROM Schemes
|
||||
UNION ALL SELECT Id, DefaultRunAdminRole FROM Schemes
|
||||
UNION ALL SELECT Id, DefaultRunMemberRole FROM Schemes
|
||||
) expanded
|
||||
WHERE role_name IS NOT NULL AND role_name <> ''
|
||||
GROUP BY role_name
|
||||
) m ON r.Name = m.role_name
|
||||
SET r.SchemeId = m.scheme_id;
|
||||
@@ -0,0 +1,14 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Roles'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_roles_scheme_id'
|
||||
) > 0,
|
||||
'DROP INDEX idx_roles_scheme_id ON Roles;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
@@ -0,0 +1,14 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'Roles'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'idx_roles_scheme_id'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_roles_scheme_id ON Roles(SchemeId);'
|
||||
));
|
||||
|
||||
PREPARE createIndexIfNotExists FROM @preparedStatement;
|
||||
EXECUTE createIndexIfNotExists;
|
||||
DEALLOCATE PREPARE createIndexIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE roles DROP COLUMN IF EXISTS schemeid;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE roles ADD COLUMN IF NOT EXISTS schemeid VARCHAR(26);
|
||||
@@ -0,0 +1 @@
|
||||
UPDATE roles SET schemeid = NULL;
|
||||
@@ -0,0 +1,23 @@
|
||||
UPDATE roles
|
||||
SET schemeid = match.scheme_id
|
||||
FROM (
|
||||
SELECT DISTINCT ON (role_name) id AS scheme_id, role_name
|
||||
FROM (
|
||||
SELECT id, unnest(ARRAY[
|
||||
defaultteamadminrole,
|
||||
defaultteamuserrole,
|
||||
defaultteamguestrole,
|
||||
defaultchanneladminrole,
|
||||
defaultchanneluserrole,
|
||||
defaultchannelguestrole,
|
||||
defaultplaybookadminrole,
|
||||
defaultplaybookmemberrole,
|
||||
defaultrunadminrole,
|
||||
defaultrunmemberrole
|
||||
]) AS role_name
|
||||
FROM schemes
|
||||
) expanded
|
||||
WHERE role_name IS NOT NULL AND role_name <> ''
|
||||
ORDER BY role_name, scheme_id
|
||||
) match
|
||||
WHERE roles.name = match.role_name;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- morph:nontransactional
|
||||
DROP INDEX CONCURRENTLY IF EXISTS idx_roles_scheme_id;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- morph:nontransactional
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_roles_scheme_id ON roles(schemeid);
|
||||
Ссылка в новой задаче
Block a user