Sign in or sign up before continuing. Don't have an account yet? Register now to get started.
[Cells 1.0] Default Work Item Types: Ensure work item type IDs are constant 1-9
Create a database migration to ensure work item types are constant - 1, 2, 3, 4, 5, 6, 7, 8, 9.
Define the default work item type IDs in the application logic.
See https://gitlab.com/gitlab-org/gitlab/-/issues/459904 and https://gitlab.com/gitlab-org/gitlab/-/issues/423483 and https://gitlab.slack.com/archives/C3NBYFJ6N/p1714539272456519 (internal only, 90 days) for some prior discussion on this.
## Current implementation plan
From one of Charlie's PoC I think this might be the best approach to accomplish this https://gitlab.com/gitlab-org/gitlab/-/merge_requests/155416+
In a few words, add a new column to both `issues` and `work_item_types` tables with temp values and that will serve as a new FK with the correct IDs (1 - 9). App code will use the new column to fetch associated records once it's backfilled. Once this works correctly we do the same to go back to the original column.
1. Seeder is explicit about the IDs and uses sequential IDs. We upsert the types based on `base_type` in the event the type already existed with the incorrect ID for whatever reason. We must also upsert the new temp column.
1. Remove the default value for `work_item_typs.id` column and drop sequence in work item types table (post deploy migration so the new seeder is already explicit about IDs). Temporary while we make IDs sequential and can remain until in the future we allow custom work item types
1. new `correct_work_item_type_id` column on issues table
1. new `correct_id` on work_item_types_id table
1. We backfill the correct id for every issue on the table
1. Finalize migration
1. Override relationship method to call super or correct_id relationship when fetching related records (can be behind feature flag)
1. If everything is working as expected on the new column, fix work_item_types.id with the correct/expected IDs
1. Backfill the original issues.work_item_type_id column with the correct values.
1. Finalize migration
1. Again behind a feature flag, test everything works on the original column.
1. If everything works, now we have the correct ID in the original columns with the right names and we can drop temp columns
In this epic we are only going as far as using sequential IDs in the new temp column as this will already unblock the cells team. I have created https://gitlab.com/groups/gitlab-org/-/epics/15905 to continue working on the last steps described above (going back to using the original issues.work_item_type_id column)
epic