From 889ba145c6510a327631ca6c77d5a84aec1a2d5d Mon Sep 17 00:00:00 2001 From: pkanellidis Date: Wed, 10 Sep 2025 11:47:51 +0300 Subject: [PATCH 1/4] Add last_scheduled_run_at column Adds the column to track scheduled runs and avoid duplicate creations due to deduplication issues Changelog: other --- ...last_scheduled_run_at_to_ci_pipeline_schedules.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb diff --git a/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb b/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb new file mode 100644 index 00000000000000..de58775b2be3f8 --- /dev/null +++ b/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddLastScheduledRunAtToCiPipelineSchedules < Gitlab::Database::Migration[2.3] + milestone '18.4' + + def change + add_column :ci_pipeline_schedules, :last_scheduled_run_at, :datetime_with_timezone + end +end -- GitLab From 540b6eecd34f902c741a338d6babd02b42db187b Mon Sep 17 00:00:00 2001 From: pkanellidis Date: Wed, 10 Sep 2025 11:48:30 +0300 Subject: [PATCH 2/4] Remove redundant comments Changelog: other --- ...83751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb b/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb index de58775b2be3f8..a930f2d01ce55e 100644 --- a/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb +++ b/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddLastScheduledRunAtToCiPipelineSchedules < Gitlab::Database::Migration[2.3] milestone '18.4' -- GitLab From 3f3cec71afac51ee7735c082a131f46c1b2e7cb9 Mon Sep 17 00:00:00 2001 From: pkanellidis Date: Wed, 10 Sep 2025 12:36:47 +0300 Subject: [PATCH 3/4] Remove column timezone Changelog: other --- ...751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb | 5 ++++- db/schema_migrations/20250910083751 | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 db/schema_migrations/20250910083751 diff --git a/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb b/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb index a930f2d01ce55e..3a44b10634a6df 100644 --- a/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb +++ b/db/migrate/20250910083751_add_last_scheduled_run_at_to_ci_pipeline_schedules.rb @@ -3,7 +3,10 @@ class AddLastScheduledRunAtToCiPipelineSchedules < Gitlab::Database::Migration[2.3] milestone '18.4' + # rubocop:disable Migration/Datetime -- We are keeping it the same as next_run_at + # which doesn't include the timezone. def change - add_column :ci_pipeline_schedules, :last_scheduled_run_at, :datetime_with_timezone + add_column :ci_pipeline_schedules, :last_scheduled_run_at, :datetime end + # rubocop:enable Migration/Datetime end diff --git a/db/schema_migrations/20250910083751 b/db/schema_migrations/20250910083751 new file mode 100644 index 00000000000000..5b3fa05ba341e8 --- /dev/null +++ b/db/schema_migrations/20250910083751 @@ -0,0 +1 @@ +3a25dcd53bce2eb8f951d4d9dd5dec114ebad5042ba7a00d964502bfd9878268 \ No newline at end of file -- GitLab From 5816af0512b8ef22ab5329f75320956b74e5479d Mon Sep 17 00:00:00 2001 From: pkanellidis Date: Wed, 10 Sep 2025 12:40:44 +0300 Subject: [PATCH 4/4] Add schema changes Changelog: other --- db/structure.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/structure.sql b/db/structure.sql index 7e64c91d5bd6f2..3ba4d1b25fada9 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -13282,6 +13282,7 @@ CREATE TABLE ci_pipeline_schedules ( active boolean DEFAULT true, created_at timestamp without time zone, updated_at timestamp without time zone, + last_scheduled_run_at timestamp without time zone, CONSTRAINT check_4a0f7b994d CHECK ((project_id IS NOT NULL)) ); -- GitLab