ec5a866673
- GisUat table now includes workspacePk column (created via raw SQL) - GET /api/eterra/uats serves from PostgreSQL instant, no eTerra login needed - POST /api/eterra/uats triggers sync check: compares county count with DB, only does full eTerra fetch if data differs or DB is empty - Frontend loads UATs from DB on mount (fast), falls back to uat.json if empty - On eTerra connect, fires POST to sync-check; if data changed, reloads from DB - Workspace cache populated from DB on GET for search route performance
81 lines
2.2 KiB
Plaintext
81 lines
2.2 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
previewFeatures = ["postgresqlExtensions"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
extensions = [postgis]
|
|
}
|
|
|
|
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)
|
|
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])
|
|
}
|