Lead fehler
This commit is contained in:
parent
af1c0456d7
commit
0eafe421d2
Binary file not shown.
|
After Width: | Height: | Size: 726 KiB |
|
|
@ -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();
|
||||||
|
|
@ -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(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue