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? updatedAt DateTime @updatedAt @@index([name]) }