f6781ab851
- Add geometry (Json), areaValue (Float), lastUpdatedDtm (String) to GisUat model for local caching of UAT boundaries - County refresh now fetches LIMITE_UAT with returnGeometry=true and stores EsriGeometry rings per UAT in EPSG:3844 - Uses LAST_UPDATED_DTM from eTerra for future incremental sync - Skips geometry fetch if >50% already have geometry stored Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
118 lines
4.0 KiB
Plaintext
118 lines
4.0 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); negative for no-geometry parcels (= -immovablePk)
|
|
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)
|
|
geometrySource String? // null = normal GIS sync, "NO_GEOMETRY" = eTerra immovable without GIS geometry
|
|
// 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])
|
|
@@index([geometrySource])
|
|
}
|
|
|
|
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?
|
|
geometry Json? /// EsriGeometry { rings: number[][][] } in EPSG:3844
|
|
areaValue Float? /// Area in sqm from LIMITE_UAT AREA_VALUE field
|
|
lastUpdatedDtm String? /// LAST_UPDATED_DTM from eTerra — for incremental sync
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([name])
|
|
@@index([county])
|
|
}
|
|
|
|
// ─── Registratura: Atomic Sequences + Audit ────────────────────────
|
|
|
|
model RegistrySequence {
|
|
id String @id @default(uuid())
|
|
company String // B, U, S, G (single-letter prefix)
|
|
year Int
|
|
type String // SEQ (shared across directions)
|
|
lastSeq Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([company, year, type])
|
|
@@index([company, year])
|
|
}
|
|
|
|
model RegistryAudit {
|
|
id String @id @default(uuid())
|
|
entryId String
|
|
entryNumber String
|
|
action String // created, updated, reserved_created, reserved_claimed, late_registration, closed, deleted
|
|
actor String
|
|
actorName String?
|
|
company String
|
|
detail Json?
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([entryId])
|
|
@@index([company, createdAt])
|
|
}
|