Validate NOT NULL constraint on gitlab_subscriptions namespace_id
requested to merge 321662-validate_not_null_constraint_on_gitlab_subscriptions_namespace_id into master
What does this MR do?
For issue #321662 (closed). This MR is the seconds step to validate the NOT NULL constraint on GitlabSubscriptions namespace_id column
.
Isseu #243496 (closed) requires to add NOT NULL constraint on GitlabSubscriptions namespace_id column. Per document https://docs.gitlab.com/ee/development/database/not_null_constraints.html#add-a-not-null-constraint-to-an-existing-column, it requires two steps in two releases.
The first step is done by MR !54319 (merged), where it:
- Ensure the constraint is enforced at the application level (i.e. add a model validation).
- Add a post-deployment migration to add the NOT NULL constraint with validate: false.
- Add a post-deployment migration to fix the existing records
This MR is the second step, where it:
- Validate the NOT NULL constraint using a post-deployment migration.
Migration output
Up
$ bin/rails db:migrate
== 20210322115438 ValidateNotNullConstraintOnGitlabSubscriptionsNamespaceId: migrating
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE gitlab_subscriptions VALIDATE CONSTRAINT check_77fea3f0e7;")
-> 0.0006s
== 20210322115438 ValidateNotNullConstraintOnGitlabSubscriptionsNamespaceId: migrated (0.0029s)
NO-OP
in this migration script)
Down (Note: rollback is $ bin/rails db:rollback
== 20210322115438 ValidateNotNullConstraintOnGitlabSubscriptionsNamespaceId: reverting
== 20210322115438 ValidateNotNullConstraintOnGitlabSubscriptionsNamespaceId: reverted (0.0000s)
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related to #321662 (closed)
Edited by Max Orefice