|
|
@ -13,8 +13,8 @@ module Mastodon
|
|
|
|
true
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
MIN_SUPPORTED_VERSION = 2019_10_01_213028 # rubocop:disable Style/NumericLiterals
|
|
|
|
MIN_SUPPORTED_VERSION = 2019_10_01_213028
|
|
|
|
MAX_SUPPORTED_VERSION = 2022_11_04_133904 # rubocop:disable Style/NumericLiterals
|
|
|
|
MAX_SUPPORTED_VERSION = 2022_11_04_133904
|
|
|
|
|
|
|
|
|
|
|
|
# Stubs to enjoy ActiveRecord queries while not depending on a particular
|
|
|
|
# Stubs to enjoy ActiveRecord queries while not depending on a particular
|
|
|
|
# version of the code/database
|
|
|
|
# version of the code/database
|
|
|
@ -209,7 +209,7 @@ module Mastodon
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@prompt.say 'Restoring index_accounts_on_username_and_domain_lower…'
|
|
|
|
@prompt.say 'Restoring index_accounts_on_username_and_domain_lower…'
|
|
|
|
if ActiveRecord::Migrator.current_version < 20200620164023 # rubocop:disable Style/NumericLiterals
|
|
|
|
if ActiveRecord::Migrator.current_version < 2020_06_20_164023
|
|
|
|
ActiveRecord::Base.connection.add_index :accounts, 'lower (username), lower(domain)', name: 'index_accounts_on_username_and_domain_lower', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :accounts, 'lower (username), lower(domain)', name: 'index_accounts_on_username_and_domain_lower', unique: true
|
|
|
|
else
|
|
|
|
else
|
|
|
|
ActiveRecord::Base.connection.add_index :accounts, "lower (username), COALESCE(lower(domain), '')", name: 'index_accounts_on_username_and_domain_lower', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :accounts, "lower (username), COALESCE(lower(domain), '')", name: 'index_accounts_on_username_and_domain_lower', unique: true
|
|
|
@ -252,7 +252,7 @@ module Mastodon
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if ActiveRecord::Migrator.current_version < 20220118183010 # rubocop:disable Style/NumericLiterals
|
|
|
|
if ActiveRecord::Migrator.current_version < 2022_01_18_183010
|
|
|
|
ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users WHERE remember_token IS NOT NULL GROUP BY remember_token HAVING count(*) > 1").each do |row|
|
|
|
|
ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users WHERE remember_token IS NOT NULL GROUP BY remember_token HAVING count(*) > 1").each do |row|
|
|
|
|
users = User.where(id: row['ids'].split(',')).sort_by(&:updated_at).reverse.drop(1)
|
|
|
|
users = User.where(id: row['ids'].split(',')).sort_by(&:updated_at).reverse.drop(1)
|
|
|
|
@prompt.warn "Unsetting remember token for those accounts: #{users.map(&:account).map(&:acct).join(', ')}"
|
|
|
|
@prompt.warn "Unsetting remember token for those accounts: #{users.map(&:account).map(&:acct).join(', ')}"
|
|
|
@ -275,9 +275,9 @@ module Mastodon
|
|
|
|
@prompt.say 'Restoring users indexes…'
|
|
|
|
@prompt.say 'Restoring users indexes…'
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['email'], name: 'index_users_on_email', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['email'], name: 'index_users_on_email', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['remember_token'], name: 'index_users_on_remember_token', unique: true if ActiveRecord::Migrator.current_version < 20220118183010
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['remember_token'], name: 'index_users_on_remember_token', unique: true if ActiveRecord::Migrator.current_version < 2022_01_18_183010
|
|
|
|
|
|
|
|
|
|
|
|
if ActiveRecord::Migrator.current_version < 20220310060641 # rubocop:disable Style/NumericLiterals
|
|
|
|
if ActiveRecord::Migrator.current_version < 2022_03_10_060641
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
|
|
|
|
else
|
|
|
|
else
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, where: 'reset_password_token IS NOT NULL', opclass: :text_pattern_ops
|
|
|
|
ActiveRecord::Base.connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, where: 'reset_password_token IS NOT NULL', opclass: :text_pattern_ops
|
|
|
@ -340,7 +340,7 @@ module Mastodon
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@prompt.say 'Restoring conversations indexes…'
|
|
|
|
@prompt.say 'Restoring conversations indexes…'
|
|
|
|
if ActiveRecord::Migrator.current_version < 20220307083603 # rubocop:disable Style/NumericLiterals
|
|
|
|
if ActiveRecord::Migrator.current_version < 2022_03_07_083603
|
|
|
|
ActiveRecord::Base.connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true
|
|
|
|
else
|
|
|
|
else
|
|
|
|
ActiveRecord::Base.connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops
|
|
|
|
ActiveRecord::Base.connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops
|
|
|
@ -457,7 +457,7 @@ module Mastodon
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@prompt.say 'Restoring media_attachments indexes…'
|
|
|
|
@prompt.say 'Restoring media_attachments indexes…'
|
|
|
|
if ActiveRecord::Migrator.current_version < 20220310060626 # rubocop:disable Style/NumericLiterals
|
|
|
|
if ActiveRecord::Migrator.current_version < 2022_03_10_060626
|
|
|
|
ActiveRecord::Base.connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true
|
|
|
|
else
|
|
|
|
else
|
|
|
|
ActiveRecord::Base.connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true, where: 'shortcode IS NOT NULL', opclass: :text_pattern_ops
|
|
|
|
ActiveRecord::Base.connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true, where: 'shortcode IS NOT NULL', opclass: :text_pattern_ops
|
|
|
@ -490,7 +490,7 @@ module Mastodon
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@prompt.say 'Restoring statuses indexes…'
|
|
|
|
@prompt.say 'Restoring statuses indexes…'
|
|
|
|
if ActiveRecord::Migrator.current_version < 20220310060706 # rubocop:disable Style/NumericLiterals
|
|
|
|
if ActiveRecord::Migrator.current_version < 2022_03_10_060706
|
|
|
|
ActiveRecord::Base.connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true
|
|
|
|
else
|
|
|
|
else
|
|
|
|
ActiveRecord::Base.connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops
|
|
|
|
ActiveRecord::Base.connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops
|
|
|
@ -512,7 +512,7 @@ module Mastodon
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@prompt.say 'Restoring tags indexes…'
|
|
|
|
@prompt.say 'Restoring tags indexes…'
|
|
|
|
if ActiveRecord::Migrator.current_version < 20210421121431
|
|
|
|
if ActiveRecord::Migrator.current_version < 2021_04_21_121431
|
|
|
|
ActiveRecord::Base.connection.add_index :tags, 'lower((name)::text)', name: 'index_tags_on_name_lower', unique: true
|
|
|
|
ActiveRecord::Base.connection.add_index :tags, 'lower((name)::text)', name: 'index_tags_on_name_lower', unique: true
|
|
|
|
else
|
|
|
|
else
|
|
|
|
ActiveRecord::Base.connection.execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)'
|
|
|
|
ActiveRecord::Base.connection.execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)'
|
|
|
|