Skip to content

Commit

Permalink
fix: improve error handling for d1
Browse files Browse the repository at this point in the history
  • Loading branch information
ottomated committed Jun 10, 2024
1 parent 42fba8d commit 0961a14
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion template_builder/templates/extras/prisma/{D1}push.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
[
Expand All @@ -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);
Expand Down

0 comments on commit 0961a14

Please sign in to comment.