From 960f0c2d17abdaccb264d3f26498ab5b0cdc2251 Mon Sep 17 00:00:00 2001 From: Sean O'Connor Date: Sat, 6 Jun 2026 18:07:35 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20add=20isMigrationApplied=20cases=20for?= =?UTF-8?q?=20migrations=200009=E2=80=930012?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Baseline logic was falling through to false for all migrations after 0008, causing incorrect behaviour on fresh deploys. Now correctly detects api_keys table, time_entry table, invoiceId column, and verification token value column type. Co-Authored-By: Claude Sonnet 4.6 --- src/server/db/migrate.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/server/db/migrate.ts b/src/server/db/migrate.ts index dd566cc..18399a8 100644 --- a/src/server/db/migrate.ts +++ b/src/server/db/migrate.ts @@ -243,6 +243,24 @@ async function isMigrationApplied(client: Pool, tag: string): Promise { if (tag === "0008_payments_recurring_public_links") { return columnExists(client, "public", "beenvoice_invoice", "publicToken"); } + if (tag === "0009_api_keys") { + return tableExists(client, "public", "beenvoice_api_key"); + } + if (tag === "0010_time_entries") { + return tableExists(client, "public", "beenvoice_time_entry"); + } + if (tag === "0011_time_entry_invoice_id") { + return columnExists(client, "public", "beenvoice_time_entry", "invoiceId"); + } + if (tag === "0012_verification_token_value_text") { + const { rows } = await client.query<{ data_type: string }>(` + SELECT data_type FROM information_schema.columns + WHERE table_schema = 'public' + AND table_name = 'beenvoice_verification_token' + AND column_name = 'value' + `); + return rows[0]?.data_type === "text"; + } // Unknown migration — assume not applied so it runs return false; }