Commit 7d8c3c4c authored by Vitali Tatarintev's avatar Vitali Tatarintev

Add incident_management_timeline_events table

Create `incident_management_timeline_events` table and required
foreign keys

Changelog: added
parent 010254c4
# frozen_string_literal: true
class CreateIncidentManagementTimelineEvents < Gitlab::Database::Migration[1.0]
def up
create_table :incident_management_timeline_events do |t|
t.timestamps_with_timezone null: false
t.datetime_with_timezone :occurred_at, null: false
t.bigint :project_id, null: false
t.bigint :author_id
t.bigint :issue_id, null: false
t.bigint :updated_by_user_id
t.bigint :promoted_from_note_id
t.integer :cached_markdown_version
t.boolean :editable, null: false, default: false
t.text :note, limit: 10_000, null: false
t.text :note_html, limit: 10_000, null: false
t.text :action, limit: 128, null: false
t.index :project_id, name: 'index_im_timeline_events_project_id'
t.index :author_id, name: 'index_im_timeline_events_author_id'
t.index :issue_id, name: 'index_im_timeline_events_issue_id'
t.index :updated_by_user_id, name: 'index_im_timeline_events_updated_by_user_id'
t.index :promoted_from_note_id, name: 'index_im_timeline_events_promoted_from_note_id'
end
end
def down
drop_table :incident_management_timeline_events
end
end
# frozen_string_literal: true
class AddForeignKeyToIncidentManagementTimelineEventsOnProject < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
add_concurrent_foreign_key :incident_management_timeline_events, :projects, column: :project_id, on_delete: :cascade
end
def down
with_lock_retries do
remove_foreign_key :incident_management_timeline_events, column: :project_id
end
end
end
# frozen_string_literal: true
class AddForeignKeyToIncidentManagementTimelineEventsOnUser < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
add_concurrent_foreign_key :incident_management_timeline_events, :users, column: :author_id, on_delete: :nullify
end
def down
with_lock_retries do
remove_foreign_key :incident_management_timeline_events, column: :author_id
end
end
end
# frozen_string_literal: true
class AddForeignKeyToIncidentManagementTimelineEventsOnIssue < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
add_concurrent_foreign_key :incident_management_timeline_events, :issues, column: :issue_id, on_delete: :cascade
end
def down
with_lock_retries do
remove_foreign_key :incident_management_timeline_events, column: :issue_id
end
end
end
# frozen_string_literal: true
class AddForeignKeyToIncidentManagementTimelineEventsOnUpdatedByUser < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
add_concurrent_foreign_key :incident_management_timeline_events, :users, column: :updated_by_user_id, on_delete: :nullify
end
def down
with_lock_retries do
remove_foreign_key :incident_management_timeline_events, column: :updated_by_user_id
end
end
end
# frozen_string_literal: true
class AddForeignKeyToIncidentManagementTimelineEventsOnNote < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
add_concurrent_foreign_key :incident_management_timeline_events, :notes, column: :promoted_from_note_id, on_delete: :nullify
end
def down
with_lock_retries do
remove_foreign_key :incident_management_timeline_events, column: :promoted_from_note_id
end
end
end
a9cc7d1fc3317958ecda959b62b42f93b2609c4e784566f9696fef51c5ebdf3b
\ No newline at end of file
52fd12693481ae7e08eb084ef679434592538d99117c1906f30ca6a36b12a212
\ No newline at end of file
cded37f94d578a503e5b389e6483ec68666983f71395c13b4f0011db04e807c3
\ No newline at end of file
63141e62fc21cf0a4b47355ecd3814c1f0cc829b7f4851d833f95369206c8919
\ No newline at end of file
39d1988fe409944877df24e9859b171eab13c4a4703c8e85a2bff33318fb61fc
\ No newline at end of file
f9bd521c92558ba9ad3cfa3fd6ff1a647847c0fc767e1e4f45b43422542d5cc7
\ No newline at end of file
......@@ -15079,6 +15079,35 @@ CREATE SEQUENCE incident_management_pending_issue_escalations_id_seq
ALTER SEQUENCE incident_management_pending_issue_escalations_id_seq OWNED BY incident_management_pending_issue_escalations.id;
CREATE TABLE incident_management_timeline_events (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
occurred_at timestamp with time zone NOT NULL,
project_id bigint NOT NULL,
author_id bigint,
issue_id bigint NOT NULL,
updated_by_user_id bigint,
promoted_from_note_id bigint,
cached_markdown_version integer,
editable boolean DEFAULT false NOT NULL,
note text NOT NULL,
note_html text NOT NULL,
action text NOT NULL,
CONSTRAINT check_18fd072206 CHECK ((char_length(action) <= 128)),
CONSTRAINT check_3875ed0aac CHECK ((char_length(note) <= 10000)),
CONSTRAINT check_94a235d6a4 CHECK ((char_length(note_html) <= 10000))
);
CREATE SEQUENCE incident_management_timeline_events_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE incident_management_timeline_events_id_seq OWNED BY incident_management_timeline_events.id;
CREATE TABLE index_statuses (
id integer NOT NULL,
project_id integer NOT NULL,
......@@ -21566,6 +21595,8 @@ ALTER TABLE ONLY incident_management_pending_alert_escalations ALTER COLUMN id S
ALTER TABLE ONLY incident_management_pending_issue_escalations ALTER COLUMN id SET DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass);
ALTER TABLE ONLY incident_management_timeline_events ALTER COLUMN id SET DEFAULT nextval('incident_management_timeline_events_id_seq'::regclass);
ALTER TABLE ONLY index_statuses ALTER COLUMN id SET DEFAULT nextval('index_statuses_id_seq'::regclass);
ALTER TABLE ONLY insights ALTER COLUMN id SET DEFAULT nextval('insights_id_seq'::regclass);
......@@ -23228,6 +23259,9 @@ ALTER TABLE ONLY incident_management_pending_alert_escalations
ALTER TABLE ONLY incident_management_pending_issue_escalations
ADD CONSTRAINT incident_management_pending_issue_escalations_pkey PRIMARY KEY (id, process_at);
ALTER TABLE ONLY incident_management_timeline_events
ADD CONSTRAINT incident_management_timeline_events_pkey PRIMARY KEY (id);
ALTER TABLE ONLY index_statuses
ADD CONSTRAINT index_statuses_pkey PRIMARY KEY (id);
......@@ -26091,6 +26125,16 @@ CREATE INDEX index_im_issuable_escalation_statuses_on_policy_id ON incident_mana
CREATE UNIQUE INDEX index_im_oncall_schedules_on_project_id_and_iid ON incident_management_oncall_schedules USING btree (project_id, iid);
CREATE INDEX index_im_timeline_events_author_id ON incident_management_timeline_events USING btree (author_id);
CREATE INDEX index_im_timeline_events_issue_id ON incident_management_timeline_events USING btree (issue_id);
CREATE INDEX index_im_timeline_events_project_id ON incident_management_timeline_events USING btree (project_id);
CREATE INDEX index_im_timeline_events_promoted_from_note_id ON incident_management_timeline_events USING btree (promoted_from_note_id);
CREATE INDEX index_im_timeline_events_updated_by_user_id ON incident_management_timeline_events USING btree (updated_by_user_id);
CREATE UNIQUE INDEX index_import_export_uploads_on_group_id ON import_export_uploads USING btree (group_id) WHERE (group_id IS NOT NULL);
CREATE INDEX index_import_export_uploads_on_project_id ON import_export_uploads USING btree (project_id);
......@@ -28822,6 +28866,12 @@ ALTER TABLE ONLY internal_ids
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_176d3fbb5d FOREIGN KEY (job_artifact_deleted_event_id) REFERENCES geo_job_artifact_deleted_events(id) ON DELETE CASCADE;
ALTER TABLE ONLY incident_management_timeline_events
ADD CONSTRAINT fk_17a5fafbd4 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
ALTER TABLE ONLY incident_management_timeline_events
ADD CONSTRAINT fk_1800597ef9 FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY project_features
ADD CONSTRAINT fk_18513d9b92 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
......@@ -28942,6 +28992,9 @@ ALTER TABLE ONLY sprints
ALTER TABLE ONLY push_event_payloads
ADD CONSTRAINT fk_36c74129da FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE;
ALTER TABLE ONLY incident_management_timeline_events
ADD CONSTRAINT fk_38a74279df FOREIGN KEY (updated_by_user_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY bulk_import_exports
ADD CONSTRAINT fk_39c726d3b5 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
......@@ -28969,6 +29022,9 @@ ALTER TABLE ONLY geo_event_log
ALTER TABLE ONLY remote_mirrors
ADD CONSTRAINT fk_43a9aa4ca8 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY incident_management_timeline_events
ADD CONSTRAINT fk_4432fc4d78 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_runner_projects
ADD CONSTRAINT fk_4478a6f1e4 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
......@@ -29452,6 +29508,9 @@ ALTER TABLE ONLY ci_sources_pipelines
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_d5af95fcd9 FOREIGN KEY (lfs_object_deleted_event_id) REFERENCES geo_lfs_object_deleted_events(id) ON DELETE CASCADE;
ALTER TABLE ONLY incident_management_timeline_events
ADD CONSTRAINT fk_d606a2a890 FOREIGN KEY (promoted_from_note_id) REFERENCES notes(id) ON DELETE SET NULL;
ALTER TABLE ONLY lists
ADD CONSTRAINT fk_d6cf4279f7 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
......@@ -250,6 +250,7 @@ incident_management_oncall_schedules: :gitlab_main
incident_management_oncall_shifts: :gitlab_main
incident_management_pending_alert_escalations: :gitlab_main
incident_management_pending_issue_escalations: :gitlab_main
incident_management_timeline_events: :gitlab_main
index_statuses: :gitlab_main
in_product_marketing_emails: :gitlab_main
insights: :gitlab_main
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment