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.

24 lines
826 B

  1. require Rails.root.join('lib', 'mastodon', 'migration_helpers')
  2. class AddCaseInsensitiveBtreeIndexToTags < ActiveRecord::Migration[5.2]
  3. include Mastodon::MigrationHelpers
  4. disable_ddl_transaction!
  5. def up
  6. begin
  7. safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)' }
  8. rescue ActiveRecord::StatementInvalid => e
  9. remove_index :tags, name: 'index_tags_on_name_lower_btree'
  10. raise CorruptionError if e.is_a?(ActiveRecord::RecordNotUnique)
  11. raise e
  12. end
  13. remove_index :tags, name: 'index_tags_on_name_lower'
  14. end
  15. def down
  16. safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower ON tags (lower(name))' }
  17. remove_index :tags, name: 'index_tags_on_name_lower_btree'
  18. end
  19. end