From 5892e8175adc683d96bf304a9e3ac44a23267c5c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 8 May 2020 20:23:16 +0200 Subject: Fix migrations failing due to strong-migrations update (#13680) --- db/migrate/20171125031751_add_invite_id_to_users.rb | 2 +- db/migrate/20180402031200_add_assigned_account_id_to_reports.rb | 2 +- .../20180510214435_add_access_token_id_to_web_push_subscriptions.rb | 6 ++++-- db/migrate/20181219235220_add_created_by_application_id_to_users.rb | 2 +- .../20190103124754_add_scheduled_status_id_to_media_attachments.rb | 2 +- db/migrate/20200312185443_add_parent_id_to_email_domain_blocks.rb | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) (limited to 'db') diff --git a/db/migrate/20171125031751_add_invite_id_to_users.rb b/db/migrate/20171125031751_add_invite_id_to_users.rb index 16829f866..9cfb0c542 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 0456839c4..e2d1371d2 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 94ef8e0f5..f60716532 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 17ce900af..81c9237e8 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 6f6cf2351..7d904af60 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 03915040c..54ca3b87c 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 -- cgit From 38b69512ffd13abc992a91e33e199881d38bc164 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 9 May 2020 18:37:39 +0200 Subject: Fix old unique jobs digests not having been cleaned up (#13683) --- db/migrate/20200508212852_reset_unique_jobs_locks.rb | 12 ++++++++++++ db/schema.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200508212852_reset_unique_jobs_locks.rb (limited to 'db') diff --git a/db/migrate/20200508212852_reset_unique_jobs_locks.rb b/db/migrate/20200508212852_reset_unique_jobs_locks.rb new file mode 100644 index 000000000..3ffdeb0aa --- /dev/null +++ b/db/migrate/20200508212852_reset_unique_jobs_locks.rb @@ -0,0 +1,12 @@ +class ResetUniqueJobsLocks < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + # We do this to clean up unique job digests that were not properly + # disposed of prior to https://github.com/tootsuite/mastodon/pull/13361 + + SidekiqUniqueJobs::Digests.delete_by_pattern('*', count: SidekiqUniqueJobs::Digests.count) + end + + def down; end +end diff --git a/db/schema.rb b/db/schema.rb index 7cbfebb00..08a2335ee 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_04_17_125749) do +ActiveRecord::Schema.define(version: 2020_05_08_212852) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit From 4b2d9b8a558190f8ccc51cfe67f5e151f2c3342b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 10 May 2020 18:18:12 +0200 Subject: Reset secret of web app that could have been exposed by Doorkeeper (#13688) There are no obvious ways it could be misused, as the secret is not really used for anything, but it is best to secure it for the future Follow-up to #13613 --- db/migrate/20200510110808_reset_web_app_secret.rb | 15 +++++++++++++++ db/schema.rb | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200510110808_reset_web_app_secret.rb (limited to 'db') diff --git a/db/migrate/20200510110808_reset_web_app_secret.rb b/db/migrate/20200510110808_reset_web_app_secret.rb new file mode 100644 index 000000000..b274844c5 --- /dev/null +++ b/db/migrate/20200510110808_reset_web_app_secret.rb @@ -0,0 +1,15 @@ +class ResetWebAppSecret < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + web_app = Doorkeeper::Application.find_by(superapp: true) + + return if web_app.nil? + + web_app.renew_secret + web_app.save! + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 08a2335ee..31f0c96bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_05_08_212852) do +ActiveRecord::Schema.define(version: 2020_05_10_110808) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit