Skip to content

Relate Test Reports and Requirement Issues

charlie ablett requested to merge 323779-requirement-issue-association into master

What does this MR do?

Adds a new relationship to the test_reports table to support migration of dedicated RequirementsManagement::Requirement objects to Issue objects of type Requirement.

Only one of the two requirement relationships will be allowed (XOR).

See #323779 (closed) for more details.

Database migration output

down

$ brake db:migrate:down VERSION=20210608110760
== 20210608110760 AddRequirementTestReportsForeignKey: reverting ==============
-- execute("ALTER TABLE requirements_management_test_reports\nDROP CONSTRAINT IF EXISTS requirements_test_reports_requirement_id_xor_issue_id\n")
   -> 0.0008s
-- foreign_keys(:requirements_management_test_reports)
   -> 0.0025s
-- remove_foreign_key(:requirements_management_test_reports, {:column=>:issue_id})
   -> 0.0028s
== 20210608110760 AddRequirementTestReportsForeignKey: reverted (0.0127s) =====
$ brake db:migrate:down VERSION=20210608110752
== 20210608110752 ChangeColumnNullTestReportRequirement: reverting ============
== 20210608110752 ChangeColumnNullTestReportRequirement: reverted (0.0000s) ===
$ brake db:migrate:down VERSION=20210608103235
== 20210608103235 AddIssueIndexToTestReport: reverting ========================
-- transaction_open?()
   -> 0.0000s
-- indexes(:requirements_management_test_reports)
   -> 0.0023s
-- execute("SET statement_timeout TO 0")
   -> 0.0004s
-- remove_index(:requirements_management_test_reports, {:algorithm=>:concurrently, :name=>"index_requirements_management_test_reports_on_issue_id"})
   -> 0.0018s
-- execute("RESET ALL")
   -> 0.0004s
== 20210608103235 AddIssueIndexToTestReport: reverted (0.0058s) ===============
$ brake db:migrate:down VERSION=20210608103230
== 20210608103230 AddIssueIdToTestReport: reverting ===========================
-- remove_column(:requirements_management_test_reports, :issue_id)
   -> 0.0007s
== 20210608103230 AddIssueIdToTestReport: reverted (0.0042s) ==================

up

== 20210608103230 AddIssueIdToTestReport: migrating ===========================
-- add_column(:requirements_management_test_reports, :issue_id, :bigint, {:null=>true})
   -> 0.0021s
== 20210608103230 AddIssueIdToTestReport: migrated (0.0057s) ==================

== 20210608103235 AddIssueIndexToTestReport: migrating ========================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:requirements_management_test_reports, :issue_id, {:name=>"index_requirements_management_test_reports_on_issue_id", :algorithm=>:concurrently})
   -> 0.0027s
-- execute("SET statement_timeout TO 0")
   -> 0.0006s
-- add_index(:requirements_management_test_reports, :issue_id, {:name=>"index_requirements_management_test_reports_on_issue_id", :algorithm=>:concurrently})
   -> 0.0053s
-- execute("RESET ALL")
   -> 0.0004s
== 20210608103235 AddIssueIndexToTestReport: migrated (0.0098s) ===============

== 20210608110752 ChangeColumnNullTestReportRequirement: migrating ============
-- change_column_null(:requirements_management_test_reports, :requirement_id, true)
   -> 0.0005s
== 20210608110752 ChangeColumnNullTestReportRequirement: migrated (0.0028s) ===

== 20210608110760 AddRequirementTestReportsForeignKey: migrating ==============
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:requirements_management_test_reports)
   -> 0.0020s
-- execute("ALTER TABLE requirements_management_test_reports\nADD CONSTRAINT fk_88f30752fc\nFOREIGN KEY (issue_id)\nREFERENCES issues (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0045s
-- execute("ALTER TABLE requirements_management_test_reports VALIDATE CONSTRAINT fk_88f30752fc;")
   -> 0.0081s
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0002s
-- execute("ALTER TABLE requirements_management_test_reports\nADD CONSTRAINT requirements_test_reports_requirement_id_xor_issue_id\nCHECK ( num_nonnulls(requirement_id, issue_id) = 1 )\nNOT VALID;\n")
   -> 0.0006s
-- current_schema()
   -> 0.0001s
-- execute("ALTER TABLE requirements_management_test_reports VALIDATE CONSTRAINT requirements_test_reports_requirement_id_xor_issue_id;")
   -> 0.0009s
== 20210608110760 AddRequirementTestReportsForeignKey: migrated (0.0239s) =====

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • [-] 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 #323779 (closed)

Edited by charlie ablett

Merge request reports