Lead fehler

This commit is contained in:
Timo Knuth 2026-01-16 16:49:27 +01:00
parent af1c0456d7
commit 0eafe421d2
4 changed files with 49 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 KiB

34
scripts/verify-lead-db.ts Normal file
View File

@ -0,0 +1,34 @@
import { db } from '../src/lib/db';
async function main() {
try {
console.log('Verifying Lead model...');
// Type assertion to bypass potential type generation issues locally if they exist
const leadCount = await (db as any).lead.count();
console.log(`Current lead count: ${leadCount}`);
const testLead = await (db as any).lead.create({
data: {
email: 'test_verify@example.com',
source: 'verification-script',
reprintCost: 100,
updatesPerYear: 12,
annualSavings: 1200,
},
});
console.log('Successfully created test lead:', testLead.id);
// Clean up
await (db as any).lead.delete({
where: { id: testLead.id }
});
console.log('Successfully deleted test lead');
} catch (error) {
console.error('Verification failed:', error);
process.exit(1);
}
}
main();

View File

@ -1,5 +1,6 @@
import { NextResponse } from 'next/server'; import { NextResponse } from 'next/server';
import { db } from '@/lib/db'; import { db } from '@/lib/db';
import { Prisma } from '@prisma/client';
interface LeadInput { interface LeadInput {
email: string; email: string;
@ -37,6 +38,20 @@ export async function POST(request: Request) {
return NextResponse.json({ success: true, id: lead.id }); return NextResponse.json({ success: true, id: lead.id });
} catch (error) { } catch (error) {
console.error('Error saving lead:', error); console.error('Error saving lead:', error);
if (error instanceof Prisma.PrismaClientKnownRequestError) {
if (error.code === 'P2021') {
console.error('CRITICAL: Table "Lead" does not exist in the database. Run "npx prisma migrate deploy" to fix this.');
return NextResponse.json(
{
error: 'Database configuration error',
details: 'Missing database table. Please run migrations.'
},
{ status: 500 }
);
}
}
// Return the actual error message for debugging purposes // Return the actual error message for debugging purposes
return NextResponse.json( return NextResponse.json(
{ {

BIN
verify_output.txt Normal file

Binary file not shown.