-
- Downloads
Add and backfill namespace_id for resource_weight_events
Add and backfill namespace_id for resource_weight_events. This table has a [desired sharding key](https://docs.gitlab.com/ee/development/database/multiple_databases.html#define-a-desired_sharding_key-to-automatically-backfill-a-sharding_key) configured ([view configuration](https://gitlab.com/gitlab-org/gitlab/-/blob/master/db/docs/resource_weight_events.yml)). This merge request is the first step towards transforming the desired sharding key into a [sharding key](https://docs.gitlab.com/ee/development/database/multiple_databases.html#defining-a-sharding-key-for-all-cell-local-tables). This involves three changes: - Adding a new column that will serve as the sharding key (along with the relevant index and foreign key). - Populating the sharding key when new records are created by adding a database function and trigger. - Scheduling a [batched background migration](https://docs.gitlab.com/ee/development/database/batched_background_migrations.html) to set the sharding key for existing records. Once the background migration has completed, a second merge request will be created to finalize the background migration and validate the not null constraint. We have assigned a random backend engineer from ~"group::project management" to review these changes. Please review this merge request from a ~backend perspective. The main thing we are looking to verify is that the added column and association match the values specified by the [desired sharding key](https://gitlab.com/gitlab-org/gitlab/-/blob/master/db/docs/resource_weight_events.yml) configuration and that backfilling the column from this other table makes sense in the context of this feature. When you are finished, please: 1. Trigger the [database testing pipeline](https://docs.gitlab.com/ee/development/database/database_migration_pipeline.html) as instructed by Danger. 1. Request a review from the ~backend maintainer and ~database reviewer suggested by Danger. If you have any questions or concerns, reach out to `@tigerwnz` or @shubhamkrai. This merge request was generated by a once off keep implemented in !143774 This change was generated by [gitlab-housekeeper](https://gitlab.com/gitlab-org/gitlab/-/tree/master/gems/gitlab-housekeeper) using the Keeps::BackfillDesiredShardingKeySmallTable keep. To provide feedback on your experience with `gitlab-housekeeper` please create an issue with the label ~"GitLab Housekeeper" and consider pinging the author of this keep. Changelog: other
Showing
- db/docs/batched_background_migrations/backfill_resource_weight_events_namespace_id.yml 8 additions, 0 deletions...grations/backfill_resource_weight_events_namespace_id.yml
- db/docs/resource_weight_events.yml 1 addition, 0 deletionsdb/docs/resource_weight_events.yml
- db/migrate/20241202142250_add_namespace_id_to_resource_weight_events.rb 9 additions, 0 deletions...41202142250_add_namespace_id_to_resource_weight_events.rb
- db/post_migrate/20241202142251_index_resource_weight_events_on_namespace_id.rb 16 additions, 0 deletions...202142251_index_resource_weight_events_on_namespace_id.rb
- db/post_migrate/20241202142252_add_resource_weight_events_namespace_id_fk.rb 16 additions, 0 deletions...41202142252_add_resource_weight_events_namespace_id_fk.rb
- db/post_migrate/20241202142253_add_resource_weight_events_namespace_id_trigger.rb 25 additions, 0 deletions...142253_add_resource_weight_events_namespace_id_trigger.rb
- db/post_migrate/20241202142254_queue_backfill_resource_weight_events_namespace_id.rb 40 additions, 0 deletions...254_queue_backfill_resource_weight_events_namespace_id.rb
- db/schema_migrations/20241202142250 1 addition, 0 deletionsdb/schema_migrations/20241202142250
- db/schema_migrations/20241202142251 1 addition, 0 deletionsdb/schema_migrations/20241202142251
- db/schema_migrations/20241202142252 1 addition, 0 deletionsdb/schema_migrations/20241202142252
- db/schema_migrations/20241202142253 1 addition, 0 deletionsdb/schema_migrations/20241202142253
- db/schema_migrations/20241202142254 1 addition, 0 deletionsdb/schema_migrations/20241202142254
- db/structure.sql 25 additions, 1 deletiondb/structure.sql
- lib/gitlab/background_migration/backfill_resource_weight_events_namespace_id.rb 10 additions, 0 deletions...migration/backfill_resource_weight_events_namespace_id.rb
- spec/lib/gitlab/background_migration/backfill_resource_weight_events_namespace_id_spec.rb 15 additions, 0 deletions...tion/backfill_resource_weight_events_namespace_id_spec.rb
- spec/migrations/20241202142254_queue_backfill_resource_weight_events_namespace_id_spec.rb 33 additions, 0 deletions...ueue_backfill_resource_weight_events_namespace_id_spec.rb
db/schema_migrations/20241202142250
0 → 100644
db/schema_migrations/20241202142251
0 → 100644
db/schema_migrations/20241202142252
0 → 100644
db/schema_migrations/20241202142253
0 → 100644
db/schema_migrations/20241202142254
0 → 100644
Please register or sign in to comment