Database schema inconsistency: Ci::Build.name, Ci::BuildNeed.build_name and Ci::BuildName.name string limits are not aligned
Summary
The string length limits for CI build name fields are inconsistent across related database tables. The following fields should have aligned limits but currently don't:
Ci::Build.nameCi::BuildNeed.build_nameCi::BuildName.name
Related links (Internal): Slack, Issue
EDIT
After some research we found:
- Ci::CommitStatus has no name limit on neither the application or the DB level
- Ci::BuildNeed has no limit on the DB level but has 255 at the application level
- Ci::BuildName has a check constraint on the DB and application limit set to 255. When setting the name, it truncates the data.
Expected Behavior
All three fields should have the same string length limit to ensure data consistency across the CI build domain models.
Proposed Solution
To avoid data loss and maintain backward compatibility, we should:
-
Identify the maximum limit among the three fields (appears to be
Ci::Build.name) - Align all fields to this maximum limit through a database migration
- Add validation to ensure consistency is maintained going forward
- Update model validations to reflect the standardized limit
Migration Considerations
Since this change involves modifying column limits, we need to:
- Create a post-deployment migration to update the column limits
- Ensure the migration is safe for large tables (ci_builds can be very large)
- Verify no existing data exceeds the new limits before applying
- Consider using batched background migrations if needed for large datasets
Edited by Panos Kanellidis