diff --git a/server/channels/db/migrations/migrations.list b/server/channels/db/migrations/migrations.list index 3ec0c0d59ae..06ca4ab90d3 100644 --- a/server/channels/db/migrations/migrations.list +++ b/server/channels/db/migrations/migrations.list @@ -421,3 +421,7 @@ channels/db/migrations/postgres/000212_add_scheduled_post_recurrence.down.sql channels/db/migrations/postgres/000212_add_scheduled_post_recurrence.up.sql channels/db/migrations/postgres/000213_add_scheduled_post_pending_index.down.sql channels/db/migrations/postgres/000213_add_scheduled_post_pending_index.up.sql +channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.down.sql +channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.up.sql +channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.down.sql +channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.up.sql diff --git a/server/channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.down.sql b/server/channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.down.sql new file mode 100644 index 00000000000..9fc4a9381b3 --- /dev/null +++ b/server/channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.down.sql @@ -0,0 +1,8 @@ +-- morph:nontransactional +-- Recreate the partial index on the channelmembers autotranslation column, +-- mirroring migration 000147. Runs after 000215 restores the column. +-- CONCURRENTLY cannot run inside a transaction, so this must be the only +-- statement in the file. +CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_channelmembers_autotranslation_enabled + ON channelmembers (channelid) + WHERE autotranslation = true; diff --git a/server/channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.up.sql b/server/channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.up.sql new file mode 100644 index 00000000000..e191d38f024 --- /dev/null +++ b/server/channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.up.sql @@ -0,0 +1,5 @@ +-- morph:nontransactional +-- Drop the partial index on the deprecated channelmembers autotranslation +-- column ahead of dropping the column itself in 000215. CONCURRENTLY cannot run +-- inside a transaction, so this must be the only statement in the file. +DROP INDEX CONCURRENTLY IF EXISTS idx_channelmembers_autotranslation_enabled; diff --git a/server/channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.down.sql b/server/channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.down.sql new file mode 100644 index 00000000000..342a3873f3c --- /dev/null +++ b/server/channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.down.sql @@ -0,0 +1,5 @@ +-- Recreate the deprecated channelmembers autotranslation column, mirroring +-- migration 000147. Prior values are not restorable. The partial index is +-- recreated separately in 000214. +ALTER TABLE channelmembers + ADD COLUMN IF NOT EXISTS autotranslation boolean NOT NULL DEFAULT false; diff --git a/server/channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.up.sql b/server/channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.up.sql new file mode 100644 index 00000000000..3cfa7121eb4 --- /dev/null +++ b/server/channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.up.sql @@ -0,0 +1,5 @@ +-- Drop the deprecated channelmembers autotranslation column (opt-in semantics), +-- replaced by autotranslationdisabled (opt-out) in migration 000151. The partial +-- index on this column is dropped separately in 000214. +ALTER TABLE channelmembers + DROP COLUMN IF EXISTS autotranslation;