DEV: Partially move watched_precedence_over_muted migration to post-migration phase (#35755)

The change_column_null and change_column_default operations for the
watched_precedence_over_muted column have been moved from the
pre-migration
script to the post-migration script. This adjustment ensures that the
column
is only modified after all data transformations are complete, reducing
the
risk of data integrity issues during the migration process.

We have already seen this once in production, where a later failed
migration left the column in a bad state.
This commit is contained in:
Martin Brennan
2025-11-03 16:04:14 +10:00
committed by GitHub
parent 3485ef243f
commit 129d157b3c
2 changed files with 3 additions and 3 deletions
@@ -25,9 +25,6 @@ class ConvertWatchedPrecedenceOverMutedToDefaultPref < ActiveRecord::Migration[8
SET watched_precedence_over_muted = :preference_value
WHERE watched_precedence_over_muted IS NULL;
SQL
change_column_default :user_options, :watched_precedence_over_muted, from: nil, to: false
change_column_null :user_options, :watched_precedence_over_muted, false
end
def down
@@ -4,6 +4,9 @@ class DeleteOldWatchedPrecedenceSetting < ActiveRecord::Migration[8.0]
DB.exec(<<~SQL)
DELETE FROM site_settings WHERE name = 'watched_precedence_over_muted';
SQL
change_column_default :user_options, :watched_precedence_over_muted, from: nil, to: false
change_column_null :user_options, :watched_precedence_over_muted, false
end
def down