Skip to content

Retain timelogs for deleted notes

Lee Tickett requested to merge retain-timelogs-for-deleted-notes into master

What does this MR do?

Changes the behaviour when deleting notes from: deleting related timelogs... to nullifying the note_id

Closes #245257 (closed)

Screenshots (strongly suggested)

lee@cc-gdk-2:~/gitlab-development-kit/gitlab$ bundle exec rake db:migrate:up VERSION=20210403022952 RAILS_ENV=development
== 20210403022952 RemoveNotesDeleteCascadeTimelogs: migrating =================
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:timelogs)
   -> 0.0029s
-- execute("ALTER TABLE timelogs\nADD CONSTRAINT fk_timelogs_note_id\nFOREIGN KEY (note_id)\nREFERENCES notes (id)\nON DELETE SET NULL\nNOT VALID;\n")
   -> 0.0013s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- execute("ALTER TABLE timelogs VALIDATE CONSTRAINT fk_timelogs_note_id;")
   -> 0.0015s
-- execute("RESET ALL")
   -> 0.0005s
-- foreign_keys(:timelogs)
   -> 0.0020s
-- remove_foreign_key(:timelogs, :notes, {:column=>:note_id, :on_delete=>:cascade})
   -> 0.0026s
== 20210403022952 RemoveNotesDeleteCascadeTimelogs: migrated (0.0197s) ========

lee@cc-gdk-2:~/gitlab-development-kit/gitlab$ bundle exec rake db:migrate:down VERSION=20210403022952 RAILS_ENV=development
== 20210403022952 RemoveNotesDeleteCascadeTimelogs: reverting =================
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:timelogs)
   -> 0.0025s
-- execute("ALTER TABLE timelogs\nADD CONSTRAINT fk_8d058cd571\nFOREIGN KEY (note_id)\nREFERENCES notes (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0010s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- execute("ALTER TABLE timelogs VALIDATE CONSTRAINT fk_8d058cd571;")
   -> 0.0015s
-- execute("RESET ALL")
   -> 0.0005s
-- foreign_keys(:timelogs)
   -> 0.0019s
-- remove_foreign_key(:timelogs, :notes, {:column=>:note_id, :on_delete=>:nullify, :name=>"fk_timelogs_note_id"})
   -> 0.0025s
== 20210403022952 RemoveNotesDeleteCascadeTimelogs: reverted (0.0197s) ========

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 Lee Tickett

Merge request reports