Skip to content

Add default branch to ci_daily_build_group_report_result

Max Orefice requested to merge mo-add-default-branch-to-daily-build into master

Part of #231386 (closed)

Following up !44472 (merged)

What does this MR do?

This MR adds a new column default_branch to our ci_daily_build_group_report_result table.

Why are we doing this?

Today it's a pain to fetch our coverage data per project and filter out our coverage for the project default branch.

To solve this problem, the team decided to add a new column which will help us to query coverage for our default branch in a simple way.

How the feature looks like?

You can visualize how this feature looks like on the mocks.

Database Review

-----Click here for supplemental database review materials------

Up migration output: Column creation

$ bin/rails db:migrate
== 20201019152046 AddDefaultBranchToDailyBuildGroupReportResult: migrating ====
-- add_column(:ci_daily_build_group_report_results, :default_branch, :boolean, {:default=>false, :null=>false})
   -> 0.0034s
== 20201019152046 AddDefaultBranchToDailyBuildGroupReportResult: migrated (0.0035s)

$ bin/rails dbconsole
psql (11.7)
Type "help" for help.

gitlabhq_development=# \d ci_pipeline_artifacts
                                 Table "public.ci_daily_build_group_report_results"
      Column      |  Type  | Collation | Nullable |                             Default
------------------+--------+-----------+----------+-----------------------------------------------------------------
 id               | bigint |           | not null | nextval('ci_daily_build_group_report_results_id_seq'::regclass)
 date             | date   |           | not null |
 project_id       | bigint |           | not null |
 last_pipeline_id | bigint |           | not null |
 ref_path         | text   |           | not null |
 group_name       | text   |           | not null |
 data             | jsonb  |           | not null |
 default_branch   | boolean|           | not null | false
Indexes:
    "ci_daily_build_group_report_results_pkey" PRIMARY KEY, btree (id)
    "index_daily_build_group_report_results_unique_columns" UNIQUE, btree (project_id, ref_path, date, group_name)
    "index_ci_daily_build_group_report_results_on_last_pipeline_id" btree (last_pipeline_id)
Foreign-key constraints:
    "fk_rails_0667f7608c" FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
    "fk_rails_ee072d13b3" FOREIGN KEY (last_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE

Rollback column creation

$ bin/rails db:rollback
== 20201019152046 AddDefaultBranchToDailyBuildGroupReportResult: reverting ====
-- remove_column(:ci_daily_build_group_report_results, :default_branch, :boolean, {:default=>false, :null=>false})
   -> 0.0012s
== 20201019152046 AddDefaultBranchToDailyBuildGroupReportResult: reverted (0.0047s)

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 Max Orefice

Merge request reports