VSA - Add sharding key for `analytics_cycle_analytics_stage_event_hashes` table
Overview
About GitLab Cells.
Tasks
The analytics_cycle_analytics_stage_event_hashes
table contains global metadata which is associated with stage records (group-level). To make this table work with the org mover we need to alter the database schema.
Task: Add organization_id
to the table
- Add organization_id to the
analytics_cycle_analytics_stage_event_hashes
table with default value 1. - Change the unique index on
hash_sha256
and scope it to theorganization_id
column. - When a new record is created, set the organization ID using the association which creates the hash record.
# in the ensure_stage_event_hash_id method stage = Stage.build(...) hash = Hash.create(organization_id: stage.group.organization_id, ...) stage.save!
- Update all queries where we load the hash records to be scoped to the associated
namespace.organization_id
. - Configure the sharding key in the YML for
analytics_cycle_analytics_stage_event_hashes
.
Edited by Haim Snir