mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-27 02:24:03 -05:00
Move length value mapping to constant in ids to bigints migration (#29048)
This commit is contained in:
parent
4cf07ed78c
commit
dedefdc303
@ -7,10 +7,7 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||
include Mastodon::MigrationHelpers
|
||||
include Mastodon::MigrationWarning
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def migrate_columns(to_type)
|
||||
included_columns = [
|
||||
TABLE_COLUMN_MAPPING = [
|
||||
[:account_domain_blocks, :account_id],
|
||||
[:account_domain_blocks, :id],
|
||||
[:accounts, :id],
|
||||
@ -70,17 +67,13 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||
[:users, :id],
|
||||
[:web_settings, :id],
|
||||
[:web_settings, :user_id],
|
||||
]
|
||||
included_columns << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
|
||||
].freeze
|
||||
|
||||
migration_duration_warning(<<~EXPLANATION)
|
||||
This migration has some sections that can be safely interrupted
|
||||
and restarted later, and will tell you when those are occurring.
|
||||
disable_ddl_transaction!
|
||||
|
||||
For more information, see https://github.com/mastodon/mastodon/pull/5088
|
||||
EXPLANATION
|
||||
def migrate_columns(to_type)
|
||||
display_warning
|
||||
|
||||
tables = included_columns.map(&:first).uniq
|
||||
table_sizes = {}
|
||||
|
||||
# Sort tables by their size
|
||||
@ -103,6 +96,25 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
||||
end
|
||||
end
|
||||
|
||||
def display_warning
|
||||
migration_duration_warning(<<~EXPLANATION)
|
||||
This migration has some sections that can be safely interrupted
|
||||
and restarted later, and will tell you when those are occurring.
|
||||
|
||||
For more information, see https://github.com/mastodon/mastodon/pull/5088
|
||||
EXPLANATION
|
||||
end
|
||||
|
||||
def tables
|
||||
included_columns.map(&:first).uniq
|
||||
end
|
||||
|
||||
def included_columns
|
||||
TABLE_COLUMN_MAPPING.dup.tap do |included_columns|
|
||||
included_columns << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
|
||||
end
|
||||
end
|
||||
|
||||
def up
|
||||
migrate_columns(:bigint)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user