add schemas for DB (#8)
Co-authored-by: OxSaitama <arnaud.daubernatali@smart-chain.fr>
This commit is contained in:
parent
ad4f692732
commit
41a8f67da2
@ -5,7 +5,7 @@ import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
@Service()
|
||||
export default class TezosLink {
|
||||
export default class Database {
|
||||
protected readonly dbProvider: DbProvider;
|
||||
constructor() {
|
||||
this.dbProvider = new DbProvider({
|
@ -6,29 +6,310 @@ generator client {
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
url = env("DEV_PRISMA_STUDIO_DB_URL")
|
||||
}
|
||||
|
||||
model Project {
|
||||
id Int @default(autoincrement()) @id
|
||||
title String @db.VarChar(255)
|
||||
uuid String @unique @db.VarChar(255)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
network String @db.VarChar(255)
|
||||
Metrics Metric[]
|
||||
@@map("app_projects")
|
||||
// Entités -> snake_case
|
||||
// table -> CamelCase
|
||||
|
||||
// Models au sein de la Database (Prisma)
|
||||
// Permet d'utiliser du cable_case dans les tables et du SnakeCase dans les models
|
||||
// id String @unique @default(auto()) @map("_id") @db.ObjectId // @map de la table checker le naming avec le tiret
|
||||
|
||||
model Addresses {
|
||||
uuid String @id @unique @default(uuid())
|
||||
address String @db.VarChar(255)
|
||||
city String @db.VarChar(255)
|
||||
zip_code Int
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
contacts Contacts?
|
||||
office Office?
|
||||
|
||||
@@map("addresses")
|
||||
}
|
||||
|
||||
model Metric {
|
||||
id Int @default(autoincrement()) @id
|
||||
path String @db.VarChar(255)
|
||||
uuid String @unique @db.VarChar(255)
|
||||
remote_address String @db.VarChar(255)
|
||||
date_requested DateTime
|
||||
project Project @relation(fields: [projectId], references: [id])
|
||||
projectId Int
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@map("app_metrics")
|
||||
}
|
||||
model Contacts {
|
||||
uuid String @id @unique @default(uuid())
|
||||
first_name String @db.VarChar(255)
|
||||
last_name String @db.VarChar(255)
|
||||
email String @db.VarChar(255)
|
||||
phone_number String? @db.VarChar(50)
|
||||
cell_phone_number String @db.VarChar(50)
|
||||
civility ECivility @default(MALE)
|
||||
address Addresses @relation(fields: [address_uuid], references: [uuid])
|
||||
address_uuid String @unique @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
users Users?
|
||||
customers Customers?
|
||||
|
||||
@@map("contacts")
|
||||
}
|
||||
|
||||
model Users {
|
||||
uuid String @id @unique @default(uuid())
|
||||
idNot String @unique @db.VarChar(255)
|
||||
contact Contacts @relation(fields: [contact_uuid], references: [uuid])
|
||||
contact_uuid String @unique @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
office_membership Office @relation(fields: [office_uuid], references: [uuid])
|
||||
office_uuid String @db.VarChar(255)
|
||||
user_has_notifications UserHasNotifications[]
|
||||
office_folder_has_stakeholder OfficeFolderHasStakeholder[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model Office {
|
||||
uuid String @id @unique @default(uuid())
|
||||
idNot String @unique @db.VarChar(255)
|
||||
name String @db.VarChar(255)
|
||||
crpcen String @unique @db.VarChar(255)
|
||||
address Addresses @relation(fields: [address_uuid], references: [uuid])
|
||||
address_uuid String @unique @db.VarChar(255)
|
||||
office_status EOfficeStatus @default(DESACTIVATED)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
deed_types DeedTypes[]
|
||||
users Users[]
|
||||
office_folders OfficeFolders[]
|
||||
|
||||
@@map("offices")
|
||||
}
|
||||
|
||||
model Customers {
|
||||
uuid String @id @unique @default(uuid())
|
||||
status ECustomerStatus @default(PENDING)
|
||||
contact Contacts @relation(fields: [contact_uuid], references: [uuid])
|
||||
contact_uuid String @unique @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
office_folder_has_customers OfficeFolderHasCustomers[]
|
||||
documents Documents[]
|
||||
|
||||
@@map("customers")
|
||||
}
|
||||
|
||||
model UserHasNotifications {
|
||||
uuid String @id @unique @default(uuid())
|
||||
user Users @relation(fields: [user_uuid], references: [uuid])
|
||||
user_uuid String @db.VarChar(255)
|
||||
notification Notifications @relation(fields: [notification_uuid], references: [uuid])
|
||||
notification_uuid String @db.VarChar(255)
|
||||
notification_status ENotificationStatus @default(UNREAD)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@map("user_has_notifications")
|
||||
}
|
||||
|
||||
model Notifications {
|
||||
uuid String @id @unique @default(uuid())
|
||||
message String @db.VarChar(255)
|
||||
redirection_url String @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
user_has_notifications UserHasNotifications[]
|
||||
|
||||
@@map("notifications")
|
||||
}
|
||||
|
||||
model OfficeFolders {
|
||||
uuid String @id @unique @default(uuid())
|
||||
folder_number String @db.VarChar(255)
|
||||
name String @db.VarChar(255)
|
||||
description String? @db.VarChar(255)
|
||||
archived_description String? @db.VarChar(255)
|
||||
status EFolderStatus @default(LIVE)
|
||||
deed Deed @relation(fields: [deed_uuid], references: [uuid])
|
||||
deed_uuid String @unique @db.VarChar(255)
|
||||
office Office @relation(fields: [office_uuid], references: [uuid])
|
||||
office_uuid String @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
office_folder_has_customers OfficeFolderHasCustomers[]
|
||||
office_folder_has_stakeholder OfficeFolderHasStakeholder[]
|
||||
documents Documents[]
|
||||
|
||||
@@map("office_folders")
|
||||
}
|
||||
|
||||
model OfficeFolderHasCustomers {
|
||||
uuid String @id @unique @default(uuid())
|
||||
customer Customers @relation(fields: [customer_uuid], references: [uuid])
|
||||
customer_uuid String @db.VarChar(255)
|
||||
office_folder OfficeFolders @relation(fields: [office_folder_uuid], references: [uuid])
|
||||
office_folder_uuid String @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@map("office_folder_has_customers")
|
||||
}
|
||||
|
||||
model OfficeFolderHasStakeholder {
|
||||
uuid String @id @unique @default(uuid())
|
||||
office_folder OfficeFolders @relation(fields: [office_folder_uuid], references: [uuid])
|
||||
office_folder_uuid String @db.VarChar(255)
|
||||
user_stakeholder Users @relation(fields: [user_stakeholder_uuid], references: [uuid])
|
||||
user_stakeholder_uuid String @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@map("office_folder_has_stakeholder")
|
||||
}
|
||||
|
||||
model Documents {
|
||||
uuid String @id @unique @default(uuid())
|
||||
document_status EDocumentStatus @default(ASKED)
|
||||
type DocumentTypes @relation(fields: [type_uuid], references: [uuid])
|
||||
type_uuid String @db.VarChar(255)
|
||||
blockchain_anchor BlockchainAnchors? @relation(fields: [blockchain_anchor_uuid], references: [uuid])
|
||||
blockchain_anchor_uuid String? @db.VarChar(255)
|
||||
folder OfficeFolders @relation(fields: [folder_uuid], references: [uuid])
|
||||
folder_uuid String @db.VarChar(255)
|
||||
depositor Customers @relation(fields: [depositor_uuid], references: [uuid])
|
||||
depositor_uuid String @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
files Files[]
|
||||
document_history DocumentHistory[]
|
||||
|
||||
@@map("documents")
|
||||
}
|
||||
|
||||
model DocumentHistory {
|
||||
uuid String @id @unique @default(uuid())
|
||||
document_history_type EDocumentStatus @default(ASKED)
|
||||
refused_reason String? @db.VarChar(255)
|
||||
document Documents @relation(fields: [document_uuid], references: [uuid])
|
||||
document_uuid String @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@map("document_history")
|
||||
}
|
||||
|
||||
model Files {
|
||||
uuid String @id @unique @default(uuid())
|
||||
document Documents @relation(fields: [document_uuid], references: [uuid])
|
||||
document_uuid String @db.VarChar(255)
|
||||
file_path String? @unique @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@map("files")
|
||||
}
|
||||
|
||||
model BlockchainAnchors {
|
||||
uuid String @id @unique @default(uuid())
|
||||
smartSigJobId String @unique @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
documents Documents[]
|
||||
|
||||
@@map("blockchain_anchors")
|
||||
}
|
||||
|
||||
model DocumentTypes {
|
||||
uuid String @id @unique @default(uuid())
|
||||
name String @db.VarChar(255)
|
||||
public_description String @db.VarChar(255)
|
||||
private_description String @db.VarChar(255)
|
||||
archived_at DateTime?
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
Documents Documents[]
|
||||
deed_has_document_types DeedHasDocumentTypes[]
|
||||
deed_type_has_document_types DeedTypeHasDocumentTypes[]
|
||||
|
||||
@@map("document_types")
|
||||
}
|
||||
|
||||
model DeedHasDocumentTypes {
|
||||
uuid String @id @unique @default(uuid())
|
||||
document_type DocumentTypes @relation(fields: [document_type_uuid], references: [uuid])
|
||||
document_type_uuid String @db.VarChar(255)
|
||||
deed Deed @relation(fields: [deed_uuid], references: [uuid])
|
||||
deed_uuid String @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@map("deed_has_document_types")
|
||||
}
|
||||
|
||||
model Deed {
|
||||
uuid String @id @unique @default(uuid())
|
||||
deed_type DeedTypes @relation(fields: [deed_type_uuid], references: [uuid])
|
||||
deed_type_uuid String @unique @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
deed_has_document_types DeedHasDocumentTypes[]
|
||||
office_folders OfficeFolders[]
|
||||
|
||||
@@map("deed")
|
||||
}
|
||||
|
||||
model DeedTypes {
|
||||
uuid String @id @unique @default(uuid())
|
||||
name String @db.VarChar(255)
|
||||
description String @db.VarChar(255)
|
||||
archived_at DateTime?
|
||||
office Office @relation(fields: [office_uuid], references: [uuid])
|
||||
office_uuid String @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
deed Deed?
|
||||
deed_type_has_document_types DeedTypeHasDocumentTypes[]
|
||||
|
||||
@@map("deed_types")
|
||||
}
|
||||
|
||||
model DeedTypeHasDocumentTypes {
|
||||
uuid String @id @unique @default(uuid())
|
||||
document_type DocumentTypes @relation(fields: [document_type_uuid], references: [uuid])
|
||||
document_type_uuid String @db.VarChar(255)
|
||||
deed_type DeedTypes @relation(fields: [deed_type_uuid], references: [uuid])
|
||||
deed_type_uuid String @db.VarChar(255)
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
|
||||
@@map("deed_type_has_document_types")
|
||||
}
|
||||
|
||||
// TODO SE RENSEIGNER SUR LES ENUMS
|
||||
enum ECivility {
|
||||
MALE
|
||||
FEMALE
|
||||
OTHERS
|
||||
}
|
||||
|
||||
enum EFolderStatus {
|
||||
LIVE
|
||||
ARCHIVED
|
||||
}
|
||||
|
||||
enum EOfficeStatus {
|
||||
ACTIVATED
|
||||
DESACTIVATED
|
||||
}
|
||||
|
||||
enum ENotificationStatus {
|
||||
READ
|
||||
UNREAD
|
||||
}
|
||||
|
||||
enum ECustomerStatus {
|
||||
VALIDATED
|
||||
PENDING
|
||||
ERRONED
|
||||
}
|
||||
|
||||
enum EDocumentStatus {
|
||||
ASKED
|
||||
DEPOSITED
|
||||
VALIDATED
|
||||
ANCHORED
|
||||
REFUSED
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user