This repository has been archived on 2024-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
2021-06-02 13:15:17 -04:00
|
|
|
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
|
|
|
|
2021-04-25 00:33:28 -04:00
|
|
|
class AddCaseInsensitiveBtreeIndexToTags < ActiveRecord::Migration[5.2]
|
2021-06-02 13:15:17 -04:00
|
|
|
include Mastodon::MigrationHelpers
|
|
|
|
|
2021-04-25 00:33:28 -04:00
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
def up
|
2021-06-02 13:15:17 -04:00
|
|
|
begin
|
|
|
|
safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)' }
|
|
|
|
rescue ActiveRecord::StatementInvalid => e
|
|
|
|
remove_index :tags, name: 'index_tags_on_name_lower_btree'
|
2023-02-17 08:47:23 -05:00
|
|
|
raise CorruptionError, 'index_tags_on_name_lower_btree' if e.is_a?(ActiveRecord::RecordNotUnique)
|
2023-02-20 00:58:28 -05:00
|
|
|
|
2021-06-02 13:15:17 -04:00
|
|
|
raise e
|
|
|
|
end
|
|
|
|
|
2021-04-25 00:33:28 -04:00
|
|
|
remove_index :tags, name: 'index_tags_on_name_lower'
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower ON tags (lower(name))' }
|
|
|
|
remove_index :tags, name: 'index_tags_on_name_lower_btree'
|
|
|
|
end
|
|
|
|
end
|