Add `work_item_types.correct_id` column
What does this MR do and why?
We need this new column as the first step to make IDs in the work_item_types table sequential 1 - 9. The next step is to create a new foreign key on the issues table that will use these new correct_id values to fetch the associated work item type on every issue
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Migration output
UP
main: == [advisory_lock_connection] object_id: 128800, pg_backend_pid: 47939
main: == 20240918202118 AddCorrectIdToWorkItemTypes: migrating ======================
main: -- add_column(:work_item_types, :correct_id, :bigint, {:null=>false, :default=>0})
main: -> 0.0059s
main: == 20240918202118 AddCorrectIdToWorkItemTypes: migrated (0.0101s) =============
main: == [advisory_lock_connection] object_id: 128800, pg_backend_pid: 47939
ci: == [advisory_lock_connection] object_id: 129100, pg_backend_pid: 47943
ci: == 20240918202118 AddCorrectIdToWorkItemTypes: migrating ======================
ci: -- add_column(:work_item_types, :correct_id, :bigint, {:null=>false, :default=>0})
ci: -> 0.0055s
ci: == 20240918202118 AddCorrectIdToWorkItemTypes: migrated (0.0127s) =============
ci: == [advisory_lock_connection] object_id: 129100, pg_backend_pid: 47943
main: == [advisory_lock_connection] object_id: 129340, pg_backend_pid: 47946
main: == 20240918204510 SetCorrectIdToExistingWorkItemTypes: migrating ==============
main: == 20240918204510 SetCorrectIdToExistingWorkItemTypes: migrated (0.0279s) =====
main: == [advisory_lock_connection] object_id: 129340, pg_backend_pid: 47946
ci: == [advisory_lock_connection] object_id: 130220, pg_backend_pid: 47948
ci: == 20240918204510 SetCorrectIdToExistingWorkItemTypes: migrating ==============
ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main].
ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_internal, :gitlab_shared].
ci: == 20240918204510 SetCorrectIdToExistingWorkItemTypes: migrated (0.0070s) =====
ci: == [advisory_lock_connection] object_id: 130220, pg_backend_pid: 47948
DOWN
main: == [advisory_lock_connection] object_id: 128540, pg_backend_pid: 85267
main: == 20240918204510 SetCorrectIdToExistingWorkItemTypes: reverting ==============
main: == 20240918204510 SetCorrectIdToExistingWorkItemTypes: reverted (0.0623s) =====
main: == [advisory_lock_connection] object_id: 128540, pg_backend_pid: 85267
ci: == [advisory_lock_connection] object_id: 134260, pg_backend_pid: 85529
ci: == 20240918204510 SetCorrectIdToExistingWorkItemTypes: reverting ==============
ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main].
ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_internal, :gitlab_shared].
ci: == 20240918204510 SetCorrectIdToExistingWorkItemTypes: reverted (0.0074s) =====
ci: == [advisory_lock_connection] object_id: 134260, pg_backend_pid: 85529
main: == [advisory_lock_connection] object_id: 128520, pg_backend_pid: 86039
main: == 20240918202118 AddCorrectIdToWorkItemTypes: reverting ======================
main: -- remove_column(:work_item_types, :correct_id, :bigint, {:null=>false, :default=>0})
main: -> 0.0014s
main: == 20240918202118 AddCorrectIdToWorkItemTypes: reverted (0.0056s) =============
main: == [advisory_lock_connection] object_id: 128520, pg_backend_pid: 86039
ci: == [advisory_lock_connection] object_id: 129340, pg_backend_pid: 86297
ci: == 20240918202118 AddCorrectIdToWorkItemTypes: reverting ======================
ci: -- remove_column(:work_item_types, :correct_id, :bigint, {:null=>false, :default=>0})
ci: -> 0.0024s
ci: == 20240918202118 AddCorrectIdToWorkItemTypes: reverted (0.0092s) =============
ci: == [advisory_lock_connection] object_id: 129340, pg_backend_pid: 86297
Related to #493972 (closed) part of &15272 (closed)
Edited by Mario Celi