Add escalations table for issues
What does this MR do?
Related issue: #330277 (closed)
Adds a table for representing when issues should be escalated according to a project's escalation policy.
The structure of this table is meant to follow the one introduced for alerts in !64274 (merged) & modified in !65635 (merged).
Up migrations
% bin/rails db:migrate
== 20210730194555 CreateIncidentManagementPendingIssueEscalations: migrating ==
-- execute("CREATE TABLE incident_management_pending_issue_escalations (\n id bigint NOT NULL,\n rule_id bigint NOT NULL,\n issue_id bigint NOT NULL,\n process_at timestamp with time zone NOT NULL,\n created_at timestamp with time zone NOT NULL,\n updated_at timestamp with time zone NOT NULL,\n PRIMARY KEY (id, process_at)\n) PARTITION BY RANGE (process_at);\n\nCREATE INDEX index_incident_management_pending_issue_escalations_on_issue_id\n ON incident_management_pending_issue_escalations USING btree (issue_id);\n\nCREATE INDEX index_incident_management_pending_issue_escalations_on_rule_id\n ON incident_management_pending_issue_escalations USING btree (rule_id);\n")
-> 0.0043s
== 20210730194555 CreateIncidentManagementPendingIssueEscalations: migrated (0.0269s)
== 20210820171834 AddForeignKeysForPendingIssueEscalations: migrating =========
-- foreign_keys(:incident_management_pending_issue_escalations)
-> 0.0048s
-- add_foreign_key(:incident_management_pending_issue_escalations, :incident_management_escalation_rules, {:column=>:rule_id, :on_delete=>:cascade, :name=>"fk_rails_0470889ee5", :validate=>true})
-> 0.0106s
-- foreign_keys(:incident_management_pending_issue_escalations)
-> 0.0022s
-- add_foreign_key(:incident_management_pending_issue_escalations, :issues, {:column=>:issue_id, :on_delete=>:cascade, :name=>"fk_rails_636678b3bd", :validate=>true})
-> 0.0034s
== 20210820171834 AddForeignKeysForPendingIssueEscalations: migrated (0.0729s)
% gdk psql
\psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_pending_issue_escalations
Partitioned table "public.incident_management_pending_issue_escalations"
Column | Type | Collation | Nullable | Default
------------+--------------------------+-----------+----------+---------------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_pending_issue_escalations_id_seq'::regclass)
rule_id | bigint | | not null |
issue_id | bigint | | not null |
process_at | timestamp with time zone | | not null |
created_at | timestamp with time zone | | not null |
updated_at | timestamp with time zone | | not null |
Partition key: RANGE (process_at)
Indexes:
"incident_management_pending_issue_escalations_pkey" PRIMARY KEY, btree (id, process_at)
"index_incident_management_pending_issue_escalations_on_issue_id" btree (issue_id)
"index_incident_management_pending_issue_escalations_on_rule_id" btree (rule_id)
Foreign-key constraints:
"fk_rails_0470889ee5" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
"fk_rails_636678b3bd" FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE
Number of partitions: 8 (Use \d+ to list them.)
Down migrations
% bin/rails db:migrate:down VERSION=20210820171834
gdk psql
== 20210820171834 AddForeignKeysForPendingIssueEscalations: reverting =========
-- foreign_keys(:incident_management_pending_issue_escalations)
-> 0.0047s
-- remove_foreign_key(:incident_management_pending_issue_escalations, :incident_management_escalation_rules, {:column=>:rule_id})
-> 0.0105s
-- foreign_keys(:incident_management_pending_issue_escalations)
-> 0.0024s
-- remove_foreign_key(:incident_management_pending_issue_escalations, :issues, {:column=>:issue_id})
-> 0.0043s
== 20210820171834 AddForeignKeysForPendingIssueEscalations: reverted (0.0221s)
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_pending_issue_escalations
Partitioned table "public.incident_management_pending_issue_escalations"
Column | Type | Collation | Nullable | Default
------------+--------------------------+-----------+----------+---------------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_pending_issue_escalations_id_seq'::regclass)
rule_id | bigint | | not null |
issue_id | bigint | | not null |
process_at | timestamp with time zone | | not null |
created_at | timestamp with time zone | | not null |
updated_at | timestamp with time zone | | not null |
Partition key: RANGE (process_at)
Indexes:
"incident_management_pending_issue_escalations_pkey" PRIMARY KEY, btree (id, process_at)
"index_incident_management_pending_issue_escalations_on_issue_id" btree (issue_id)
"index_incident_management_pending_issue_escalations_on_rule_id" btree (rule_id)
Number of partitions: 8 (Use \d+ to list them.)
% bin/rails db:migrate:down VERSION=20210730194555
== 20210730194555 CreateIncidentManagementPendingIssueEscalations: reverting ==
-- drop_table(:incident_management_pending_issue_escalations)
-> 0.0062s
== 20210730194555 CreateIncidentManagementPendingIssueEscalations: reverted (0.0295s)
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_pending_issue_escalations
Did not find any relation named "incident_management_pending_issue_escalations".
Screenshots (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.
Related to #330277 (closed)
Edited by Mayra Cabrera