Adds logical deletes to shared channel remotes and remote clusters (#28159)
* Adds logical deletes to shared channel remotes and remote clusters Instead of physically deleting the shared channel remote and remote clusters records when a channel is unshared, a remote uninvited or a remote cluster is deleted, now those have a logical `DeleteAt` field that is set. This allows us to safely restore shared channels between two remote clusters (as of now resetting the cursor without backfilling their contents) and to know which connections were established in the past and now are severed. * Delete the index in remoteclusters before adding the new column * Fix bad error check
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
19733eef1e
Коммит
f8202309ce
@@ -247,6 +247,8 @@ channels/db/migrations/mysql/000124_remove_manage_team_permission.down.sql
|
||||
channels/db/migrations/mysql/000124_remove_manage_team_permission.up.sql
|
||||
channels/db/migrations/mysql/000125_remoteclusters_add_default_team_id.down.sql
|
||||
channels/db/migrations/mysql/000125_remoteclusters_add_default_team_id.up.sql
|
||||
channels/db/migrations/mysql/000126_sharedchannels_remotes_add_deleteat.down.sql
|
||||
channels/db/migrations/mysql/000126_sharedchannels_remotes_add_deleteat.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
|
||||
@@ -495,3 +497,5 @@ channels/db/migrations/postgres/000124_remove_manage_team_permission.down.sql
|
||||
channels/db/migrations/postgres/000124_remove_manage_team_permission.up.sql
|
||||
channels/db/migrations/postgres/000125_remoteclusters_add_default_team_id.down.sql
|
||||
channels/db/migrations/postgres/000125_remoteclusters_add_default_team_id.up.sql
|
||||
channels/db/migrations/postgres/000126_sharedchannels_remotes_add_deleteat.down.sql
|
||||
channels/db/migrations/postgres/000126_sharedchannels_remotes_add_deleteat.up.sql
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- Skipping it because the forward migrations are destructive
|
||||
@@ -0,0 +1,44 @@
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
|
||||
WHERE table_name = 'RemoteClusters'
|
||||
AND table_schema = DATABASE()
|
||||
AND index_name = 'remote_clusters_site_url_unique'
|
||||
) > 0,
|
||||
'DROP INDEX remote_clusters_site_url_unique ON RemoteClusters;',
|
||||
'SELECT 1'
|
||||
));
|
||||
|
||||
PREPARE removeIndexIfExists FROM @preparedStatement;
|
||||
EXECUTE removeIndexIfExists;
|
||||
DEALLOCATE PREPARE removeIndexIfExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'RemoteClusters'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DeleteAt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE RemoteClusters ADD DeleteAt bigint(20) DEFAULT 0;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'SharedChannelRemotes'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DeleteAt'
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
'ALTER TABLE SharedChannelRemotes ADD DeleteAt bigint(20) DEFAULT 0;'
|
||||
));
|
||||
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
@@ -0,0 +1 @@
|
||||
-- Skipping it because the forward migrations are destructive
|
||||
@@ -0,0 +1,4 @@
|
||||
DROP INDEX IF EXISTS remote_clusters_site_url_unique;
|
||||
ALTER TABLE remoteclusters ADD COLUMN IF NOT EXISTS deleteat bigint DEFAULT 0;
|
||||
|
||||
ALTER TABLE sharedchannelremotes ADD COLUMN IF NOT EXISTS deleteat bigint DEFAULT 0;
|
||||
Ссылка в новой задаче
Block a user