Add contacts table and model
What does this MR do?
In order for us to leverage GitLab as a CRM/service desk/many other activities we have just introduced the concept of "organizations" (aka companies/clients/customers - see !67551 (merged)).
Now we need to introduce the concept of "contacts" (clients/individuals).
This MR introduces the first iteration of the contacts
model / table
Screenshots or Screencasts (strongly suggested)
== 20210811120204 CreateCustomerRelationsContacts: migrating ==================
-- create_table(:customer_relations_contacts, {})
-- quote_column_name(:phone)
-> 0.0000s
-- quote_column_name(:first_name)
-> 0.0000s
-- quote_column_name(:last_name)
-> 0.0000s
-- quote_column_name(:email)
-> 0.0000s
-- quote_column_name(:description)
-> 0.0000s
-> 0.0066s
-- quote_table_name("check_f4b7f78c89")
-> 0.0000s
-- quote_table_name("check_1195f4c929")
-> 0.0000s
-- quote_table_name("check_cd2d67c484")
-> 0.0000s
-- quote_table_name("check_fc0adabf60")
-> 0.0000s
-- quote_table_name("check_40c70da037")
-> 0.0000s
-- quote_table_name(:customer_relations_contacts)
-> 0.0000s
-- execute("ALTER TABLE \"customer_relations_contacts\"\nADD CONSTRAINT \"check_f4b7f78c89\" CHECK (char_length(\"phone\") <= 32),\nADD CONSTRAINT \"check_1195f4c929\" CHECK (char_length(\"first_name\") <= 255),\nADD CONSTRAINT \"check_cd2d67c484\" CHECK (char_length(\"last_name\") <= 255),\nADD CONSTRAINT \"check_fc0adabf60\" CHECK (char_length(\"email\") <= 255),\nADD CONSTRAINT \"check_40c70da037\" CHECK (char_length(\"description\") <= 1024)\n")
-> 0.0040s
== 20210811120204 CreateCustomerRelationsContacts: migrated (0.0154s) =========
== 20210813131313 CreateIndexOnContactsGroupId: migrating =====================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:customer_relations_contacts, :group_id, {:name=>"index_customer_relations_contacts_on_group_id", :algorithm=>:concurrently})
-> 0.0020s
-- execute("SET statement_timeout TO 0")
-> 0.0006s
-- add_index(:customer_relations_contacts, :group_id, {:name=>"index_customer_relations_contacts_on_group_id", :algorithm=>:concurrently})
-> 0.0027s
-- execute("RESET statement_timeout")
-> 0.0006s
-- transaction_open?()
-> 0.0001s
-- foreign_keys(:customer_relations_contacts)
-> 0.0025s
-- execute("ALTER TABLE customer_relations_contacts\nADD CONSTRAINT fk_b91ddd9345\nFOREIGN KEY (group_id)\nREFERENCES namespaces (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0019s
-- execute("ALTER TABLE customer_relations_contacts VALIDATE CONSTRAINT fk_b91ddd9345;")
-> 0.0020s
== 20210813131313 CreateIndexOnContactsGroupId: migrated (0.0246s) ============
== 20210813131313 CreateIndexOnContactsGroupId: reverting =====================
-- foreign_keys(:customer_relations_contacts)
-> 0.0027s
-- remove_foreign_key(:customer_relations_contacts, {:column=>:group_id})
-> 0.0035s
-- transaction_open?()
-> 0.0000s
-- indexes(:customer_relations_contacts)
-> 0.0019s
-- execute("SET statement_timeout TO 0")
-> 0.0006s
-- remove_index(:customer_relations_contacts, {:algorithm=>:concurrently, :name=>"index_customer_relations_contacts_on_group_id"})
-> 0.0014s
-- execute("RESET statement_timeout")
-> 0.0005s
== 20210813131313 CreateIndexOnContactsGroupId: reverted (0.0167s) ============
== 20210811120204 CreateCustomerRelationsContacts: reverting ==================
-- drop_table(:customer_relations_contacts)
-> 0.0025s
== 20210811120204 CreateCustomerRelationsContacts: reverted (0.0081s) =========
How to setup and validate locally (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
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
Related to #2256
Edited by Lee Tickett