[Plan] Create foreign key constraints for new name_uid columns
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Objective
Create foreign key constraints between the new name_uid columns and validate data integrity across all referencing tables.
plans table FixedItemModels there won't be any foreign key reference?
Prerequisites
- Application code updated to use new associations (#571422)
Tasks
-
Create foreign key constraints for new columns:
-
plan_limits.plan_name_uid→plans.name_uid -
gitlab_subscriptions.hosted_plan_name_uid→plans.name_uid -
gitlab_subscription_histories.hosted_plan_name_uid→plans.name_uid - Other referencing tables as identified
-
- Validate data integrity before adding constraints
- Handle any orphaned records or data inconsistencies
- Add not-null constraints where appropriate
- Test constraint enforcement
- Ensure constraints are properly indexed for performance
Data Validation Steps
-
Verify all referencing records have valid
name_uidvalues - Identify and handle orphaned records
- Check for any null values that should not exist
- Validate enum values are within expected range
Migration Strategy
- Validate data integrity first
- Clean up any orphaned or invalid records
- Add foreign key constraints
- Add not-null constraints where appropriate
- Verify constraint enforcement works correctly
Acceptance Criteria
- Foreign key constraints created for all new columns
- Data integrity validated and maintained
- No orphaned records remain
- Constraints properly enforce referential integrity
- Performance impact assessed and acceptable
- Rollback plan tested and documented
References
- Parent Epic: Convert `plans` table to be hard-coded in appli... (&19409)
- Original Issue: #519892 (closed)
Edited by 🤖 GitLab Bot 🤖