Skip to content

Add issue_customer_relations_contacts linking table

Lee Tickett requested to merge 2256-add-issue-contacts into master

What does this MR do and why?

Now we have Organizations and Contacts and are making good progress with the GraphQL CRUD endpoints... we need a way to start using them.

This MR introduces a linking table and association between contacts and issues.

Screenshots or screen recordings

lee@cc-gdk-2:~/gitlab-development-kit/gitlab$ bundle exec rake db:migrate:up VERSION=20210922215740 RAILS_ENV=development
== 20210922215740 CreateIssueCustomerRelationsContacts: migrating =============
-- create_table(:issue_customer_relations_contacts, {})
   -> 0.0095s
== 20210922215740 CreateIssueCustomerRelationsContacts: migrated (0.0096s) ====

lee@cc-gdk-2:~/gitlab-development-kit/gitlab$ bundle exec rake db:migrate:up VERSION=20210922220104 RAILS_ENV=development
== 20210922220104 AddIssueCustomerRelationsContactsForeignKeys: migrating =====
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:issue_customer_relations_contacts)
   -> 0.0030s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE issue_customer_relations_contacts\nADD CONSTRAINT fk_0c0037f723\nFOREIGN KEY (issue_id)\nREFERENCES issues (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0018s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- execute("ALTER TABLE issue_customer_relations_contacts VALIDATE CONSTRAINT fk_0c0037f723;")
   -> 0.0024s
-- execute("RESET statement_timeout")
   -> 0.0006s
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:issue_customer_relations_contacts)
   -> 0.0022s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE issue_customer_relations_contacts\nADD CONSTRAINT fk_7b92f835bb\nFOREIGN KEY (contact_id)\nREFERENCES customer_relations_contacts (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0011s
-- execute("ALTER TABLE issue_customer_relations_contacts VALIDATE CONSTRAINT fk_7b92f835bb;")
   -> 0.0013s
== 20210922220104 AddIssueCustomerRelationsContactsForeignKeys: migrated (0.0278s)

lee@cc-gdk-2:~/gitlab-development-kit/gitlab$ bundle exec rake db:migrate:down VERSION=20210922220104 RAILS_ENV=development
== 20210922220104 AddIssueCustomerRelationsContactsForeignKeys: reverting =====
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:issue_customer_relations_contacts)
   -> 0.0030s
-- remove_foreign_key(:issue_customer_relations_contacts, {:column=>:issue_id})
   -> 0.0037s
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:issue_customer_relations_contacts)
   -> 0.0025s
-- remove_foreign_key(:issue_customer_relations_contacts, {:column=>:contact_id})
   -> 0.0032s
== 20210922220104 AddIssueCustomerRelationsContactsForeignKeys: reverted (0.0255s)

lee@cc-gdk-2:~/gitlab-development-kit/gitlab$ bundle exec rake db:migrate:down VERSION=20210922215740 RAILS_ENV=development
== 20210922215740 CreateIssueCustomerRelationsContacts: reverting =============
-- drop_table(:issue_customer_relations_contacts, {})
   -> 0.0030s
== 20210922215740 CreateIssueCustomerRelationsContacts: reverted (0.0060s) ====

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #2256

Edited by Lee Tickett

Merge request reports