Always remove setting keys in legacy user settings migrations (#33196)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions

This commit is contained in:
Claire 2024-12-06 11:58:18 +01:00 committed by GitHub
parent 25387dc423
commit fbcd14ff7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View File

@ -8,6 +8,22 @@ class RemoveLegacyUserSettingsData < ActiveRecord::Migration[7.2]
thing_type IS NOT NULL
AND thing_id IS NOT NULL
SQL
# When running these migrations on mastodon.social, we saw 'notification_emails'
# and 'interactions' records that were not associated to a user and caused a
# migration issue.
# While I have not been able to pinpoint the exact cause of the issue, it is likely
# related to the settings system changes made in b11fdc3ae3f90731c01149a5a36dc64e065d4ea2.
# So, delete a few user settings that should already have been deleted.
connection.execute(<<~SQL.squish)
DELETE FROM settings
WHERE var IN (
'notification_emails', 'interactions', 'boost_modal', 'auto_play_gif',
'delete_modal', 'system_font_ui', 'default_sensitive', 'unfollow_modal',
'reduce_motion', 'display_sensitive_media', 'hide_network', 'expand_spoilers',
'display_media', 'aggregate_reblogs', 'show_application', 'advanced_layout',
'use_blurhash', 'use_pending_items')
SQL
end
def down

View File

@ -15,6 +15,22 @@ class RemoveLegacyUserSettingsColumns < ActiveRecord::Migration[7.2]
AND thing_id IS NOT NULL
SQL
# When running these migrations on mastodon.social, we saw 'notification_emails'
# and 'interactions' records that were not associated to a user and caused a
# migration issue.
# While I have not been able to pinpoint the exact cause of the issue, it is likely
# related to the settings system changes made in b11fdc3ae3f90731c01149a5a36dc64e065d4ea2.
# So, delete a few user settings that should already have been deleted.
connection.execute(<<~SQL.squish)
DELETE FROM settings
WHERE var IN (
'notification_emails', 'interactions', 'boost_modal', 'auto_play_gif',
'delete_modal', 'system_font_ui', 'default_sensitive', 'unfollow_modal',
'reduce_motion', 'display_sensitive_media', 'hide_network', 'expand_spoilers',
'display_media', 'aggregate_reblogs', 'show_application', 'advanced_layout',
'use_blurhash', 'use_pending_items')
SQL
add_index :settings, :var, unique: true, algorithm: :concurrently
remove_index :settings, [:thing_type, :thing_id, :var], name: :index_settings_on_thing_type_and_thing_id_and_var, unique: true