db/migrations: ensure to drop parentid from posts table (#21493)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-10-25 16:32:34 +03:00
коммит произвёл GitHub
родитель b62ee905ae
Коммит c5f4882f0a
5 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@@ -188,6 +188,8 @@ db/migrations/mysql/000093_notify_admin.down.sql
db/migrations/mysql/000093_notify_admin.up.sql
db/migrations/mysql/000094_threads_teamid.down.sql
db/migrations/mysql/000094_threads_teamid.up.sql
db/migrations/mysql/000095_remove_posts_parentid.down.sql
db/migrations/mysql/000095_remove_posts_parentid.up.sql
db/migrations/postgres/000001_create_teams.down.sql
db/migrations/postgres/000001_create_teams.up.sql
db/migrations/postgres/000002_create_team_members.down.sql
@@ -376,3 +378,5 @@ db/migrations/postgres/000093_notify_admin.down.sql
db/migrations/postgres/000093_notify_admin.up.sql
db/migrations/postgres/000094_threads_teamid.down.sql
db/migrations/postgres/000094_threads_teamid.up.sql
db/migrations/postgres/000095_remove_posts_parentid.down.sql
db/migrations/postgres/000095_remove_posts_parentid.up.sql

Просмотреть файл

@@ -0,0 +1 @@
-- Intentionally left blank as forward migration is not reversible.

Просмотреть файл

@@ -0,0 +1,17 @@
-- While upgrading from 5.x to 6.x with manual queries, there is a chance that this
-- migration is skipped. In that case, we need to make sure that the column is dropped.
SET @preparedStatement = (SELECT IF(
(
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'Posts'
AND table_schema = DATABASE()
AND column_name = 'ParentId'
) > 0,
'ALTER TABLE Posts DROP COLUMN ParentId;',
'SELECT 1'
));
PREPARE alterIfExists FROM @preparedStatement;
EXECUTE alterIfExists;
DEALLOCATE PREPARE alterIfExists;

Просмотреть файл

@@ -0,0 +1 @@
-- Intentionally left blank as forward migration is not reversible.

Просмотреть файл

@@ -0,0 +1,4 @@
-- While upgrading from 5.x to 6.x with manual queries, there is a chance that this
-- migration is skipped. In that case, we need to make sure that the column is dropped.
ALTER TABLE posts DROP COLUMN IF EXISTS parentid;