feat(parcel-sync): native PostGIS geometry support for QGIS

- Remove postgresqlExtensions/postgis from Prisma schema (PostGIS not yet installed)
- Add prisma/postgis-setup.sql: trigger auto-converts GeoJSON→native geometry,
  GiST spatial index, QGIS-friendly views (gis_terenuri, gis_cladiri, etc.)
- Add POST /api/eterra/setup-postgis endpoint (idempotent, runs all SQL setup)
- Add safety-net raw SQL in sync-service: backfills geom after upsert phase
- Add QGIS/PostGIS setup card in layer catalog UI with connection info
- Schema comment documents the trigger-managed 'geom' column approach
This commit is contained in:
AI Assistant
2026-03-07 10:25:30 +02:00
parent b0c4bf91d7
commit 0d0b1f8c9f
5 changed files with 433 additions and 15 deletions
@@ -221,6 +221,17 @@ export async function syncLayer(
});
}
// Populate native PostGIS geometry (safety net if trigger not installed)
try {
await prisma.$executeRaw`
UPDATE "GisFeature"
SET geom = ST_SetSRID(ST_GeomFromGeoJSON(geometry::text), 3844)
WHERE "layerId" = ${layerId} AND siruta = ${siruta}
AND geometry IS NOT NULL AND geom IS NULL`;
} catch {
// PostGIS not available yet — not critical, skip silently
}
// Mark removed features
if (removedObjIds.length > 0) {
push({ phase: "Marcare șterse" });