mirror of
https://github.com/mastodon/mastodon.git
synced 2024-10-20 08:36:10 +00:00
75e33fd08f
* Fix null values being included in some indexes * Update lib/mastodon/migration_helpers.rb Co-authored-by: Claire <claire.github-309c@sitedethib.com> * Add documentation link to corruption error message Co-authored-by: Claire <claire.github-309c@sitedethib.com>
25 lines
864 B
Ruby
25 lines
864 B
Ruby
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
|
|
|
class AddCaseInsensitiveBtreeIndexToTags < ActiveRecord::Migration[5.2]
|
|
include Mastodon::MigrationHelpers
|
|
|
|
disable_ddl_transaction!
|
|
|
|
def up
|
|
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'
|
|
raise CorruptionError.new('index_tags_on_name_lower_btree') if e.is_a?(ActiveRecord::RecordNotUnique)
|
|
raise e
|
|
end
|
|
|
|
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
|