Merge remote-tracking branch 'parent/main' into upstream-20241209
This commit is contained in:
commit
6b6f145633
28 changed files with 571 additions and 324 deletions
|
@ -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
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddMissingDeleteCascadeWebauthnCredentials < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
ALTER TABLE webauthn_credentials
|
||||
DROP CONSTRAINT fk_rails_a4355aef77,
|
||||
ADD CONSTRAINT fk_rails_a4355aef77
|
||||
FOREIGN KEY (user_id)
|
||||
REFERENCES users(id)
|
||||
ON DELETE CASCADE
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
ALTER TABLE webauthn_credentials
|
||||
DROP CONSTRAINT fk_rails_a4355aef77,
|
||||
ADD CONSTRAINT fk_rails_a4355aef77
|
||||
FOREIGN KEY (user_id)
|
||||
REFERENCES users(id)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,45 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddMissingDeleteCascadeAccountModerationNotes < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
ALTER TABLE account_moderation_notes
|
||||
DROP CONSTRAINT fk_rails_3f8b75089b,
|
||||
ADD CONSTRAINT fk_rails_3f8b75089b
|
||||
FOREIGN KEY (account_id)
|
||||
REFERENCES accounts(id)
|
||||
ON DELETE CASCADE
|
||||
SQL
|
||||
|
||||
execute <<~SQL.squish
|
||||
ALTER TABLE account_moderation_notes
|
||||
DROP CONSTRAINT fk_rails_dd62ed5ac3,
|
||||
ADD CONSTRAINT fk_rails_dd62ed5ac3
|
||||
FOREIGN KEY (target_account_id)
|
||||
REFERENCES accounts(id)
|
||||
ON DELETE CASCADE
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
ALTER TABLE account_moderation_notes
|
||||
DROP CONSTRAINT fk_rails_3f8b75089b,
|
||||
ADD CONSTRAINT fk_rails_3f8b75089b
|
||||
FOREIGN KEY (account_id)
|
||||
REFERENCES accounts(id)
|
||||
SQL
|
||||
|
||||
execute <<~SQL.squish
|
||||
ALTER TABLE account_moderation_notes
|
||||
DROP CONSTRAINT fk_rails_dd62ed5ac3,
|
||||
ADD CONSTRAINT fk_rails_dd62ed5ac3
|
||||
FOREIGN KEY (target_account_id)
|
||||
REFERENCES accounts(id)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1606,8 +1606,8 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_08_232829) do
|
|||
add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
|
||||
add_foreign_key "account_migrations", "accounts", column: "target_account_id", on_delete: :nullify
|
||||
add_foreign_key "account_migrations", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_moderation_notes", "accounts"
|
||||
add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id"
|
||||
add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
add_foreign_key "account_moderation_notes", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_notes", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
add_foreign_key "account_notes", "accounts", on_delete: :cascade
|
||||
add_foreign_key "account_pins", "accounts", column: "target_account_id", on_delete: :cascade
|
||||
|
@ -1764,7 +1764,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_08_232829) do
|
|||
add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
|
||||
add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade
|
||||
add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
|
||||
add_foreign_key "webauthn_credentials", "users"
|
||||
add_foreign_key "webauthn_credentials", "users", on_delete: :cascade
|
||||
|
||||
create_view "instances", materialized: true, sql_definition: <<-SQL
|
||||
WITH domain_counts(domain, accounts_count) AS (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue