2021-06-22 19:27:03 +08:00
|
|
|
# frozen_string_literal: true
|
2021-06-29 21:57:23 +08:00
|
|
|
require File.expand_path('app/helpers/database_helper')
|
|
|
|
include DatabaseHelper
|
2021-06-22 19:27:03 +08:00
|
|
|
|
2021-06-22 18:51:25 +08:00
|
|
|
class FixExperimentIndices < ActiveRecord::Migration[6.1]
|
|
|
|
def up
|
|
|
|
remove_index :experiments, name: 'index_experiments_on_name', column: 'name'
|
|
|
|
|
2021-06-29 21:57:23 +08:00
|
|
|
add_gin_index_without_tags(:experiments, :name)
|
|
|
|
add_gin_index_without_tags(:experiments, :description)
|
2021-06-22 18:51:25 +08:00
|
|
|
|
|
|
|
ActiveRecord::Base.connection.execute(
|
2021-06-29 21:57:23 +08:00
|
|
|
"CREATE INDEX index_experiments_on_experiment_code ON experiments using gin (('EX'::text || id) gin_trgm_ops);"
|
2021-06-22 18:51:25 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
2021-06-29 21:57:23 +08:00
|
|
|
remove_index :experiments, name: 'index_experiments_on_code'
|
|
|
|
remove_index :experiments, name: 'index_experiments_on_description', column: 'description'
|
|
|
|
remove_index :experiments, name: 'index_experiments_on_name', column: 'name'
|
2021-06-22 18:51:25 +08:00
|
|
|
|
|
|
|
add_index :experiments, :name
|
|
|
|
end
|
|
|
|
end
|