From 0961a1493652cb38bdf669ce8ca0eecb83ac1d81 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Sun, 9 Jun 2024 21:24:05 -0700 Subject: [PATCH] fix: improve error handling for d1 --- template_builder/templates/extras/prisma/{D1}push.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/template_builder/templates/extras/prisma/{D1}push.mjs b/template_builder/templates/extras/prisma/{D1}push.mjs index 5275b56b..a89053df 100644 --- a/template_builder/templates/extras/prisma/{D1}push.mjs +++ b/template_builder/templates/extras/prisma/{D1}push.mjs @@ -31,7 +31,7 @@ try { const schema = resolve(dirname, './schema.prisma'); // 1. Pull current schema -const current = JSON.parse( +const currentRes = JSON.parse( spawnSync( 'npx', [ @@ -47,6 +47,12 @@ const current = JSON.parse( { encoding: 'utf-8' }, ).stdout, )[0].results; +if (currentRes.error) { + console.error(currentRes.error); + console.error('Have you put your database ID in wrangler.toml?'); + process.exit(1); +} +const current = currentRes[0].results; // 2. create dummy db with that schema const db = new Database(tempDb);