Draft: Prevent auto-delete of epic children
What does this MR do?
When deleting an epic, the children automatically get destroyed as well due to ON DELETE CASCADE
in the foreign key. This MR changes that value to SET NULL
. See https://gitlab.slack.com/archives/C72HPNV97/p1614717313122300 (internal) for context.
It also changes the UX warning so the user is clear about the consequences of deleting the epic.
!55574 (merged) should be merged first as it's the "smallest first iteration"
related to #321752 (closed)
Screenshots (strongly suggested)
before
after
Database migration outputs
up
$ bundle exec rake db:migrate:up VERSION=20210302222539
== 20210302222539 ChangeEpicParentForeignKeyCascadeSetNull: migrating =========
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:epics)
-> 0.0022s
-- execute("ALTER TABLE epics\nADD CONSTRAINT epics_parent_fk_nullify_on_destroy\nFOREIGN KEY (parent_id)\nREFERENCES epics (id)\nON DELETE SET NULL\nNOT VALID;\n")
-> 0.0129s
-- execute("SET statement_timeout TO 0")
-> 0.0014s
-- execute("ALTER TABLE epics VALIDATE CONSTRAINT epics_parent_fk_nullify_on_destroy;")
-> 0.0065s
-- execute("RESET ALL")
-> 0.0004s
-- remove_foreign_key(:epics, {:column=>:parent_id})
-> 0.0039s
== 20210302222539 ChangeEpicParentForeignKeyCascadeSetNull: migrated (0.0364s)
down
$ bundle exec rake db:migrate:down VERSION=20210302222539
== 20210302222539 ChangeEpicParentForeignKeyCascadeSetNull: reverting =========
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:epics)
-> 0.0022s
-- execute("ALTER TABLE epics\nADD CONSTRAINT fk_25b99c1be3\nFOREIGN KEY (parent_id)\nREFERENCES epics (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0010s
-- execute("SET statement_timeout TO 0")
-> 0.0005s
-- execute("ALTER TABLE epics VALIDATE CONSTRAINT fk_25b99c1be3;")
-> 0.0025s
-- execute("RESET ALL")
-> 0.0004s
-- remove_foreign_key(:epics, {:column=>:parent_id})
-> 0.0033s
== 20210302222539 ChangeEpicParentForeignKeyCascadeSetNull: reverted (0.0144s)
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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 charlie ablett