Create IncidentManagement::OncallShift table and model
What does this MR do?
- Related issue: #262860 (closed)
- Work breakdown: #262860 (comment 461899498)
Note: This MR targets the branch in !49206 (merged), but this is only for ease of review/dev. This should not be merged until the branch targets master
.
This MR adds a table/model used for tracking past and present on-call shifts. A user in the on-call rotation will have shifts covering a given time range.
Anticipated usage:
- viewing historical shifts in the UI (queried by rotation)
- viewing reports of on-call distribution (possibly queried by project, schedule, rotation, or user)
Up Migration
$ bin/rails db:migrate
== 20201208210209 CreateIncidentManagementOncallShifts: migrating =============
-- table_exists?(:incident_management_oncall_shifts)
-> 0.0007s
-- create_table(:incident_management_oncall_shifts)
-> 0.0091s
-- execute("ALTER TABLE incident_management_oncall_shifts\n ADD CONSTRAINT inc_mgmnt_no_overlapping_oncall_shifts\n EXCLUDE USING gist\n ( rotation_id WITH =,\n tstzrange(starts_at, ends_at, '[)') WITH &&\n )\n")
-> 0.0047s
== 20201208210209 CreateIncidentManagementOncallShifts: migrated (0.0233s) ====
$ bin/rails dbconsole
psql (11.9)
Type "help" for help.
gitlabhq_development=# \d incident_management_oncall_shifts
Table "public.incident_management_oncall_shifts"
Column | Type | Collation | Nullable | Default
----------------+--------------------------+-----------+----------+---------------------------------------------------------------
id | bigint | | not null | nextval('incident_management_oncall_shifts_id_seq'::regclass)
rotation_id | bigint | | not null |
participant_id | bigint | | not null |
starts_at | timestamp with time zone | | not null |
ends_at | timestamp with time zone | | not null |
Indexes:
"incident_management_oncall_shifts_pkey" PRIMARY KEY, btree (id)
"inc_mgmnt_no_overlapping_oncall_shifts" EXCLUDE USING gist (rotation_id WITH =, tstzrange(starts_at, ends_at, '[)'::text) WITH &&)
"index_incident_management_oncall_shifts_on_participant_id" btree (participant_id)
"index_incident_management_oncall_shifts_on_rotation_id" btree (rotation_id)
Foreign-key constraints:
"fk_rails_df4feb286a" FOREIGN KEY (rotation_id) REFERENCES incident_management_oncall_rotations(id) ON DELETE CASCADE
"fk_rails_f6eef06841" FOREIGN KEY (participant_id) REFERENCES incident_management_oncall_participants(id) ON DELETE CASCADE
Down Migration
$ bin/rails db:migrate:down VERSION=20201208210209
== 20201208210209 CreateIncidentManagementOncallShifts: reverting =============
-- drop_table(:incident_management_oncall_shifts)
-> 0.0026s
== 20201208210209 CreateIncidentManagementOncallShifts: reverted (0.0099s) ====
$ bin/rails dbconsole
psql (11.9)
Type "help" for help.
gitlabhq_development=# \d incident_management_oncall_shifts
Did not find any relation named "incident_management_oncall_shifts".
gitlabhq_development=# \q
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
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 #262860 (closed)
Edited by Sarah Yasonik