102 lines
3.9 KiB
Plaintext
102 lines
3.9 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
model Quote {
|
|
id Int @id @default(autoincrement())
|
|
uuid String @unique @default(uuid())
|
|
supplierId Int @map("supplier_id")
|
|
supplier Supplier @relation(fields: [supplierId], references: [id], onDelete: Cascade)
|
|
productId Int @map("product_id")
|
|
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
status String @default("active") @db.VarChar(20)
|
|
quantity Decimal @db.Decimal(12, 2)
|
|
unit String @default("ton") @db.VarChar(20)
|
|
pricePerUnit Decimal @map("price_per_unit") @db.Decimal(12, 2)
|
|
currency String @default("USD") @db.VarChar(10)
|
|
incotermsCode String? @map("incoterms_code") @db.VarChar(20)
|
|
originPointUuid String? @map("origin_point_uuid") @db.VarChar(100)
|
|
originName String? @map("origin_name") @db.VarChar(255)
|
|
validUntil DateTime? @map("valid_until") @db.Date
|
|
notes String?
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@index([status, productId, createdAt])
|
|
@@index([supplierId, createdAt])
|
|
@@map("exchange_quotes")
|
|
}
|
|
|
|
model Supplier {
|
|
id Int @id @default(autoincrement())
|
|
uuid String @unique @default(uuid())
|
|
teamUuid String? @unique @map("team_uuid") @db.VarChar(100)
|
|
name String @db.VarChar(255)
|
|
description String?
|
|
country String @default("") @db.VarChar(100)
|
|
countryCode String @default("") @map("country_code") @db.VarChar(10)
|
|
logoUrl String? @map("logo_url") @db.VarChar(500)
|
|
isVerified Boolean @default(false) @map("is_verified")
|
|
isActive Boolean @default(true) @map("is_active")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
quotes Quote[]
|
|
|
|
@@index([countryCode, isActive])
|
|
@@map("exchange_suppliers")
|
|
}
|
|
|
|
model Product {
|
|
id Int @id @default(autoincrement())
|
|
uuid String @unique @default(uuid())
|
|
sku String? @unique @db.VarChar(100)
|
|
name String @db.VarChar(255)
|
|
categoryName String @default("") @map("category_name") @db.VarChar(255)
|
|
unit String @default("ton") @db.VarChar(20)
|
|
imageUrl String? @map("image_url") @db.VarChar(500)
|
|
description String?
|
|
isActive Boolean @default(true) @map("is_active")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
quotes Quote[]
|
|
|
|
@@index([categoryName, isActive])
|
|
@@map("exchange_products")
|
|
}
|
|
|
|
model CurrencyRateSnapshot {
|
|
id Int @id @default(autoincrement())
|
|
uuid String @unique @default(uuid())
|
|
baseCurrency String @map("base_currency") @db.VarChar(3)
|
|
effectiveDate DateTime @map("effective_date") @db.Date
|
|
quotedAt DateTime @map("quoted_at")
|
|
nextUpdateAt DateTime? @map("next_update_at")
|
|
provider String @db.VarChar(255)
|
|
documentation String @db.VarChar(500)
|
|
termsOfUse String @map("terms_of_use") @db.VarChar(500)
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
rates CurrencyRate[]
|
|
|
|
@@unique([baseCurrency, effectiveDate])
|
|
@@index([effectiveDate])
|
|
@@map("exchange_currency_rate_snapshots")
|
|
}
|
|
|
|
model CurrencyRate {
|
|
id Int @id @default(autoincrement())
|
|
snapshotId Int @map("snapshot_id")
|
|
snapshot CurrencyRateSnapshot @relation(fields: [snapshotId], references: [id], onDelete: Cascade)
|
|
quoteCurrency String @map("quote_currency") @db.VarChar(3)
|
|
rate Decimal @db.Decimal(24, 10)
|
|
|
|
@@unique([snapshotId, quoteCurrency])
|
|
@@index([quoteCurrency])
|
|
@@map("exchange_currency_rates")
|
|
}
|