Add organization_id column to keys table
Overview
This issue tracks adding the organization_id column to the keys table as part of the sharding key implementation for GitLab Cells architecture.
Status:
What was done
The database schema changes have been successfully merged and deployed:
- Added
organization_idcolumn to thekeystable (type:bigint) - Created index on
organization_idfor query performance - Added foreign key constraint to
organizationstable withON DELETE CASCADE - Updated
db/docs/keys.ymlwith:gitlab_schema: gitlab_main_orgsharding_key: organization_id
- Added model association:
belongs_to :organizationinapp/models/key.rb - Removed
sharding_key_issue_urlfrom documentation
Database Migration Details
The following migrations were created and executed:
- 20251008081704_add_organization_id_to_keys.rb - Added the column
- 20251008113553_add_index_to_keys_organization_id.rb - Added index
- 20251010161830_add_foreign_key_to_keys_organization.rb - Added foreign key constraint
References
- Merge Request: !208105 (merged) (merged)
- Parent Epic: &19679
- Investigation Issue: #553463 (closed)
Next Steps
This issue can be closed. The remaining work is tracked in:
- #577243 (closed) - Update application logic for SSH keys
- #577244 - Update application logic for deploy keys
- #577245 - Backfill migration for existing records
- #577246 - Add NOT NULL constraint
Edited by Aboobacker MK