Skip to content

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: COMPLETED via !208105 (merged)

What was done

The database schema changes have been successfully merged and deployed:

  • Added organization_id column to the keys table (type: bigint)
  • Created index on organization_id for query performance
  • Added foreign key constraint to organizations table with ON DELETE CASCADE
  • Updated db/docs/keys.yml with:
    • gitlab_schema: gitlab_main_org
    • sharding_key: organization_id
  • Added model association: belongs_to :organization in app/models/key.rb
  • Removed sharding_key_issue_url from documentation

Database Migration Details

The following migrations were created and executed:

  1. 20251008081704_add_organization_id_to_keys.rb - Added the column
  2. 20251008113553_add_index_to_keys_organization_id.rb - Added index
  3. 20251010161830_add_foreign_key_to_keys_organization.rb - Added foreign key constraint

References

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