Skip to content

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

Availability and Testing

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 🤖

Merge request reports