Skip to content

Commit db9947b

Browse files
committed
Fix missing User table by running migrations before app start
Add a `prestart` script to package.json that runs `prisma migrate deploy` before `next start`, ensuring all database tables exist. Also wrap the informational User lookup in getNonce with a try/catch so nonce generation doesn't fail if the User table is temporarily unavailable. https://claude.ai/code/session_01Y4mDygMY7HNHAJz7GUs5dz
1 parent 81c0242 commit db9947b

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"dev": "next dev",
1515
"postinstall": "prisma generate",
1616
"lint": "next lint",
17+
"prestart": "prisma migrate deploy",
1718
"start": "next start",
1819
"test": "jest",
1920
"test:watch": "jest --watch",

src/pages/api/v1/getNonce.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ export default async function handler(
3030

3131
// Log whether the address has a corresponding user, but don't block nonce issuance.
3232
// This allows first-time wallet connections to authorize via nonce signing.
33-
const user = await db.user.findUnique({ where: { address } });
34-
if (!user) {
35-
console.warn("[getNonce] Address has no User record yet:", address);
36-
} else {
37-
console.debug("[getNonce] Found User for address:", {
38-
address,
39-
userId: user.id,
40-
});
33+
try {
34+
const user = await db.user.findUnique({ where: { address } });
35+
if (!user) {
36+
console.warn("[getNonce] Address has no User record yet:", address);
37+
} else {
38+
console.debug("[getNonce] Found User for address:", {
39+
address,
40+
userId: user.id,
41+
});
42+
}
43+
} catch (userLookupError) {
44+
console.warn("[getNonce] User lookup failed (table may not exist yet):", (userLookupError as Error).message);
4145
}
4246

4347
// Check if a nonce already exists for this address in the database

0 commit comments

Comments
 (0)