[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 #459904 (closed) and #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 Add new "correct id" to work item types and bac... (!155416 - closed)
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.
- 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. - 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 - temp_work_item_type_id column on issues table
- temp_id on work_item_types_id table
- We backfill the correct id for every issue on the table
- Finalize migration
- Override relationship method to call super or temp relationship when fetching related records (can be behind feature flag)
- If everything is working as expected on the new column, fix work_item_types.id with the correct/expected IDs
- Backfill the original issues.work_item_type_id column with the correct values.
- Finalize migration
- Again behind a feature flag, test everything works on the original column.
- If everything works, now we have the correct ID in the original columns with the right names and we can drop temp columns