debian-mirror-gitlab/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb

36 lines
967 B
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
2019-02-15 15:39:39 +05:30
class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration[4.2]
2018-03-17 18:26:18 +05:30
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
NEW_INDEX_NAME = 'idx_issues_on_project_id_and_due_date_and_id_and_state_partial'
OLD_INDEX_NAME = 'index_issues_on_project_id_and_due_date_and_id_and_state'
disable_ddl_transaction!
def up
add_concurrent_index(
:issues,
[:project_id, :due_date, :id, :state],
where: 'due_date IS NOT NULL',
name: NEW_INDEX_NAME
)
2018-11-08 19:23:39 +05:30
remove_concurrent_index_by_name(:issues, OLD_INDEX_NAME)
2018-03-17 18:26:18 +05:30
end
def down
add_concurrent_index(
:issues,
[:project_id, :due_date, :id, :state],
name: OLD_INDEX_NAME
)
2018-11-08 19:23:39 +05:30
remove_concurrent_index_by_name(:issues, NEW_INDEX_NAME)
2018-03-17 18:26:18 +05:30
end
end