diff options
Diffstat (limited to 'db/migrate/20200407121321_add_push_rule_foreign_key_to_groups.rb')
-rw-r--r-- | db/migrate/20200407121321_add_push_rule_foreign_key_to_groups.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/db/migrate/20200407121321_add_push_rule_foreign_key_to_groups.rb b/db/migrate/20200407121321_add_push_rule_foreign_key_to_groups.rb new file mode 100644 index 00000000000..acc74b43659 --- /dev/null +++ b/db/migrate/20200407121321_add_push_rule_foreign_key_to_groups.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddPushRuleForeignKeyToGroups < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + disable_ddl_transaction! + + def up + add_concurrent_index :namespaces, :push_rule_id, unique: true + add_concurrent_foreign_key :namespaces, :push_rules, column: :push_rule_id, on_delete: :nullify + end + + def down + remove_foreign_key_if_exists :namespaces, column: :push_rule_id + remove_concurrent_index :namespaces, :push_rule_id + end +end |