b0927ee075
- Rewrite export-bundle to sync-first: check freshness -> sync layers -> enrich (magic) -> build GPKG/CSV from local DB - Rewrite export-layer-gpkg to sync-first: sync if stale -> export from DB - Create enrich-service.ts: extracted magic enrichment logic (CF, owners, addresses) with DB storage - Add enrichment + enrichedAt columns to GisFeature schema - Update PostGIS views to include enrichment data - UI: update button labels for sync-first semantics, refresh sync status after exports - Smart caching: skip sync if data is fresh (168h / 1 week default)
83 lines
2.7 KiB
Plaintext
83 lines
2.7 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
|
|
enrichment Json? // magic data: CF, owners, address, categories, etc.
|
|
enrichedAt DateTime? // when enrichment was last fetched
|
|
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])
|
|
}
|