From c6475c851e6966cde9bcdc5bf592fba43df09367 Mon Sep 17 00:00:00 2001 From: KoreX Labs Date: Mon, 14 Sep 2026 10:13:02 -0300 Subject: [PATCH] fix(api): clear legacy draft urgency during migration --- .../migrations/1790113800000-f6-1-act-urgency-at-lock.ts | 1 + api-v3/test/unit/f6-3-mobile-act-finding-flow.test.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/api-v3/src/database/migrations/1790113800000-f6-1-act-urgency-at-lock.ts b/api-v3/src/database/migrations/1790113800000-f6-1-act-urgency-at-lock.ts index 8415e80..83dec2e 100644 --- a/api-v3/src/database/migrations/1790113800000-f6-1-act-urgency-at-lock.ts +++ b/api-v3/src/database/migrations/1790113800000-f6-1-act-urgency-at-lock.ts @@ -6,6 +6,7 @@ export class F61ActUrgencyAtLock1790113800000 implements MigrationInterface { public async up(q: QueryRunner): Promise { await q.query(`ALTER TABLE inspection_acts ALTER COLUMN urgency DROP DEFAULT`); await q.query(`ALTER TABLE inspection_acts ALTER COLUMN urgency DROP NOT NULL`); + await q.query(`UPDATE inspection_acts SET urgency=NULL WHERE status='DRAFT'`); } public async down(q: QueryRunner): Promise { diff --git a/api-v3/test/unit/f6-3-mobile-act-finding-flow.test.ts b/api-v3/test/unit/f6-3-mobile-act-finding-flow.test.ts index 7ef413e..4eb200a 100644 --- a/api-v3/test/unit/f6-3-mobile-act-finding-flow.test.ts +++ b/api-v3/test/unit/f6-3-mobile-act-finding-flow.test.ts @@ -61,4 +61,5 @@ test('F6.1 Acta urgency is null while drafting and is persisted atomically at lo assert.match(actsService, /urgency: null/); assert.match(closingService, /urgency=\$2/); assert.match(migration, /ALTER COLUMN urgency DROP NOT NULL/); + assert.match(migration, /SET urgency=NULL WHERE status='DRAFT'/); });