From 82694c35dedc1f34d87aac3314d373ee5277e380 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Fri, 12 Jun 2026 11:54:15 +0300 Subject: [PATCH] appview/db: add migration to fix incorrect pipeline statuses fixes duplications in our DB from an unfortunate spindle deploy. on the offchance that there are other spindle instances out there that deployed master, this should fix all ingested statuses. Signed-off-by: oppiliappan --- appview/db/db.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/appview/db/db.go b/appview/db/db.go index 18559b5b..39689e42 100644 --- a/appview/db/db.go +++ b/appview/db/db.go @@ -2192,6 +2192,22 @@ func Make(ctx context.Context, dbPath string) (*DB, error) { return err }) + orm.RunMigration(conn, logger, "delete-unused-pipeline-statuses", func(tx *sql.Tx) error { + _, err := tx.Exec(` + delete from pipeline_statuses as p + where p.status = 'pending' + and exists ( + select 1 from pipeline_statuses as q + where q.pipeline_knot = p.pipeline_knot + and q.pipeline_rkey = p.pipeline_rkey + and q.workflow = p.workflow + and q.status = 'pending' + and q.created < p.created + ); + `) + return err + }) + return &DB{ db, logger, -- 2.51.2