Add NOT NULL to snippet_statistics
What does this MR do and why?
Adds NOT NULL constraint on sharding key column snippet_project_id
, snippet_organization_id
on table: snippet_statistics
.
This merge request is the last step towards transforming the desired sharding key into a sharding key.
This involves the following changes:
- Adding a not null constraint for the sharding key columns (
snippet_project_id
,snippet_organization_id
). - Setting
snippet_project_id
,snippet_organization_id
assharding_key
ofsnippet_statistics
.
We are skipping model-level validations when adding NOT NULL
for now: !189213 (comment 2480466972)
The backfilling migrations were finished and finalized:
- https://gitlab.com/gitlab-org/gitlab/blob/734083808aadc236b0104bcb7ab5df867def7f06/db/docs/batched_background_migrations/backfill_snippet_statistics_snippet_project_id.yml
- https://gitlab.com/gitlab-org/gitlab/blob/4d412b83b5e6627a7b4b0e61dd5e759633d0d42b/db/docs/batched_background_migrations/backfill_snippet_statistics_snippet_organization_id.yml
References
- !189213 (comment 2480466972)
- https://docs.gitlab.com/ee/development/database/multiple_databases.html#defining-a-sharding-key-for-all-cell-local-tables
- https://docs.gitlab.com/development/database/not_null_constraints/
- #514146 (closed)
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.