From 6a38335cc7a2ef8b7f56269d998af7f51446cfb1 Mon Sep 17 00:00:00 2001 From: Yee Hing Tong Date: Tue, 26 Mar 2024 13:38:03 -0700 Subject: [PATCH] Migration for backfill of new launch plan column (#172) The artifact trigger work previously prompted the decision to merge the notion of schedules and artifacts together into a launch plan trigger concept, a [new column](https://github.com/unionai/flyte/pull/83/files#diff-7189b1a0f8ed581ca15085037de7cd70b60305b90e42cc60f7eda13796577788R1227) for which was added to the launch plans table that would indicate whether the trigger type for a launch plan was a schedule or an artifact trigger. This adds a backfill migration to admin. Signed-off-by: Yee Hing Tong --- flyteadmin/pkg/repositories/config/migrations.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/flyteadmin/pkg/repositories/config/migrations.go b/flyteadmin/pkg/repositories/config/migrations.go index 345ac21a76..3adf87af2f 100644 --- a/flyteadmin/pkg/repositories/config/migrations.go +++ b/flyteadmin/pkg/repositories/config/migrations.go @@ -1293,6 +1293,22 @@ var ContinuedMigrations = []*gormigrate.Migration{ return tx.Table("launch_plans").Migrator().DropColumn(&models.LaunchPlan{}, "launch_condition_type") }, }, + { + ID: "pg-continue-2024-03-backfill-launch-conditions", + Migrate: func(tx *gorm.DB) error { + query := `` + + `UPDATE launch_plans ` + + `SET launch_condition_type = 'SCHED' ` + + `WHERE schedule_type in ('CRON', 'RATE') ` + + ` AND launch_condition_type is null` + tx.Exec(query) + + return tx.Error + }, + Rollback: func(tx *gorm.DB) error { + return nil + }, + }, } var Migrations = append(LegacyMigrations, append(NoopMigrations, append(ContinuedMigrations, UnionMigrations...)...)...)