From 5892e8175adc683d96bf304a9e3ac44a23267c5c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 8 May 2020 20:23:16 +0200 Subject: [PATCH] Fix migrations failing due to strong-migrations update (#13680) --- db/migrate/20171125031751_add_invite_id_to_users.rb | 2 +- .../20180402031200_add_assigned_account_id_to_reports.rb | 2 +- ...0214435_add_access_token_id_to_web_push_subscriptions.rb | 6 ++++-- ...20181219235220_add_created_by_application_id_to_users.rb | 2 +- ...03124754_add_scheduled_status_id_to_media_attachments.rb | 2 +- .../20200312185443_add_parent_id_to_email_domain_blocks.rb | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/db/migrate/20171125031751_add_invite_id_to_users.rb b/db/migrate/20171125031751_add_invite_id_to_users.rb index 16829f8665..9cfb0c542c 100644 --- a/db/migrate/20171125031751_add_invite_id_to_users.rb +++ b/db/migrate/20171125031751_add_invite_id_to_users.rb @@ -1,5 +1,5 @@ class AddInviteIdToUsers < ActiveRecord::Migration[5.1] def change - add_reference :users, :invite, null: true, default: nil, foreign_key: { on_delete: :nullify }, index: false + safety_assured { add_reference :users, :invite, null: true, default: nil, foreign_key: { on_delete: :nullify }, index: false } end end diff --git a/db/migrate/20180402031200_add_assigned_account_id_to_reports.rb b/db/migrate/20180402031200_add_assigned_account_id_to_reports.rb index 0456839c4a..e2d1371d2d 100644 --- a/db/migrate/20180402031200_add_assigned_account_id_to_reports.rb +++ b/db/migrate/20180402031200_add_assigned_account_id_to_reports.rb @@ -1,5 +1,5 @@ class AddAssignedAccountIdToReports < ActiveRecord::Migration[5.1] def change - add_reference :reports, :assigned_account, null: true, default: nil, foreign_key: { on_delete: :nullify, to_table: :accounts }, index: false + safety_assured { add_reference :reports, :assigned_account, null: true, default: nil, foreign_key: { on_delete: :nullify, to_table: :accounts }, index: false } end end diff --git a/db/migrate/20180510214435_add_access_token_id_to_web_push_subscriptions.rb b/db/migrate/20180510214435_add_access_token_id_to_web_push_subscriptions.rb index 94ef8e0f59..f607165328 100644 --- a/db/migrate/20180510214435_add_access_token_id_to_web_push_subscriptions.rb +++ b/db/migrate/20180510214435_add_access_token_id_to_web_push_subscriptions.rb @@ -1,6 +1,8 @@ class AddAccessTokenIdToWebPushSubscriptions < ActiveRecord::Migration[5.2] def change - add_reference :web_push_subscriptions, :access_token, null: true, default: nil, foreign_key: { on_delete: :cascade, to_table: :oauth_access_tokens }, index: false - add_reference :web_push_subscriptions, :user, null: true, default: nil, foreign_key: { on_delete: :cascade }, index: false + safety_assured do + add_reference :web_push_subscriptions, :access_token, null: true, default: nil, foreign_key: { on_delete: :cascade, to_table: :oauth_access_tokens }, index: false + add_reference :web_push_subscriptions, :user, null: true, default: nil, foreign_key: { on_delete: :cascade }, index: false + end end end diff --git a/db/migrate/20181219235220_add_created_by_application_id_to_users.rb b/db/migrate/20181219235220_add_created_by_application_id_to_users.rb index 17ce900af3..81c9237e83 100644 --- a/db/migrate/20181219235220_add_created_by_application_id_to_users.rb +++ b/db/migrate/20181219235220_add_created_by_application_id_to_users.rb @@ -2,7 +2,7 @@ class AddCreatedByApplicationIdToUsers < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change - add_reference :users, :created_by_application, foreign_key: { to_table: 'oauth_applications', on_delete: :nullify }, index: false + safety_assured { add_reference :users, :created_by_application, foreign_key: { to_table: 'oauth_applications', on_delete: :nullify }, index: false } add_index :users, :created_by_application_id, algorithm: :concurrently end end diff --git a/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb b/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb index 6f6cf23513..7d904af60f 100644 --- a/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb +++ b/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb @@ -2,7 +2,7 @@ class AddScheduledStatusIdToMediaAttachments < ActiveRecord::Migration[5.2] disable_ddl_transaction! def change - add_reference :media_attachments, :scheduled_status, foreign_key: { on_delete: :nullify }, index: false + safety_assured { add_reference :media_attachments, :scheduled_status, foreign_key: { on_delete: :nullify }, index: false } add_index :media_attachments, :scheduled_status_id, algorithm: :concurrently end end diff --git a/db/migrate/20200312185443_add_parent_id_to_email_domain_blocks.rb b/db/migrate/20200312185443_add_parent_id_to_email_domain_blocks.rb index 03915040c8..54ca3b87c8 100644 --- a/db/migrate/20200312185443_add_parent_id_to_email_domain_blocks.rb +++ b/db/migrate/20200312185443_add_parent_id_to_email_domain_blocks.rb @@ -1,5 +1,5 @@ class AddParentIdToEmailDomainBlocks < ActiveRecord::Migration[5.2] def change - add_reference :email_domain_blocks, :parent, null: true, default: nil, foreign_key: { on_delete: :cascade, to_table: :email_domain_blocks }, index: false + safety_assured { add_reference :email_domain_blocks, :parent, null: true, default: nil, foreign_key: { on_delete: :cascade, to_table: :email_domain_blocks }, index: false } end end