From 60889f16a1067cd658e862915e8bdaa631dfa539 Mon Sep 17 00:00:00 2001 From: Narendran Date: Wed, 17 Dec 2025 17:50:53 +0530 Subject: [PATCH 1/3] Add `stage_name` to `ci_finished_builds` ClickHouse table Changelog: added --- db/click_house/main.sql | 3 ++- ...0727_add_stage_name_to_ci_finished_builds.rb | 17 +++++++++++++++++ .../schema_migrations/main/20251217120727 | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db/click_house/migrate/main/20251217120727_add_stage_name_to_ci_finished_builds.rb create mode 100644 db/click_house/schema_migrations/main/20251217120727 diff --git a/db/click_house/main.sql b/db/click_house/main.sql index 67acb69d9d3def..063250661b59e8 100644 --- a/db/click_house/main.sql +++ b/db/click_house/main.sql @@ -70,6 +70,7 @@ CREATE TABLE ci_finished_builds `date` Date32 MATERIALIZED toStartOfMonth(finished_at), `runner_owner_namespace_id` UInt64 DEFAULT 0, `stage_id` UInt64 DEFAULT 0, + `stage_name` String DEFAULT '', PROJECTION build_stats_by_project_pipeline_name_stage ( SELECT @@ -2386,4 +2387,4 @@ AS SELECT _siphon_replicated_at AS version, _siphon_deleted AS deleted FROM siphon_label_links -WHERE (target_type = 'Issue') AND (target_id IS NOT NULL) AND (label_id IS NOT NULL) \ No newline at end of file +WHERE (target_type = 'Issue') AND (target_id IS NOT NULL) AND (label_id IS NOT NULL) diff --git a/db/click_house/migrate/main/20251217120727_add_stage_name_to_ci_finished_builds.rb b/db/click_house/migrate/main/20251217120727_add_stage_name_to_ci_finished_builds.rb new file mode 100644 index 00000000000000..f245bfaa598436 --- /dev/null +++ b/db/click_house/migrate/main/20251217120727_add_stage_name_to_ci_finished_builds.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddStageNameToCiFinishedBuilds < ClickHouse::Migration + def up + execute <<~SQL + ALTER TABLE ci_finished_builds + ADD COLUMN IF NOT EXISTS `stage_name` String DEFAULT '' + SQL + end + + def down + execute <<~SQL + ALTER TABLE ci_finished_builds + DROP COLUMN IF EXISTS `stage_name` + SQL + end +end diff --git a/db/click_house/schema_migrations/main/20251217120727 b/db/click_house/schema_migrations/main/20251217120727 new file mode 100644 index 00000000000000..c2ac88d684973b --- /dev/null +++ b/db/click_house/schema_migrations/main/20251217120727 @@ -0,0 +1 @@ +ca0f604dbea1f48e75b9bc81e0c68e6f1175d0cc6661c09f74cc7219ac37d61f \ No newline at end of file -- GitLab From 7a6a1ec622481f69c0e9fbb13d2dc9bd5b6daa10 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Thu, 18 Dec 2025 09:49:54 +0100 Subject: [PATCH 2/3] Apply 1 suggestion(s) to 1 file(s) --- .../20251217120727_add_stage_name_to_ci_finished_builds.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/click_house/migrate/main/20251217120727_add_stage_name_to_ci_finished_builds.rb b/db/click_house/migrate/main/20251217120727_add_stage_name_to_ci_finished_builds.rb index f245bfaa598436..ea3c8906930df2 100644 --- a/db/click_house/migrate/main/20251217120727_add_stage_name_to_ci_finished_builds.rb +++ b/db/click_house/migrate/main/20251217120727_add_stage_name_to_ci_finished_builds.rb @@ -10,8 +10,8 @@ def up def down execute <<~SQL - ALTER TABLE ci_finished_builds - DROP COLUMN IF EXISTS `stage_name` + ALTER TABLE ci_finished_builds + DROP COLUMN IF EXISTS `stage_name` SQL end end -- GitLab From 5f7b2028dd0a81d44612d09d11e2ed942a1f773d Mon Sep 17 00:00:00 2001 From: Narendran Date: Thu, 18 Dec 2025 15:36:56 +0530 Subject: [PATCH 3/3] Fix rspec failure --- db/click_house/main.sql | 2 +- .../data_ingestion/ci_finished_builds_sync_service_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/db/click_house/main.sql b/db/click_house/main.sql index 063250661b59e8..8e15abce6662d1 100644 --- a/db/click_house/main.sql +++ b/db/click_house/main.sql @@ -2387,4 +2387,4 @@ AS SELECT _siphon_replicated_at AS version, _siphon_deleted AS deleted FROM siphon_label_links -WHERE (target_type = 'Issue') AND (target_id IS NOT NULL) AND (label_id IS NOT NULL) +WHERE (target_type = 'Issue') AND (target_id IS NOT NULL) AND (label_id IS NOT NULL) \ No newline at end of file diff --git a/ee/spec/services/click_house/data_ingestion/ci_finished_builds_sync_service_spec.rb b/ee/spec/services/click_house/data_ingestion/ci_finished_builds_sync_service_spec.rb index d9d851e16bd8e7..57656ed45d71ae 100644 --- a/ee/spec/services/click_house/data_ingestion/ci_finished_builds_sync_service_spec.rb +++ b/ee/spec/services/click_house/data_ingestion/ci_finished_builds_sync_service_spec.rb @@ -271,6 +271,7 @@ def expected_build_attributes(build) date: build.finished_at.beginning_of_month, name: build.name || '', stage_id: build.stage_id || 0, + stage_name: '', root_namespace_id: build.project.root_namespace.id, runner_id: runner&.id || 0, runner_type: Ci::Runner.runner_types.fetch(runner&.runner_type, 0), -- GitLab