Skip to content

Change constraint on foreign key from cascade to nullify

Gosia Ksionek requested to merge recreate_foreign_key_with_nullify into master

What does this MR do?

I think I got one thing wrong while coding this. This MR fixes it.

Screenshots

up

== 20200417075843 RemoveAndAddForeignKeyToProjectSettings: migrating ==========
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:project_settings)
   -> 0.0029s
-- execute("ALTER TABLE project_settings\nADD CONSTRAINT fk_project_settings_push_rule_id\nFOREIGN KEY (push_rule_id)\nREFERENCES push_rules (id)\nON DELETE SET NULL\nNOT VALID;\n")
   -> 0.0034s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- execute("ALTER TABLE project_settings VALIDATE CONSTRAINT fk_project_settings_push_rule_id;")
   -> 0.0014s
-- execute("RESET ALL")
   -> 0.0002s
-- foreign_keys(:project_settings)
   -> 0.0020s
-- remove_foreign_key(:project_settings, {:column=>:push_rule_id, :on_delete=>:cascade})
   -> 0.0028s
== 20200417075843 RemoveAndAddForeignKeyToProjectSettings: migrated (0.0219s) =

down:

== 20200417075843 RemoveAndAddForeignKeyToProjectSettings: reverting ==========
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:project_settings)
   -> 0.0034s
-- execute("ALTER TABLE project_settings\nADD CONSTRAINT fk_413a953e20\nFOREIGN KEY (push_rule_id)\nREFERENCES push_rules (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0025s
-- execute("SET statement_timeout TO 0")
   -> 0.0002s
-- execute("ALTER TABLE project_settings VALIDATE CONSTRAINT fk_413a953e20;")
   -> 0.0013s
-- execute("RESET ALL")
   -> 0.0002s
-- foreign_keys(:project_settings)
   -> 0.0022s
-- remove_foreign_key(:project_settings, {:column=>:push_rule_id, :name=>"fk_project_settings_push_rule_id", :on_delete=>:nullify})
   -> 0.0032s
== 20200417075843 RemoveAndAddForeignKeyToProjectSettings: reverted (0.0209s) =

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Yorick Peterse

Merge request reports