Skip to content

Add WorkItems::DatesStart table

Kassio Borges requested to merge kassio/add-work-items-dates-sources-table into master

What does this MR do and why?

Add WorkItems::DatesStart table/model

This is part of Improved Epic Experience on Work Items Framework (&9290).

This table will be used initially on the RolledupDatesWidget, but later it might also be used as the SSOT of the issues start/end dates.

Related to: #409936 (closed)

Changelog: added

Migrations

bundle exec rails db:migrate:up:main VERSION=20231207150738
main: == [advisory_lock_connection] object_id: 182300, pg_backend_pid: 53972
main: == 20231207150738 AddWorkItemDatesSources: migrating ==========================
main: -- create_table(:work_item_dates_sources, {:id=>false})
main:    -> 0.0046s
main: == 20231207150738 AddWorkItemDatesSources: migrated (0.1451s) =================

main: == [advisory_lock_connection] object_id: 182300, pg_backend_pid: 53972
bundle exec rails db:migrate:up:ci VERSION=20231207150738
ci: == [advisory_lock_connection] object_id: 182300, pg_backend_pid: 54361
ci: == 20231207150738 AddWorkItemDatesSources: migrating ==========================
ci: -- create_table(:work_item_dates_sources, {:id=>false})
ci:    -> 0.0049s
I, [2023-12-14T19:14:18.556931 #54219]  INFO -- : Database: 'ci', Table: 'work_item_dates_sources': Lock Writes
ci: == 20231207150738 AddWorkItemDatesSources: migrated (0.0772s) =================

ci: == [advisory_lock_connection] object_id: 182300, pg_backend_pid: 54361
bundle exec rails db:migrate:up:main VERSION=20231207150739
main: == [advisory_lock_connection] object_id: 182340, pg_backend_pid: 54746
main: == 20231207150739 AddWorkItemDatesSourcesForeingKeys: migrating ===============
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_d602f0955d FOREIGN KEY (namespace_id) REFERENCES namespaces (id) ON DELETE SET NULL NOT VALID;")
main:    -> 0.0012s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_d602f0955d;")
main:    -> 0.0051s
main: -- execute("RESET statement_timeout")
main:    -> 0.0004s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0006s
main: -- index_exists?(:work_item_dates_sources, :namespace_id, {:name=>"wi_datessources_namespace_id_index", :algorithm=>:concurrently})
main:    -> 0.0012s
main: -- add_index(:work_item_dates_sources, :namespace_id, {:name=>"wi_datessources_namespace_id_index", :algorithm=>:concurrently})
main:    -> 0.0012s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_8a4948b668 FOREIGN KEY (start_date_sourcing_work_item_id) REFERENCES issues (id) ON DELETE SET NULL NOT VALID;")
main:    -> 0.0007s
main: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_8a4948b668;")
main:    -> 0.0045s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0004s
main: -- index_exists?(:work_item_dates_sources, :start_date_sourcing_work_item_id, {:name=>"wi_datessources_start_date_sourcing_work_item_id_index", :algorithm=>:concurrently})
main:    -> 0.0011s
main: -- add_index(:work_item_dates_sources, :start_date_sourcing_work_item_id, {:name=>"wi_datessources_start_date_sourcing_work_item_id_index", :algorithm=>:concurrently})
main:    -> 0.0008s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_283fb4ad36 FOREIGN KEY (start_date_sourcing_milestone_id) REFERENCES milestones (id) ON DELETE SET NULL NOT VALID;")
main:    -> 0.0005s
main: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_283fb4ad36;")
main:    -> 0.0020s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0007s
main: -- index_exists?(:work_item_dates_sources, :start_date_sourcing_milestone_id, {:name=>"wi_datessources_start_date_sourcing_milestone_id_index", :algorithm=>:concurrently})
main:    -> 0.0013s
main: -- add_index(:work_item_dates_sources, :start_date_sourcing_milestone_id, {:name=>"wi_datessources_start_date_sourcing_milestone_id_index", :algorithm=>:concurrently})
main:    -> 0.0009s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_dbbe8917ee FOREIGN KEY (due_date_sourcing_work_item_id) REFERENCES issues (id) ON DELETE SET NULL NOT VALID;")
main:    -> 0.0005s
main: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_dbbe8917ee;")
main:    -> 0.0007s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0005s
main: -- index_exists?(:work_item_dates_sources, :due_date_sourcing_work_item_id, {:name=>"wi_datessources_due_date_sourcing_work_item_id_index", :algorithm=>:concurrently})
main:    -> 0.0016s
main: -- add_index(:work_item_dates_sources, :due_date_sourcing_work_item_id, {:name=>"wi_datessources_due_date_sourcing_work_item_id_index", :algorithm=>:concurrently})
main:    -> 0.0008s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_fc7bc5e687 FOREIGN KEY (due_date_sourcing_milestone_id) REFERENCES milestones (id) ON DELETE SET NULL NOT VALID;")
main:    -> 0.0005s
main: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_fc7bc5e687;")
main:    -> 0.0005s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0005s
main: -- index_exists?(:work_item_dates_sources, :due_date_sourcing_milestone_id, {:name=>"wi_datessources_due_date_sourcing_milestone_id_index", :algorithm=>:concurrently})
main:    -> 0.0022s
main: -- add_index(:work_item_dates_sources, :due_date_sourcing_milestone_id, {:name=>"wi_datessources_due_date_sourcing_milestone_id_index", :algorithm=>:concurrently})
main:    -> 0.0011s
main: == 20231207150739 AddWorkItemDatesSourcesForeingKeys: migrated (0.1893s) ======

main: == [advisory_lock_connection] object_id: 182340, pg_backend_pid: 54746
bundle exec rails db:migrate:up:ci VERSION=20231207150739
ci: == [advisory_lock_connection] object_id: 181240, pg_backend_pid: 55192
ci: == 20231207150739 AddWorkItemDatesSourcesForeingKeys: migrating ===============
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_d602f0955d FOREIGN KEY (namespace_id) REFERENCES namespaces (id) ON DELETE SET NULL NOT VALID;")
ci:    -> 0.0009s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0003s
ci: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_d602f0955d;")
ci:    -> 0.0042s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0002s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0006s
ci: -- index_exists?(:work_item_dates_sources, :namespace_id, {:name=>"wi_datessources_namespace_id_index", :algorithm=>:concurrently})
ci:    -> 0.0012s
ci: -- add_index(:work_item_dates_sources, :namespace_id, {:name=>"wi_datessources_namespace_id_index", :algorithm=>:concurrently})
ci:    -> 0.0011s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_8a4948b668 FOREIGN KEY (start_date_sourcing_work_item_id) REFERENCES issues (id) ON DELETE SET NULL NOT VALID;")
ci:    -> 0.0006s
ci: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_8a4948b668;")
ci:    -> 0.0040s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0006s
ci: -- index_exists?(:work_item_dates_sources, :start_date_sourcing_work_item_id, {:name=>"wi_datessources_start_date_sourcing_work_item_id_index", :algorithm=>:concurrently})
ci:    -> 0.0012s
ci: -- add_index(:work_item_dates_sources, :start_date_sourcing_work_item_id, {:name=>"wi_datessources_start_date_sourcing_work_item_id_index", :algorithm=>:concurrently})
ci:    -> 0.0009s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_283fb4ad36 FOREIGN KEY (start_date_sourcing_milestone_id) REFERENCES milestones (id) ON DELETE SET NULL NOT VALID;")
ci:    -> 0.0004s
ci: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_283fb4ad36;")
ci:    -> 0.0020s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0005s
ci: -- index_exists?(:work_item_dates_sources, :start_date_sourcing_milestone_id, {:name=>"wi_datessources_start_date_sourcing_milestone_id_index", :algorithm=>:concurrently})
ci:    -> 0.0012s
ci: -- add_index(:work_item_dates_sources, :start_date_sourcing_milestone_id, {:name=>"wi_datessources_start_date_sourcing_milestone_id_index", :algorithm=>:concurrently})
ci:    -> 0.0007s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_dbbe8917ee FOREIGN KEY (due_date_sourcing_work_item_id) REFERENCES issues (id) ON DELETE SET NULL NOT VALID;")
ci:    -> 0.0005s
ci: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_dbbe8917ee;")
ci:    -> 0.0007s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0005s
ci: -- index_exists?(:work_item_dates_sources, :due_date_sourcing_work_item_id, {:name=>"wi_datessources_due_date_sourcing_work_item_id_index", :algorithm=>:concurrently})
ci:    -> 0.0016s
ci: -- add_index(:work_item_dates_sources, :due_date_sourcing_work_item_id, {:name=>"wi_datessources_due_date_sourcing_work_item_id_index", :algorithm=>:concurrently})
ci:    -> 0.0007s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE work_item_dates_sources ADD CONSTRAINT fk_fc7bc5e687 FOREIGN KEY (due_date_sourcing_milestone_id) REFERENCES milestones (id) ON DELETE SET NULL NOT VALID;")
ci:    -> 0.0006s
ci: -- execute("ALTER TABLE work_item_dates_sources VALIDATE CONSTRAINT fk_fc7bc5e687;")
ci:    -> 0.0006s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci:    -> 0.0005s
ci: -- index_exists?(:work_item_dates_sources, :due_date_sourcing_milestone_id, {:name=>"wi_datessources_due_date_sourcing_milestone_id_index", :algorithm=>:concurrently})
ci:    -> 0.0019s
ci: -- add_index(:work_item_dates_sources, :due_date_sourcing_milestone_id, {:name=>"wi_datessources_due_date_sourcing_milestone_id_index", :algorithm=>:concurrently})
ci:    -> 0.0009s
ci: == 20231207150739 AddWorkItemDatesSourcesForeingKeys: migrated (0.1902s) ======

ci: == [advisory_lock_connection] object_id: 181240, pg_backend_pid: 55192
bundle exec rails db:migrate:down:main VERSION=20231207150739
main: == 20231207150739 AddWorkItemDatesSourcesForeingKeys: reverting ===============
main: -- remove_foreign_key(:work_item_dates_sources, :issues, {:column=>:start_date_sourcing_work_item_id})
main:    -> 0.0025s
main: -- remove_foreign_key(:work_item_dates_sources, :issues, {:column=>:due_date_sourcing_work_item_id})
main:    -> 0.0021s
main: == 20231207150739 AddWorkItemDatesSourcesForeingKeys: reverted (0.1434s) ======

main: == [advisory_lock_connection] object_id: 182400, pg_backend_pid: 52387
bundle exec rails db:migrate:down:ci VERSION=20231207150739
ci: == [advisory_lock_connection] object_id: 182280, pg_backend_pid: 52776
ci: == 20231207150739 AddWorkItemDatesSourcesForeingKeys: reverting ===============
ci: -- remove_foreign_key(:work_item_dates_sources, :issues, {:column=>:start_date_sourcing_work_item_id})
ci:    -> 0.0026s
ci: -- remove_foreign_key(:work_item_dates_sources, :issues, {:column=>:due_date_sourcing_work_item_id})
ci:    -> 0.0019s
ci: == 20231207150739 AddWorkItemDatesSourcesForeingKeys: reverted (0.1483s) ======

ci: == [advisory_lock_connection] object_id: 182280, pg_backend_pid: 52776
bundle exec rails db:migrate:down:main VERSION=20231207150738
main: == [advisory_lock_connection] object_id: 181280, pg_backend_pid: 53165
main: == 20231207150738 AddWorkItemDatesSources: reverting ==========================
main: -- drop_table(:work_item_dates_sources)
main:    -> 0.0029s
main: == 20231207150738 AddWorkItemDatesSources: reverted (0.0060s) =================

main: == [advisory_lock_connection] object_id: 181280, pg_backend_pid: 53165
bundle exec rails db:migrate:down:ci VERSION=20231207150738
ci: == [advisory_lock_connection] object_id: 182300, pg_backend_pid: 53548
ci: == 20231207150738 AddWorkItemDatesSources: reverting ==========================
ci: -- drop_table(:work_item_dates_sources)
ci:    -> 0.0024s
ci: == 20231207150738 AddWorkItemDatesSources: reverted (0.0100s) =================

ci: == [advisory_lock_connection] object_id: 182300, pg_backend_pid: 53548

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Kassio Borges

Merge request reports

Loading