Allow user to be assigned to escalation rule
What does this MR do?
Adds support for notifying a user directly via an escalation rule.
- Issue: #330648 (comment 623415083)
- Dependent on: !65635 (merged)
- FE: !64844 (merged)
- Replaces approach in: !65208 (closed)
Database changes
Before & after all migrations
Before
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | not null |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_on_policy_schedule_status_elapsed_time_escalation_rules" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
After
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
user_id | bigint | | |
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_escalation_rules_on_all_attributes" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds, user_id)
"index_escalation_rules_on_user" btree (user_id)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Check constraints:
"escalation_rules_one_of_oncall_schedule_or_user" CHECK (num_nonnulls(oncall_schedule_id, user_id) = 1)
Foreign-key constraints:
"fk_0314ee86eb" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
After rollback
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | not null |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_on_policy_schedule_status_elapsed_time_escalation_rules" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
20210722074220: RemoveNullConstraintOnScheduleFromEscalationRules
Up
% bin/rails db:migrate VERSION=20210722074220
== 20210722074220 RemoveNullConstraintOnScheduleFromEscalationRules: migrating
-- change_column_null(:incident_management_escalation_rules, :oncall_schedule_id, true)
-> 0.0019s
== 20210722074220 RemoveNullConstraintOnScheduleFromEscalationRules: migrated (0.0020s)
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_on_policy_schedule_status_elapsed_time_escalation_rules" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
Down
% bin/rails db:migrate:down VERSION=20210722074220
== 20210722074220 RemoveNullConstraintOnScheduleFromEscalationRules: reverting
-- exec_query("DELETE FROM incident_management_escalation_rules WHERE oncall_schedule_id IS NULL")
-> 0.0026s
-- change_column_null(:incident_management_escalation_rules, :oncall_schedule_id, false)
-> 0.0012s
== 20210722074220 RemoveNullConstraintOnScheduleFromEscalationRules: reverted (0.0039s)
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | not null |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_on_policy_schedule_status_elapsed_time_escalation_rules" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
20210722074242: AddUserToEscalationRules
Up
% bin/rails db:migrate VERSION=20210722074242
== 20210722074242 AddUserToEscalationRules: migrating =========================
-- add_column(:incident_management_escalation_rules, :user_id, :bigint, {:null=>true})
-> 0.0012s
== 20210722074242 AddUserToEscalationRules: migrated (0.0090s) ================
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
user_id | bigint | | |
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_on_policy_schedule_status_elapsed_time_escalation_rules" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
Down
% bin/rails db:migrate:down VERSION=20210722074242
== 20210722074242 AddUserToEscalationRules: reverting =========================
-- remove_column(:incident_management_escalation_rules, :user_id)
-> 0.0012s
== 20210722074242 AddUserToEscalationRules: reverted (0.0085s) ================
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_on_policy_schedule_status_elapsed_time_escalation_rules" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
20210722074256: AddUserIndexToEscalationRules
Up
% bin/rails db:migrate VERSION=20210722074256
== 20210722074256 AddUserIndexToEscalationRules: migrating ====================
-- transaction_open?()
-> 0.0000s
-- indexes(:incident_management_escalation_rules)
-> 0.0041s
-- execute("SET statement_timeout TO 0")
-> 0.0005s
-- remove_index(:incident_management_escalation_rules, {:algorithm=>:concurrently, :name=>"index_on_policy_schedule_status_elapsed_time_escalation_rules"})
-> 0.0043s
-- execute("RESET ALL")
-> 0.0006s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:incident_management_escalation_rules, :user_id, {:name=>"index_escalation_rules_on_user", :algorithm=>:concurrently})
-> 0.0014s
-- add_index(:incident_management_escalation_rules, :user_id, {:name=>"index_escalation_rules_on_user", :algorithm=>:concurrently})
-> 0.0034s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:incident_management_escalation_rules, [:policy_id, :oncall_schedule_id, :status, :elapsed_time_seconds, :user_id], {:unique=>true, :name=>"index_escalation_rules_on_all_attributes", :algorithm=>:concurrently})
-> 0.0016s
-- add_index(:incident_management_escalation_rules, [:policy_id, :oncall_schedule_id, :status, :elapsed_time_seconds, :user_id], {:unique=>true, :name=>"index_escalation_rules_on_all_attributes", :algorithm=>:concurrently})
-> 0.0031s
== 20210722074256 AddUserIndexToEscalationRules: migrated (0.0215s) ===========
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
user_id | bigint | | |
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_escalation_rules_on_all_attributes" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds, user_id)
"index_escalation_rules_on_user" btree (user_id)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
Down
% bin/rails db:migrate:down VERSION=20210722074256
== 20210722074256 AddUserIndexToEscalationRules: reverting ====================
-- transaction_open?()
-> 0.0000s
-- indexes(:incident_management_escalation_rules)
-> 0.0031s
-- execute("SET statement_timeout TO 0")
-> 0.0005s
-- remove_index(:incident_management_escalation_rules, {:algorithm=>:concurrently, :name=>"index_escalation_rules_on_user"})
-> 0.0038s
-- execute("RESET ALL")
-> 0.0005s
-- transaction_open?()
-> 0.0000s
-- indexes(:incident_management_escalation_rules)
-> 0.0015s
-- remove_index(:incident_management_escalation_rules, {:algorithm=>:concurrently, :name=>"index_escalation_rules_on_all_attributes"})
-> 0.0028s
-- exec_query("DELETE FROM incident_management_escalation_rules WHERE oncall_schedule_id IS NULL")
-> 0.0011s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:incident_management_escalation_rules, [:policy_id, :oncall_schedule_id, :status, :elapsed_time_seconds], {:unique=>true, :name=>"index_on_policy_schedule_status_elapsed_time_escalation_rules", :algorithm=>:concurrently})
-> 0.0011s
-- add_index(:incident_management_escalation_rules, [:policy_id, :oncall_schedule_id, :status, :elapsed_time_seconds], {:unique=>true, :name=>"index_on_policy_schedule_status_elapsed_time_escalation_rules", :algorithm=>:concurrently})
-> 0.0041s
== 20210722074256 AddUserIndexToEscalationRules: reverted (0.0208s) ===========
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
user_id | bigint | | |
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_on_policy_schedule_status_elapsed_time_escalation_rules" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
20210722074309: AddUserFkToEscalationRules
Up
% bin/rails db:migrate VERSION=20210722074309
== 20210722074309 AddUserFkToEscalationRules: migrating =======================
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:incident_management_escalation_rules)
-> 0.0047s
-- execute("ALTER TABLE incident_management_escalation_rules\nADD CONSTRAINT fk_0314ee86eb\nFOREIGN KEY (user_id)\nREFERENCES users (id)\nON DELETE CASCADE\nNOT VALID;\n")
-> 0.0089s
-- execute("ALTER TABLE incident_management_escalation_rules VALIDATE CONSTRAINT fk_0314ee86eb;")
-> 0.0201s
== 20210722074309 AddUserFkToEscalationRules: migrated (0.0449s) ==============
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
user_id | bigint | | |
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_escalation_rules_on_all_attributes" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds, user_id)
"index_escalation_rules_on_user" btree (user_id)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_0314ee86eb" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
Down
% bin/rails db:migrate:down VERSION=20210722074309
== 20210722074309 AddUserFkToEscalationRules: reverting =======================
-- foreign_keys(:incident_management_escalation_rules)
-> 0.0035s
-- remove_foreign_key(:incident_management_escalation_rules, {:column=>:user_id})
-> 0.0035s
== 20210722074309 AddUserFkToEscalationRules: reverted (0.0142s) ==============
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
user_id | bigint | | |
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_escalation_rules_on_all_attributes" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds, user_id)
"index_escalation_rules_on_user" btree (user_id)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
20210722074339: AddXorCheckConstraintForEscalationRules
Up
% bin/rails db:migrate VERSION=20210722074339
== 20210722074339 AddXorCheckConstraintForEscalationRules: migrating ==========
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE incident_management_escalation_rules\nADD CONSTRAINT escalation_rules_one_of_oncall_schedule_or_user\nCHECK ( num_nonnulls(oncall_schedule_id, user_id) = 1 )\nNOT VALID;\n")
-> 0.0060s
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE incident_management_escalation_rules VALIDATE CONSTRAINT escalation_rules_one_of_oncall_schedule_or_user;")
-> 0.0015s
== 20210722074339 AddXorCheckConstraintForEscalationRules: migrated (0.0185s) =
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
user_id | bigint | | |
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_escalation_rules_on_all_attributes" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds, user_id)
"index_escalation_rules_on_user" btree (user_id)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Check constraints:
"escalation_rules_one_of_oncall_schedule_or_user" CHECK (num_nonnulls(oncall_schedule_id, user_id) = 1)
Foreign-key constraints:
"fk_0314ee86eb" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
Down
% bin/rails db:migrate:down VERSION=20210722074339
== 20210722074339 AddXorCheckConstraintForEscalationRules: reverting ==========
-- execute("ALTER TABLE incident_management_escalation_rules\nDROP CONSTRAINT IF EXISTS escalation_rules_one_of_oncall_schedule_or_user\n")
-> 0.0012s
== 20210722074339 AddXorCheckConstraintForEscalationRules: reverted (0.0090s) =
% gdk psql
psql (12.7)
Type "help" for help.
gitlabhq_development=# \d incident_management_escalation_rules
Table "public.incident_management_escalation_rules"
Column | Type | Collation | Nullable | Default
----------------------+----------+-----------+----------+------------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_escalation_rules_id_seq'::regclass)
policy_id | bigint | | not null |
oncall_schedule_id | bigint | | |
status | smallint | | not null |
elapsed_time_seconds | integer | | not null |
is_removed | boolean | | not null | false
user_id | bigint | | |
Indexes:
"incident_management_escalation_rules_pkey" PRIMARY KEY, btree (id)
"index_escalation_rules_on_all_attributes" UNIQUE, btree (policy_id, oncall_schedule_id, status, elapsed_time_seconds, user_id)
"index_escalation_rules_on_user" btree (user_id)
"index_on_oncall_schedule_escalation_rule" btree (oncall_schedule_id)
Foreign-key constraints:
"fk_0314ee86eb" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
"fk_rails_17dbea07a6" FOREIGN KEY (policy_id) REFERENCES incident_management_escalation_policies(id) ON DELETE CASCADE
"fk_rails_b3c9c17bd4" FOREIGN KEY (oncall_schedule_id) REFERENCES incident_management_oncall_schedules(id) ON DELETE CASCADE
Referenced by:
TABLE "incident_management_pending_alert_escalations" CONSTRAINT "fk_rails_f3d17bc8af" FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE
Screenshots or Screencasts (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
Edited by Sarah Yasonik