debian-mirror-gitlab/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb
2019-02-15 15:39:39 +05:30

29 lines
1 KiB
Ruby

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class RemoveTemporaryCiBuildsIndex < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# To use create/remove index concurrently
disable_ddl_transaction!
def up
return unless index_exists?(:ci_builds, :id, name: 'index_for_ci_builds_retried_migration')
remove_concurrent_index(:ci_builds, :id, name: "index_for_ci_builds_retried_migration")
end
def down
# this was a temporary index for a migration that was never
# present previously so this probably shouldn't be here but it's
# easier to test the drop if we have a way to create it.
add_concurrent_index("ci_builds", ["id"],
name: "index_for_ci_builds_retried_migration",
where: "(retried IS NULL)",
using: :btree)
end
end