Add constraint to resource_state_events table to check for valid issuable setup
What does this MR do?
We need to update the CONSTRAINT
on resource_state_events
table to support the newly added epic_id
.
Migrations
Up
> bundle exec rails db:migrate:up VERSION=20200519074709
== 20200519074709 UpdateResourceStateEventsConstraintToSupportEpicId: migrating
-- execute("ALTER TABLE resource_state_events\nDROP CONSTRAINT IF EXISTS resource_state_events_must_belong_to_issue_or_merge_request\n")
-> 0.0010s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE resource_state_events\nADD CONSTRAINT resource_state_events_must_belong_to_issue_or_merge_request_or_epic\nCHECK ( (issue_id != NULL AND merge_request_id IS NULL AND epic_id IS NULL) OR (issue_id IS NULL AND merge_request_id != NULL AND epic_id IS NULL) OR(issue_id IS NULL AND merge_request_id IS NULL AND epic_id != NULL) )\nNOT VALID;\n")
-> 0.0011s
-- execute("ALTER TABLE resource_state_events VALIDATE CONSTRAINT resource_state_events_must_belong_to_issue_or_merge_request_or_epic;")
-> 0.0017s
== 20200519074709 UpdateResourceStateEventsConstraintToSupportEpicId: migrated (0.0203s)
Down
> bundle exec rails db:migrate:down VERSION=20200519074709
== 20200519074709 UpdateResourceStateEventsConstraintToSupportEpicId: reverting
-- execute("ALTER TABLE resource_state_events\nDROP CONSTRAINT IF EXISTS resource_state_events_must_belong_to_issue_or_merge_request_or_epic\n")
-> 0.0011s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE resource_state_events\nADD CONSTRAINT resource_state_events_must_belong_to_issue_or_merge_request\nCHECK ( (issue_id != NULL AND merge_request_id IS NULL) OR (merge_request_id != NULL AND issue_id IS NULL) )\nNOT VALID;\n")
-> 0.0009s
-- execute("ALTER TABLE resource_state_events VALIDATE CONSTRAINT resource_state_events_must_belong_to_issue_or_merge_request;")
-> 0.0016s
== 20200519074709 UpdateResourceStateEventsConstraintToSupportEpicId: reverted (0.0280s)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
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
Edited by 🤖 GitLab Bot 🤖