0d0b1f8c9f
- 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
81 lines
2.5 KiB
Plaintext
81 lines
2.5 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model KeyValueStore {
|
|
id String @id @default(uuid())
|
|
namespace String
|
|
key String
|
|
value Json
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([namespace, key])
|
|
@@index([namespace])
|
|
}
|
|
|
|
// ─── GIS: eTerra ParcelSync ────────────────────────────────────────
|
|
|
|
model GisFeature {
|
|
id String @id @default(uuid())
|
|
layerId String // e.g. TERENURI_ACTIVE, CLADIRI_ACTIVE
|
|
siruta String
|
|
objectId Int // eTerra OBJECTID (unique per layer)
|
|
inspireId String?
|
|
cadastralRef String? // NATIONAL_CADASTRAL_REFERENCE
|
|
areaValue Float?
|
|
isActive Boolean @default(true)
|
|
attributes Json // all raw eTerra attributes
|
|
geometry Json? // GeoJSON geometry (Polygon/MultiPolygon)
|
|
// NOTE: native PostGIS column 'geom' is managed via SQL trigger (see prisma/postgis-setup.sql)
|
|
// Prisma doesn't need to know about it — trigger auto-populates from geometry JSON
|
|
syncRunId String?
|
|
projectId String? // link to project tag
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
syncRun GisSyncRun? @relation(fields: [syncRunId], references: [id])
|
|
|
|
@@unique([layerId, objectId])
|
|
@@index([siruta])
|
|
@@index([cadastralRef])
|
|
@@index([layerId, siruta])
|
|
@@index([projectId])
|
|
}
|
|
|
|
model GisSyncRun {
|
|
id String @id @default(uuid())
|
|
siruta String
|
|
uatName String?
|
|
layerId String
|
|
status String @default("pending") // pending | running | done | error
|
|
totalRemote Int @default(0)
|
|
totalLocal Int @default(0)
|
|
newFeatures Int @default(0)
|
|
removedFeatures Int @default(0)
|
|
startedAt DateTime @default(now())
|
|
completedAt DateTime?
|
|
errorMessage String?
|
|
features GisFeature[]
|
|
|
|
@@index([siruta])
|
|
@@index([layerId])
|
|
@@index([siruta, layerId])
|
|
}
|
|
|
|
model GisUat {
|
|
siruta String @id
|
|
name String
|
|
county String?
|
|
workspacePk Int?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([name])
|
|
@@index([county])
|
|
}
|