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:
@@ -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`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user