Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3f6597a9
Commit
3f6597a9
authored
Sep 22, 2021
by
Lee Tickett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add issue_customer_relations_contacts linking table
Changelog: added
parent
f8b652b9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
73 additions
and
0 deletions
+73
-0
app/models/customer_relations/contact.rb
app/models/customer_relations/contact.rb
+1
-0
app/models/issue.rb
app/models/issue.rb
+1
-0
db/migrate/20210922215740_create_issue_customer_relations_contacts.rb
...0210922215740_create_issue_customer_relations_contacts.rb
+14
-0
db/migrate/20210922220104_add_issue_customer_relations_contacts_foreign_keys.rb
...104_add_issue_customer_relations_contacts_foreign_keys.rb
+20
-0
db/schema_migrations/20210922215740
db/schema_migrations/20210922215740
+1
-0
db/schema_migrations/20210922220104
db/schema_migrations/20210922220104
+1
-0
db/structure.sql
db/structure.sql
+32
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
spec/models/customer_relations/contact_spec.rb
spec/models/customer_relations/contact_spec.rb
+1
-0
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+1
-0
No files found.
app/models/customer_relations/contact.rb
View file @
3f6597a9
...
...
@@ -7,6 +7,7 @@ class CustomerRelations::Contact < ApplicationRecord
belongs_to
:group
,
->
{
where
(
type:
Group
.
sti_name
)
},
foreign_key:
'group_id'
belongs_to
:organization
,
optional:
true
has_and_belongs_to_many
:issues
,
join_table: :issue_customer_relations_contacts
# rubocop: disable Rails/HasAndBelongsToMany
strip_attributes!
:phone
,
:first_name
,
:last_name
...
...
app/models/issue.rb
View file @
3f6597a9
...
...
@@ -81,6 +81,7 @@ class Issue < ApplicationRecord
has_and_belongs_to_many
:self_managed_prometheus_alert_events
,
join_table: :issues_self_managed_prometheus_alert_events
# rubocop: disable Rails/HasAndBelongsToMany
has_and_belongs_to_many
:prometheus_alert_events
,
join_table: :issues_prometheus_alert_events
# rubocop: disable Rails/HasAndBelongsToMany
has_many
:prometheus_alerts
,
through: :prometheus_alert_events
has_and_belongs_to_many
:customer_relations_contacts
,
join_table: :issue_customer_relations_contacts
,
class_name:
'CustomerRelations::Contact'
# rubocop: disable Rails/HasAndBelongsToMany
accepts_nested_attributes_for
:issuable_severity
,
update_only:
true
accepts_nested_attributes_for
:sentry_issue
...
...
db/migrate/20210922215740_create_issue_customer_relations_contacts.rb
0 → 100644
View file @
3f6597a9
# frozen_string_literal: true
class
CreateIssueCustomerRelationsContacts
<
Gitlab
::
Database
::
Migration
[
1.0
]
def
change
create_table
:issue_customer_relations_contacts
do
|
t
|
t
.
bigint
:issue_id
,
null:
false
t
.
bigint
:contact_id
,
null:
false
t
.
timestamps_with_timezone
null:
false
t
.
index
:contact_id
t
.
index
[
:issue_id
,
:contact_id
],
unique:
true
,
name: :index_issue_crm_contacts_on_issue_id_and_contact_id
end
end
end
db/migrate/20210922220104_add_issue_customer_relations_contacts_foreign_keys.rb
0 → 100644
View file @
3f6597a9
# frozen_string_literal: true
class
AddIssueCustomerRelationsContactsForeignKeys
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
def
up
add_concurrent_foreign_key
:issue_customer_relations_contacts
,
:issues
,
column: :issue_id
add_concurrent_foreign_key
:issue_customer_relations_contacts
,
:customer_relations_contacts
,
column: :contact_id
end
def
down
with_lock_retries
do
remove_foreign_key_if_exists
:issue_customer_relations_contacts
,
column: :issue_id
end
with_lock_retries
do
remove_foreign_key_if_exists
:issue_customer_relations_contacts
,
column: :contact_id
end
end
end
db/schema_migrations/20210922215740
0 → 100644
View file @
3f6597a9
7b343a5e1fd2600585d8fe4ef7585f91fb4c72da329b6f9474384f7217381d12
\ No newline at end of file
db/schema_migrations/20210922220104
0 → 100644
View file @
3f6597a9
ced8a8373bdbf07b2be23701f243f3a9f338776eeaec0a6c4e5cc0e68572a16e
\ No newline at end of file
db/structure.sql
View file @
3f6597a9
...
...
@@ -15077,6 +15077,23 @@ CREATE TABLE issue_assignees (
issue_id integer NOT NULL
);
CREATE TABLE issue_customer_relations_contacts (
id bigint NOT NULL,
issue_id bigint NOT NULL,
contact_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL
);
CREATE SEQUENCE issue_customer_relations_contacts_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE issue_customer_relations_contacts_id_seq OWNED BY issue_customer_relations_contacts.id;
CREATE TABLE issue_email_participants (
id bigint NOT NULL,
issue_id bigint NOT NULL,
...
...
@@ -21338,6 +21355,8 @@ ALTER TABLE ONLY issuable_severities ALTER COLUMN id SET DEFAULT nextval('issuab
ALTER TABLE ONLY issuable_slas ALTER COLUMN id SET DEFAULT nextval('issuable_slas_id_seq'::regclass);
ALTER TABLE ONLY issue_customer_relations_contacts ALTER COLUMN id SET DEFAULT nextval('issue_customer_relations_contacts_id_seq'::regclass);
ALTER TABLE ONLY issue_email_participants ALTER COLUMN id SET DEFAULT nextval('issue_email_participants_id_seq'::regclass);
ALTER TABLE ONLY issue_links ALTER COLUMN id SET DEFAULT nextval('issue_links_id_seq'::regclass);
...
...
@@ -22991,6 +23010,9 @@ ALTER TABLE ONLY issuable_slas
ALTER TABLE ONLY issue_assignees
ADD CONSTRAINT issue_assignees_pkey PRIMARY KEY (issue_id, user_id);
ALTER TABLE ONLY issue_customer_relations_contacts
ADD CONSTRAINT issue_customer_relations_contacts_pkey PRIMARY KEY (id);
ALTER TABLE ONLY issue_email_participants
ADD CONSTRAINT issue_email_participants_pkey PRIMARY KEY (id);
...
...
@@ -25351,6 +25373,10 @@ CREATE UNIQUE INDEX index_issuable_slas_on_issue_id ON issuable_slas USING btree
CREATE INDEX index_issue_assignees_on_user_id ON issue_assignees USING btree (user_id);
CREATE UNIQUE INDEX index_issue_crm_contacts_on_issue_id_and_contact_id ON issue_customer_relations_contacts USING btree (issue_id, contact_id);
CREATE INDEX index_issue_customer_relations_contacts_on_contact_id ON issue_customer_relations_contacts USING btree (contact_id);
CREATE UNIQUE INDEX index_issue_email_participants_on_issue_id_and_lower_email ON issue_email_participants USING btree (issue_id, lower(email));
CREATE INDEX index_issue_links_on_source_id ON issue_links USING btree (source_id);
...
...
@@ -27394,6 +27420,9 @@ ALTER TABLE ONLY user_interacted_projects
ALTER TABLE ONLY dast_sites
ADD CONSTRAINT fk_0a57f2271b FOREIGN KEY (dast_site_validation_id) REFERENCES dast_site_validations(id) ON DELETE SET NULL;
ALTER TABLE ONLY issue_customer_relations_contacts
ADD CONSTRAINT fk_0c0037f723 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
ALTER TABLE ONLY web_hooks
ADD CONSTRAINT fk_0c8ca6d9d1 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
...
...
@@ -27706,6 +27735,9 @@ ALTER TABLE ONLY protected_branches
ALTER TABLE ONLY vulnerabilities
ADD CONSTRAINT fk_7ac31eacb9 FOREIGN KEY (updated_by_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY issue_customer_relations_contacts
ADD CONSTRAINT fk_7b92f835bb FOREIGN KEY (contact_id) REFERENCES customer_relations_contacts(id) ON DELETE CASCADE;
ALTER TABLE ONLY vulnerabilities
ADD CONSTRAINT fk_7c5bb22a22 FOREIGN KEY (due_date_sourcing_milestone_id) REFERENCES milestones(id) ON DELETE SET NULL;
spec/lib/gitlab/import_export/all_models.yml
View file @
3f6597a9
...
...
@@ -59,6 +59,7 @@ issues:
-
requirement
-
incident_management_issuable_escalation_status
-
pending_escalations
-
customer_relations_contacts
work_item_type
:
-
issues
events
:
...
...
spec/models/customer_relations/contact_spec.rb
View file @
3f6597a9
...
...
@@ -6,6 +6,7 @@ RSpec.describe CustomerRelations::Contact, type: :model do
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:group
)
}
it
{
is_expected
.
to
belong_to
(
:organization
).
optional
}
it
{
is_expected
.
to
have_and_belong_to_many
(
:issues
)
}
end
describe
'validations'
do
...
...
spec/models/issue_spec.rb
View file @
3f6597a9
...
...
@@ -34,6 +34,7 @@ RSpec.describe Issue do
it
{
is_expected
.
to
have_many
(
:issue_email_participants
)
}
it
{
is_expected
.
to
have_many
(
:timelogs
).
autosave
(
true
)
}
it
{
is_expected
.
to
have_one
(
:incident_management_issuable_escalation_status
)
}
it
{
is_expected
.
to
have_and_belong_to_many
(
:customer_relations_contacts
)
}
describe
'versions.most_recent'
do
it
'returns the most recent version'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment