From 049f51b56ae299b4c84fdab1500c10eb0f6b4b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Mon, 9 Nov 2026 13:25:52 -0300 Subject: [PATCH] fix: orders from before the PNG print file are generated again, once An order generated before item 13 had a PDF print file and no strips, so the 100% viewer opened it blank. Those still in Arte recebida, with no approved final and no customer correction, are generated again once as PNG with strips (migration png-regenerate-v1). Co-Authored-By: Claude Opus 5.5 --- app/schema.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/schema.sql b/app/schema.sql index 7844c25..b0dbd98 100644 --- a/app/schema.sql +++ b/app/schema.sql @@ -581,3 +581,20 @@ CREATE TABLE IF NOT EXISTS dtf_local.machine_snoozes ( snoozed_by text NOT NULL, snoozed_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY(machine_id, alert, cycle_from) ); + +-- Orders generated before the print file was a PNG with its strips (item 13) +-- open blank in the 100% viewer. Those not approved yet are generated again, +-- once: the same layout, now as PNG with strips. An approved final, a +-- customer's correction or a cancelled order is left as it is. +DO $$ BEGIN + IF NOT EXISTS (SELECT 1 FROM dtf_local.migrations WHERE name='png-regenerate-v1') THEN + UPDATE dtf_local.print_files p SET status='pending', attempts=0, claimed_at=NULL, claim_token=NULL, + finished_at=NULL, upload_id=NULL, detail='{}' + FROM dtf_local.orders o + WHERE o.id=p.order_id AND o.state='rec' AND o.cancelled_at IS NULL + AND p.status='ready' AND NOT (p.detail ? 'format') + AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f WHERE f.order_id=p.order_id + AND f.item_index=p.item_index AND f.active); + INSERT INTO dtf_local.migrations VALUES('png-regenerate-v1'); + END IF; +END $$;