Source code for the custom Mastodon (Glitchsoc) instance on berserker.town. https://berserker.town/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
892 B

# frozen_string_literal: true
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, '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