@ -13,8 +13,8 @@ module Mastodon
true
end
MIN_SUPPORTED_VERSION = 2019_10_01_213028 # rubocop:disable Style/NumericLiterals
MAX_SUPPORTED_VERSION = 2022_11_04_133904 # rubocop:disable Style/NumericLiterals
MIN_SUPPORTED_VERSION = 2019_10_01_213028
MAX_SUPPORTED_VERSION = 2022_11_04_133904
# Stubs to enjoy ActiveRecord queries while not depending on a particular
# version of the code/database
@ -209,7 +209,7 @@ module Mastodon
end
@prompt . say 'Restoring index_accounts_on_username_and_domain_lower…'
if ActiveRecord :: Migrator . current_version < 2020 0620164023 # 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
else
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
if ActiveRecord :: Migrator . current_version < 2022 0118183010 # 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 |
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 ( ', ' ) } "
@ -275,9 +275,9 @@ module Mastodon
@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 , [ '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 < 2022 0118183010
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 < 2022 0310060641 # 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
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
@ -340,7 +340,7 @@ module Mastodon
end
@prompt . say 'Restoring conversations indexes…'
if ActiveRecord :: Migrator . current_version < 2022 0307083603 # 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
else
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
@prompt . say 'Restoring media_attachments indexes…'
if ActiveRecord :: Migrator . current_version < 2022 0310060626 # 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
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
@ -490,7 +490,7 @@ module Mastodon
end
@prompt . say 'Restoring statuses indexes…'
if ActiveRecord :: Migrator . current_version < 2022 0310060706 # 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
else
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
@prompt . say 'Restoring tags indexes…'
if ActiveRecord :: Migrator . current_version < 2021 0421121431
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
else
ActiveRecord :: Base . connection . execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)'