diff --git a/src/app/api/geoportal/setup-enrichment-views/route.ts b/src/app/api/geoportal/setup-enrichment-views/route.ts index f18b946..5229eea 100644 --- a/src/app/api/geoportal/setup-enrichment-views/route.ts +++ b/src/app/api/geoportal/setup-enrichment-views/route.ts @@ -82,11 +82,13 @@ export async function GET() { } } -/** POST — create enrichment views (idempotent) */ +/** POST — create enrichment views (idempotent, drops first if structure changed) */ export async function POST() { const results: string[] = []; try { for (const v of VIEWS) { + // DROP first — CREATE OR REPLACE fails when columns change + await prisma.$executeRawUnsafe(`DROP VIEW IF EXISTS ${v.name} CASCADE`); await prisma.$executeRawUnsafe(v.sql); results.push(`${v.name} OK`); }