debian-mirror-gitlab/db/migrate/20210121121102_optional_devops_adoption_segment_name.rb

25 lines
740 B
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
class OptionalDevopsAdoptionSegmentName < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = 'index_analytics_devops_adoption_segments_on_name'
def up
change_column_null :analytics_devops_adoption_segments, :name, true
remove_concurrent_index_by_name :analytics_devops_adoption_segments, INDEX_NAME
end
def down
transaction do
execute "DELETE FROM analytics_devops_adoption_segments WHERE name IS NULL"
change_column_null :analytics_devops_adoption_segments, :name, false
end
add_concurrent_index :analytics_devops_adoption_segments, :name, unique: true, name: INDEX_NAME
end
end