a0dd35a066
Registratura module: - Atomic sequence numbering (BTG-2026-IN-00125 format) via PostgreSQL upsert - Reserved monthly slots (2/company/month) for late registrations - Append-only audit trail with diff tracking - REST API: /api/registratura (CRUD), /api/registratura/reserved, /api/registratura/audit - Auth: NextAuth session + Bearer API key support - New "intern" direction type with UI support (form, filters, table, detail panel) - Prisma models: RegistrySequence, RegistryAudit Theme toggle: - SVG mask-based sun/moon morph with 360° spin animation - Inverted logic (sun in dark mode, moon in light mode) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
115 lines
3.7 KiB
Plaintext
115 lines
3.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); 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?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([name])
|
|
@@index([county])
|
|
}
|
|
|
|
// ─── Registratura: Atomic Sequences + Audit ────────────────────────
|
|
|
|
model RegistrySequence {
|
|
id String @id @default(uuid())
|
|
company String // BTG, SDT, USW, GRP
|
|
year Int
|
|
type String // IN, OUT, INT
|
|
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])
|
|
}
|