about summary refs log tree commit diff
path: root/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-12-29 05:39:08 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-12-29 05:39:08 +0100
commit1155dc08352c3aa1cb763729122c34a3db6e64ec (patch)
treea33d5437ff70fbfb4fdc3b093f2af2b5ea9d26e3 /db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb
parent7ff7ca8c7c8d6612760db93d533a18e83b0a9c70 (diff)
Fix old migrations failing because of strong_migrations update (#12692)
Fixes #12690

The `strong_migrations` update from ba2eac8824a85aa9541f8070ed7bcd22b9982cc8
introduced a check for `change_column_null` specific to Postgres. This rejects
old migrations.

This commit just wraps old migrations with `safety_assured` to bypass this
check. Alternatives would have been to:
- Disable that check entirely (a possibility added in that same
  `strong_migrations` version) for Mastodon, but it makes sense to write new
  migrations without such a strong lock.
- Rewrite the old migrations to do it in a way that do not require an exclusive
  lock. I thought fixing those old migrations for performance wasn't worth the
  pain. Also, if I understand correctly, the next version of
  `strong_migrations` is going to include a helper to do that. We could update
  those migrations at that point.
Diffstat (limited to 'db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb')
-rw-r--r--db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb b/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb
index 747e5a826..1d7a0086c 100644
--- a/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb
+++ b/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb
@@ -1,6 +1,8 @@
 class ChangeAccountsNonnullableInAccountModerationNotes < ActiveRecord::Migration[5.1]
   def change
-    change_column_null :account_moderation_notes, :account_id, false
-    change_column_null :account_moderation_notes, :target_account_id, false
+    safety_assured do
+      change_column_null :account_moderation_notes, :account_id, false
+      change_column_null :account_moderation_notes, :target_account_id, false
+    end
   end
 end