190 lines
4.4 KiB
Plaintext
190 lines
4.4 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
// Get a free hosted Postgres database in seconds: `npx create-db`
|
|
|
|
generator client {
|
|
provider = "prisma-client"
|
|
output = "../lib/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
enum Sex {
|
|
MALE
|
|
FEMALE
|
|
}
|
|
|
|
enum EyeColor {
|
|
Blue
|
|
Green
|
|
Brown
|
|
Hazel
|
|
Gray
|
|
Amber
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
kotosoftId String @unique
|
|
email String @unique
|
|
firstName String
|
|
secondName String
|
|
sex Sex
|
|
birthDate DateTime?
|
|
createdAt DateTime @default(now())
|
|
isAdmin Boolean @default(false)
|
|
|
|
pages Page[] @relation("PageAuthor")
|
|
editedPages Page[] @relation("PageEditor")
|
|
|
|
citizenshipApplications CitizenshipApplication[]
|
|
reviewedApplications CitizenshipApplication[] @relation("CitizenshipReviewer")
|
|
|
|
citizenships Citizenship[]
|
|
}
|
|
|
|
enum PageStatus {
|
|
DRAFT
|
|
PUBLISHED
|
|
ARCHIVED
|
|
}
|
|
|
|
enum PageType {
|
|
PAGE
|
|
NEWS
|
|
}
|
|
|
|
model Page {
|
|
id String @id @default(uuid())
|
|
slug String @unique
|
|
title String
|
|
type PageType
|
|
status PageStatus @default(DRAFT)
|
|
meta Json @default("{}")
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
publishedAt DateTime?
|
|
|
|
createdBy String?
|
|
author User? @relation("PageAuthor", fields: [createdBy], references: [id])
|
|
|
|
updatedBy String?
|
|
editor User? @relation("PageEditor", fields: [updatedBy], references: [id])
|
|
|
|
blocks Block[]
|
|
navLinks NavLink[]
|
|
}
|
|
|
|
model Block {
|
|
id String @id @default(uuid())
|
|
pageId String
|
|
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
|
|
parentId String?
|
|
parent Block? @relation("BlockChildren", fields: [parentId], references: [id])
|
|
children Block[] @relation("BlockChildren")
|
|
|
|
type String
|
|
position Float
|
|
content Json
|
|
|
|
@@index([pageId, position])
|
|
}
|
|
|
|
model NavLink {
|
|
id String @id @default(uuid())
|
|
label String?
|
|
order Int
|
|
|
|
pageId String?
|
|
page Page? @relation(fields: [pageId], references: [id], onDelete: SetNull)
|
|
href String?
|
|
}
|
|
|
|
enum CitizenshipApplicationStatus {
|
|
PENDING
|
|
APPROVED
|
|
REJECTED
|
|
}
|
|
|
|
enum ApplicationType {
|
|
PREVIOUS_CITIZENSHIP
|
|
NATURALIZATION
|
|
}
|
|
|
|
model CitizenshipApplication {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
surname String
|
|
givenNames String
|
|
sex Sex
|
|
birthDate DateTime
|
|
applicationType ApplicationType
|
|
previousCountry String?
|
|
previousRegion String?
|
|
naturalizationReason String?
|
|
address String
|
|
regionId String?
|
|
region Region? @relation(fields: [regionId], references: [id])
|
|
city String?
|
|
street String?
|
|
customAddress String?
|
|
height Int
|
|
eyeColor EyeColor
|
|
status CitizenshipApplicationStatus @default(PENDING)
|
|
rejectionReason String?
|
|
reviewedAt DateTime?
|
|
reviewedBy String?
|
|
reviewer User? @relation("CitizenshipReviewer", fields: [reviewedBy], references: [id])
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
profileKey String
|
|
signatureKey String
|
|
citizenship Citizenship?
|
|
}
|
|
|
|
model Citizenship {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
applicationId String @unique
|
|
issuedAt DateTime @default(now())
|
|
revokedAt DateTime?
|
|
|
|
user User @relation(fields: [userId], references: [id])
|
|
application CitizenshipApplication @relation(fields: [applicationId], references: [id])
|
|
identityDocuments IdentityDocument[]
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
model IdentityDocument {
|
|
id String @id @default(uuid())
|
|
citizenshipId String
|
|
citizenship Citizenship @relation(fields: [citizenshipId], references: [id], onDelete: Cascade)
|
|
|
|
documentNumber String @unique
|
|
address String
|
|
|
|
regionId String?
|
|
region Region? @relation(fields: [regionId], references: [id])
|
|
city String?
|
|
street String?
|
|
customAddress String?
|
|
|
|
issuedAt DateTime @default(now())
|
|
expiresAt DateTime
|
|
|
|
@@index([citizenshipId, issuedAt])
|
|
}
|
|
|
|
model Region {
|
|
id String @id
|
|
name String
|
|
capital String
|
|
documents IdentityDocument[]
|
|
applications CitizenshipApplication[]
|
|
} |