fix(geoportal): DROP enrichment views before recreate (column change)

PostgreSQL CREATE OR REPLACE VIEW fails when column structure changes.
Now drops views first, then recreates them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-24 16:21:57 +02:00
parent 0dc5e58b55
commit 3f5eed25f4
@@ -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`);
}