diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-17 18:12:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-17 18:12:33 +0300 |
commit | 4847ec0f5040b52509876b7df47cb7a304f7a89a (patch) | |
tree | f6344102fcf323bdea3ca802694c19f6a118bf61 /db | |
parent | 42deff0c17c1a34f716a299db79bb9c3788c265f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/docs/work_item_dates_sources.yml | 12 | ||||
-rw-r--r-- | db/migrate/20231207150738_add_work_item_dates_sources.rb | 32 | ||||
-rw-r--r-- | db/migrate/20231207150739_add_work_item_dates_sources_foreing_keys.rb | 28 | ||||
-rw-r--r-- | db/schema_migrations/20231207150738 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20231207150739 | 1 | ||||
-rw-r--r-- | db/structure.sql | 46 |
6 files changed, 120 insertions, 0 deletions
diff --git a/db/docs/work_item_dates_sources.yml b/db/docs/work_item_dates_sources.yml new file mode 100644 index 00000000000..f26dec2874c --- /dev/null +++ b/db/docs/work_item_dates_sources.yml @@ -0,0 +1,12 @@ +--- +table_name: work_item_dates_sources +classes: + - WorkItems::DatesSource +feature_categories: + - team_planning +description: The rolled up Start and Due dates for Work Items. +introduced_by_url: +milestone: '16.7' +gitlab_schema: gitlab_main_cell +sharding_key: + namespace_id: namespaces diff --git a/db/migrate/20231207150738_add_work_item_dates_sources.rb b/db/migrate/20231207150738_add_work_item_dates_sources.rb new file mode 100644 index 00000000000..a6cc06fcd88 --- /dev/null +++ b/db/migrate/20231207150738_add_work_item_dates_sources.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class AddWorkItemDatesSources < Gitlab::Database::Migration[2.2] + enable_lock_retries! + milestone '16.7' + + def up + create_table :work_item_dates_sources, id: false do |t| + t.timestamps_with_timezone null: false + t.references :issue, + primary_key: true, + index: false, + default: nil, + foreign_key: { on_delete: :cascade, to_table: :issues } + + t.bigint :namespace_id, null: false + + t.boolean :start_date_is_fixed, default: false, null: false + t.boolean :due_date_is_fixed, default: false, null: false + t.date :start_date, null: true + t.date :due_date, null: true + t.bigint :start_date_sourcing_work_item_id, null: true + t.bigint :start_date_sourcing_milestone_id, null: true + t.bigint :due_date_sourcing_work_item_id, null: true + t.bigint :due_date_sourcing_milestone_id, null: true + end + end + + def down + drop_table :work_item_dates_sources + end +end diff --git a/db/migrate/20231207150739_add_work_item_dates_sources_foreing_keys.rb b/db/migrate/20231207150739_add_work_item_dates_sources_foreing_keys.rb new file mode 100644 index 00000000000..89e592774d2 --- /dev/null +++ b/db/migrate/20231207150739_add_work_item_dates_sources_foreing_keys.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class AddWorkItemDatesSourcesForeingKeys < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.7' + + TABLE = :work_item_dates_sources + COLUMNS = { + namespace_id: :namespaces, + start_date_sourcing_work_item_id: :issues, + start_date_sourcing_milestone_id: :milestones, + due_date_sourcing_work_item_id: :issues, + due_date_sourcing_milestone_id: :milestones + }.freeze + + def up + COLUMNS.each do |column, target_table| + add_concurrent_foreign_key TABLE, target_table, column: column, on_delete: :nullify + add_concurrent_index TABLE, column, name: "wi_datessources_#{column}_index" + end + end + + def down + COLUMNS.each_key do |column| + remove_foreign_key_if_exists TABLE, :issues, column: column + end + end +end diff --git a/db/schema_migrations/20231207150738 b/db/schema_migrations/20231207150738 new file mode 100644 index 00000000000..500322aa2b9 --- /dev/null +++ b/db/schema_migrations/20231207150738 @@ -0,0 +1 @@ +7a8759a7a0d49f6d9fb5f455f99bcf3579ab1c9e7695d34828b86ea51255b126
\ No newline at end of file diff --git a/db/schema_migrations/20231207150739 b/db/schema_migrations/20231207150739 new file mode 100644 index 00000000000..6554b107d29 --- /dev/null +++ b/db/schema_migrations/20231207150739 @@ -0,0 +1 @@ +fd09d8c41086694dcf6279b259e54c5ee73d4f4ee0b01cc1a03ba1e10c228b80
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index d3d18beb466..f70816004b4 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -25526,6 +25526,21 @@ CREATE SEQUENCE wiki_repository_states_id_seq ALTER SEQUENCE wiki_repository_states_id_seq OWNED BY wiki_repository_states.id; +CREATE TABLE work_item_dates_sources ( + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + issue_id bigint NOT NULL, + namespace_id bigint NOT NULL, + start_date_is_fixed boolean DEFAULT false NOT NULL, + due_date_is_fixed boolean DEFAULT false NOT NULL, + start_date date, + due_date date, + start_date_sourcing_work_item_id bigint, + start_date_sourcing_milestone_id bigint, + due_date_sourcing_work_item_id bigint, + due_date_sourcing_milestone_id bigint +); + CREATE TABLE work_item_hierarchy_restrictions ( id bigint NOT NULL, parent_type_id bigint NOT NULL, @@ -30151,6 +30166,9 @@ ALTER TABLE ONLY wiki_page_slugs ALTER TABLE ONLY wiki_repository_states ADD CONSTRAINT wiki_repository_states_pkey PRIMARY KEY (id); +ALTER TABLE ONLY work_item_dates_sources + ADD CONSTRAINT work_item_dates_sources_pkey PRIMARY KEY (issue_id); + ALTER TABLE ONLY work_item_hierarchy_restrictions ADD CONSTRAINT work_item_hierarchy_restrictions_pkey PRIMARY KEY (id); @@ -35540,6 +35558,16 @@ CREATE INDEX users_forbidden_state_idx ON users USING btree (id) WHERE ((confirm CREATE UNIQUE INDEX vulnerability_occurrence_pipelines_on_unique_keys ON vulnerability_occurrence_pipelines USING btree (occurrence_id, pipeline_id); +CREATE INDEX wi_datessources_due_date_sourcing_milestone_id_index ON work_item_dates_sources USING btree (due_date_sourcing_milestone_id); + +CREATE INDEX wi_datessources_due_date_sourcing_work_item_id_index ON work_item_dates_sources USING btree (due_date_sourcing_work_item_id); + +CREATE INDEX wi_datessources_namespace_id_index ON work_item_dates_sources USING btree (namespace_id); + +CREATE INDEX wi_datessources_start_date_sourcing_milestone_id_index ON work_item_dates_sources USING btree (start_date_sourcing_milestone_id); + +CREATE INDEX wi_datessources_start_date_sourcing_work_item_id_index ON work_item_dates_sources USING btree (start_date_sourcing_work_item_id); + CREATE UNIQUE INDEX work_item_types_namespace_id_and_name_unique ON work_item_types USING btree (namespace_id, btrim(lower(name))); ALTER INDEX analytics_cycle_analytics_issue_stage_events_pkey ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_00_pkey; @@ -37400,6 +37428,9 @@ ALTER TABLE ONLY geo_event_log ALTER TABLE ONLY user_namespace_callouts ADD CONSTRAINT fk_27a69fd1bd FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; +ALTER TABLE ONLY work_item_dates_sources + ADD CONSTRAINT fk_283fb4ad36 FOREIGN KEY (start_date_sourcing_milestone_id) REFERENCES milestones(id) ON DELETE SET NULL; + ALTER TABLE ONLY project_group_links ADD CONSTRAINT fk_28a1244b01 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE NOT VALID; @@ -37832,6 +37863,9 @@ ALTER TABLE ONLY catalog_resource_components ALTER TABLE ONLY protected_branch_merge_access_levels ADD CONSTRAINT fk_8a3072ccb3 FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE; +ALTER TABLE ONLY work_item_dates_sources + ADD CONSTRAINT fk_8a4948b668 FOREIGN KEY (start_date_sourcing_work_item_id) REFERENCES issues(id) ON DELETE SET NULL; + ALTER TABLE ONLY bulk_import_exports ADD CONSTRAINT fk_8c6f33cebe FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; @@ -38168,6 +38202,9 @@ ALTER TABLE p_ci_builds ALTER TABLE ONLY ci_sources_pipelines ADD CONSTRAINT fk_d4e29af7d7 FOREIGN KEY (source_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; +ALTER TABLE ONLY work_item_dates_sources + ADD CONSTRAINT fk_d602f0955d FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL; + ALTER TABLE ONLY incident_management_timeline_events ADD CONSTRAINT fk_d606a2a890 FOREIGN KEY (promoted_from_note_id) REFERENCES notes(id) ON DELETE SET NULL; @@ -38210,6 +38247,9 @@ ALTER TABLE ONLY project_topics ALTER TABLE ONLY web_hooks ADD CONSTRAINT fk_db1ea5699b FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE; +ALTER TABLE ONLY work_item_dates_sources + ADD CONSTRAINT fk_dbbe8917ee FOREIGN KEY (due_date_sourcing_work_item_id) REFERENCES issues(id) ON DELETE SET NULL; + ALTER TABLE ONLY security_scans ADD CONSTRAINT fk_dbc89265b9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -38369,6 +38409,9 @@ ALTER TABLE ONLY system_note_metadata ALTER TABLE ONLY vulnerability_remediations ADD CONSTRAINT fk_fc61a535a0 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; +ALTER TABLE ONLY work_item_dates_sources + ADD CONSTRAINT fk_fc7bc5e687 FOREIGN KEY (due_date_sourcing_milestone_id) REFERENCES milestones(id) ON DELETE SET NULL; + ALTER TABLE ONLY abuse_report_events ADD CONSTRAINT fk_fdd4d610e0 FOREIGN KEY (abuse_report_id) REFERENCES abuse_reports(id) ON DELETE CASCADE; @@ -39389,6 +39432,9 @@ ALTER TABLE incident_management_pending_alert_escalations ALTER TABLE ONLY approval_merge_request_rules_approved_approvers ADD CONSTRAINT fk_rails_8dc94cff4d FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY work_item_dates_sources + ADD CONSTRAINT fk_rails_8dcefa21a5 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE; + ALTER TABLE ONLY design_user_mentions ADD CONSTRAINT fk_rails_8de8c6d632 FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE; |