21 lines
669 B
Ruby
21 lines
669 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class AddGroupIdIndexAndFkToVulnerabilityExports < ActiveRecord::Migration[6.0]
|
||
|
include Gitlab::Database::MigrationHelpers
|
||
|
|
||
|
DOWNTIME = false
|
||
|
GROUP_ID_INDEX_NAME = 'index_vulnerability_exports_on_group_id_not_null'
|
||
|
|
||
|
disable_ddl_transaction!
|
||
|
|
||
|
def up
|
||
|
add_concurrent_index(:vulnerability_exports, :group_id, where: 'group_id IS NOT NULL', name: GROUP_ID_INDEX_NAME)
|
||
|
add_concurrent_foreign_key(:vulnerability_exports, :namespaces, column: :group_id)
|
||
|
end
|
||
|
|
||
|
def down
|
||
|
remove_foreign_key(:vulnerability_exports, column: :group_id)
|
||
|
remove_concurrent_index_by_name(:vulnerability_exports, GROUP_ID_INDEX_NAME)
|
||
|
end
|
||
|
end
|