diff options
Diffstat (limited to 'db/migrate/20201209154746_expand_ci_pipelines_index_on_ci_ref_id.rb')
-rw-r--r-- | db/migrate/20201209154746_expand_ci_pipelines_index_on_ci_ref_id.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/db/migrate/20201209154746_expand_ci_pipelines_index_on_ci_ref_id.rb b/db/migrate/20201209154746_expand_ci_pipelines_index_on_ci_ref_id.rb new file mode 100644 index 00000000000..b88763a30f9 --- /dev/null +++ b/db/migrate/20201209154746_expand_ci_pipelines_index_on_ci_ref_id.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class ExpandCiPipelinesIndexOnCiRefId < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + NEW_NAME = 'index_ci_pipelines_on_ci_ref_id_and_more' + OLD_NAME = 'index_ci_pipelines_on_ci_ref_id' + + def up + add_concurrent_index :ci_pipelines, %i[ci_ref_id id source status], order: { id: :desc }, where: 'ci_ref_id IS NOT NULL', name: NEW_NAME + + remove_concurrent_index_by_name :ci_pipelines, OLD_NAME + end + + def down + add_concurrent_index :ci_pipelines, :ci_ref_id, where: 'ci_ref_id IS NOT NULL', name: OLD_NAME + + remove_concurrent_index_by_name :ci_pipelines, NEW_NAME + end +end |