mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-11 22:30:59 +04:30
Ship legacy migrate APIs, portfolio/blog old-id schema, and admin migrate/purge flows.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
7244b70e90
commit
4598add88c
+208
-200
@@ -20,8 +20,8 @@ model User {
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
profile Json @default("{}")
|
||||
oldId BigInt? @map("old_id")
|
||||
addresses Address[]
|
||||
blogs blogs[]
|
||||
businessCustomers BusinessCustomer[]
|
||||
businessUsersInvited BusinessUser[] @relation("BusinessInviter")
|
||||
businessUsers BusinessUser[] @relation("BusinessMember")
|
||||
@@ -29,6 +29,7 @@ model User {
|
||||
commentsApproved Comment[] @relation("CommentApprover")
|
||||
expertReviewsApproved ExpertReview[] @relation("ExpertReviewApprover")
|
||||
favorites Favorite[]
|
||||
invoicesIssued Invoice[] @relation("InvoiceIssuer")
|
||||
mediaUploaded Media[]
|
||||
ordersCreated Order[] @relation("OrderCreator")
|
||||
orders Order[] @relation("OrderCustomer")
|
||||
@@ -36,8 +37,9 @@ model User {
|
||||
shoppingCards ShoppingCard[] @relation("ShoppingCardCustomer")
|
||||
transactionsCreated Transaction[] @relation("TransactionCreator")
|
||||
transactions Transaction[] @relation("TransactionCustomer")
|
||||
invoicesIssued Invoice[] @relation("InvoiceIssuer")
|
||||
userRoles UserRole[]
|
||||
authoredBlogs blogs[] @relation("BlogAuthor")
|
||||
authoredPortfolios portfolios[] @relation("PortfolioAuthor")
|
||||
|
||||
@@index([cellNumber], map: "idx_users_cell_number")
|
||||
@@map("users")
|
||||
@@ -60,14 +62,15 @@ model Business {
|
||||
socialMedia Json @default("{}") @map("social_media")
|
||||
logoMediaId BigInt? @map("logo_media_id")
|
||||
faviconMediaId BigInt? @map("favicon_media_id")
|
||||
oldBusinessId BigInt? @map("old_business_id")
|
||||
addresses Address[]
|
||||
blogs blogs[]
|
||||
brands Brand[]
|
||||
categoryAssignments BusinessCategoryAssignment[]
|
||||
businessCustomers BusinessCustomer[]
|
||||
businessUsers BusinessUser[]
|
||||
logoMedia Media? @relation("BusinessLogo", fields: [logoMediaId], references: [id], onUpdate: NoAction)
|
||||
faviconMedia Media? @relation("BusinessFavicon", fields: [faviconMediaId], references: [id], onUpdate: NoAction)
|
||||
logoMedia Media? @relation("BusinessLogo", fields: [logoMediaId], references: [id], onUpdate: NoAction)
|
||||
carts Cart[]
|
||||
categories Category[]
|
||||
contentCategoryAssignments CategoryAssignment[]
|
||||
@@ -78,6 +81,10 @@ model Business {
|
||||
domains Domain[]
|
||||
expertReviews ExpertReview[]
|
||||
favorites Favorite[]
|
||||
invoiceItemTemplates InvoiceItemTemplate[]
|
||||
invoiceTemplates InvoiceTemplate[]
|
||||
invoices Invoice[] @relation("InvoiceBusiness")
|
||||
invoicesIssued Invoice[] @relation("InvoiceIssuerBusiness")
|
||||
media Media[]
|
||||
mediaAttachments MediaAttachment[]
|
||||
orders Order[]
|
||||
@@ -89,10 +96,6 @@ model Business {
|
||||
storeItems StoreItem[]
|
||||
storeSpecials StoreSpecial[]
|
||||
transactions Transaction[]
|
||||
invoices Invoice[] @relation("InvoiceBusiness")
|
||||
invoicesIssued Invoice[] @relation("InvoiceIssuerBusiness")
|
||||
invoiceItemTemplates InvoiceItemTemplate[]
|
||||
invoiceTemplates InvoiceTemplate[]
|
||||
website_brand_groups website_brand_groups[]
|
||||
website_category_groups website_category_groups[]
|
||||
website_sliders website_sliders[]
|
||||
@@ -133,20 +136,20 @@ model BusinessCategoryAssignment {
|
||||
}
|
||||
|
||||
model Domain {
|
||||
id BigInt @id @default(autoincrement())
|
||||
businessId BigInt @map("business_id")
|
||||
host String @unique(map: "domains_host_unique") @db.VarChar(253)
|
||||
isPrimary Boolean @default(false) @map("is_primary")
|
||||
isVerified Boolean @default(false) @map("is_verified")
|
||||
verifiedAt DateTime? @map("verified_at") @db.Timestamptz(6)
|
||||
sslEnabled Boolean @default(false) @map("ssl_enabled")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
expiresAt DateTime? @map("expires_at") @db.Timestamptz(6)
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
lastDeployedAt DateTime? @map("last_deployed_at") @db.Timestamptz(6)
|
||||
lastDeployStatus String? @map("last_deploy_status") @db.VarChar(32)
|
||||
business Business @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
id BigInt @id @default(autoincrement())
|
||||
businessId BigInt @map("business_id")
|
||||
host String @unique(map: "domains_host_unique") @db.VarChar(253)
|
||||
isPrimary Boolean @default(false) @map("is_primary")
|
||||
isVerified Boolean @default(false) @map("is_verified")
|
||||
verifiedAt DateTime? @map("verified_at") @db.Timestamptz(6)
|
||||
sslEnabled Boolean @default(false) @map("ssl_enabled")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
expiresAt DateTime? @map("expires_at") @db.Timestamptz(6)
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
lastDeployedAt DateTime? @map("last_deployed_at") @db.Timestamptz(6)
|
||||
lastDeployStatus String? @map("last_deploy_status") @db.VarChar(32)
|
||||
business Business @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([businessId], map: "idx_domains_business_id")
|
||||
@@index([host], map: "idx_domains_host")
|
||||
@@ -263,10 +266,11 @@ model Media {
|
||||
metadata Json @default("{}")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
oldId BigInt? @map("old_id")
|
||||
blogs blogs[]
|
||||
brandImages Brand[]
|
||||
logoBusinesses Business[] @relation("BusinessLogo")
|
||||
faviconBusinesses Business[] @relation("BusinessFavicon")
|
||||
logoBusinesses Business[] @relation("BusinessLogo")
|
||||
business Business @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
uploader User? @relation(fields: [uploadedBy], references: [id], onUpdate: NoAction)
|
||||
attachments MediaAttachment[]
|
||||
@@ -298,7 +302,7 @@ model MediaAttachment {
|
||||
@@map("media_attachments")
|
||||
}
|
||||
|
||||
model Category {
|
||||
model Category {
|
||||
id BigInt @id @default(autoincrement())
|
||||
businessId BigInt @map("business_id")
|
||||
entityType MediaEntityType @map("entity_type")
|
||||
@@ -311,6 +315,7 @@ model Category {
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
nameFa String? @map("name_fa") @db.VarChar(255)
|
||||
oldId BigInt? @map("old_id")
|
||||
business Business @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
parent Category? @relation("CategoryTree", fields: [parentId], references: [id], onUpdate: NoAction)
|
||||
children Category[] @relation("CategoryTree")
|
||||
@@ -610,7 +615,8 @@ model blogs {
|
||||
created_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
updated_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
post_type BlogPostType @default(blog)
|
||||
users User? @relation(fields: [author_id], references: [id], onUpdate: NoAction)
|
||||
old_id BigInt?
|
||||
author User? @relation("BlogAuthor", fields: [author_id], references: [id], onUpdate: NoAction)
|
||||
businesses Business @relation(fields: [business_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
media Media? @relation(fields: [featured_media_id], references: [id], onUpdate: NoAction)
|
||||
|
||||
@@ -624,7 +630,10 @@ model blogs {
|
||||
model portfolios {
|
||||
id BigInt @id @default(autoincrement())
|
||||
business_id BigInt
|
||||
author_id BigInt?
|
||||
title String @db.VarChar(255)
|
||||
title_fa String? @db.VarChar(255)
|
||||
title_en String? @db.VarChar(255)
|
||||
slug String @db.VarChar(255)
|
||||
description String?
|
||||
content Json @default("{}")
|
||||
@@ -637,6 +646,8 @@ model portfolios {
|
||||
metadata Json @default("{}")
|
||||
created_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
updated_at DateTime @default(now()) @db.Timestamptz(6)
|
||||
old_id BigInt?
|
||||
author User? @relation("PortfolioAuthor", fields: [author_id], references: [id], onUpdate: NoAction, onDelete: SetNull)
|
||||
businesses Business @relation(fields: [business_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
media Media? @relation(fields: [featured_media_id], references: [id], onUpdate: NoAction)
|
||||
|
||||
@@ -644,6 +655,7 @@ model portfolios {
|
||||
@@index([business_id], map: "idx_portfolios_business_id")
|
||||
@@index([business_id, published_at(sort: Desc)], map: "idx_portfolios_business_published")
|
||||
@@index([business_id, status], map: "idx_portfolios_business_status")
|
||||
@@index([author_id], map: "idx_portfolios_author_id")
|
||||
}
|
||||
|
||||
/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info.
|
||||
@@ -651,7 +663,6 @@ model Address {
|
||||
id BigInt @id @default(autoincrement())
|
||||
userId BigInt? @map("user_id")
|
||||
businessId BigInt? @map("business_id")
|
||||
label String? @db.VarChar(100)
|
||||
province String @db.VarChar(100)
|
||||
city String @db.VarChar(100)
|
||||
address String
|
||||
@@ -659,6 +670,7 @@ model Address {
|
||||
landline String? @db.VarChar(30)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
label String? @db.VarChar(100)
|
||||
business Business? @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
orders Order[]
|
||||
@@ -1039,6 +1051,175 @@ model website_sliders {
|
||||
@@index([business_id], map: "idx_website_sliders_business_id")
|
||||
}
|
||||
|
||||
model InvoiceItemTemplate {
|
||||
id BigInt @id @default(autoincrement())
|
||||
ownerScope InvoiceOwnerScope @map("owner_scope")
|
||||
businessId BigInt? @map("business_id")
|
||||
title String @db.VarChar(255)
|
||||
duration String? @db.VarChar(100)
|
||||
worktime String? @db.VarChar(100)
|
||||
description String?
|
||||
price Decimal @default(0) @db.Decimal(12, 2)
|
||||
discountedPrice Decimal? @map("discounted_price") @db.Decimal(12, 2)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
business Business? @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
invoiceItems InvoiceItem[]
|
||||
invoiceTemplateItems InvoiceTemplateItem[]
|
||||
|
||||
@@index([ownerScope, sortOrder], map: "idx_invoice_item_templates_owner_scope")
|
||||
@@map("invoice_item_templates")
|
||||
}
|
||||
|
||||
model InvoiceTemplate {
|
||||
id BigInt @id @default(autoincrement())
|
||||
ownerScope InvoiceOwnerScope @map("owner_scope")
|
||||
businessId BigInt? @map("business_id")
|
||||
name String @db.VarChar(255)
|
||||
topText String? @map("top_text")
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
accounts InvoiceTemplateAccount[]
|
||||
items InvoiceTemplateItem[]
|
||||
keyPoints InvoiceTemplateKeyPoint[]
|
||||
business Business? @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
invoices Invoice[]
|
||||
|
||||
@@index([ownerScope, sortOrder], map: "idx_invoice_templates_owner_scope")
|
||||
@@map("invoice_templates")
|
||||
}
|
||||
|
||||
model InvoiceTemplateItem {
|
||||
id BigInt @id @default(autoincrement())
|
||||
templateId BigInt @map("template_id")
|
||||
itemTemplateId BigInt? @map("item_template_id")
|
||||
title String @db.VarChar(255)
|
||||
duration String? @db.VarChar(100)
|
||||
worktime String? @db.VarChar(100)
|
||||
description String?
|
||||
price Decimal @default(0) @db.Decimal(12, 2)
|
||||
discountedPrice Decimal? @map("discounted_price") @db.Decimal(12, 2)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
itemTemplate InvoiceItemTemplate? @relation(fields: [itemTemplateId], references: [id], onUpdate: NoAction)
|
||||
template InvoiceTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([templateId, sortOrder], map: "idx_invoice_template_items_template_id")
|
||||
@@map("invoice_template_items")
|
||||
}
|
||||
|
||||
model InvoiceTemplateKeyPoint {
|
||||
id BigInt @id @default(autoincrement())
|
||||
templateId BigInt @map("template_id")
|
||||
text String
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
template InvoiceTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([templateId, sortOrder], map: "idx_invoice_template_key_points_template_id")
|
||||
@@map("invoice_template_key_points")
|
||||
}
|
||||
|
||||
model InvoiceTemplateAccount {
|
||||
id BigInt @id @default(autoincrement())
|
||||
templateId BigInt @map("template_id")
|
||||
bankName String @map("bank_name") @db.VarChar(255)
|
||||
cardNumber String? @map("card_number") @db.VarChar(64)
|
||||
iban String? @db.VarChar(64)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
accountHolderName String? @map("account_holder_name") @db.VarChar(255)
|
||||
template InvoiceTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([templateId, sortOrder], map: "idx_invoice_template_accounts_template_id")
|
||||
@@map("invoice_template_accounts")
|
||||
}
|
||||
|
||||
model Invoice {
|
||||
id BigInt @id @default(autoincrement())
|
||||
businessId BigInt @map("business_id")
|
||||
ownerScope InvoiceOwnerScope @default(platform) @map("owner_scope")
|
||||
issuerBusinessId BigInt? @map("issuer_business_id")
|
||||
status InvoiceStatus @default(issued)
|
||||
notes String?
|
||||
issuedBy BigInt? @map("issued_by")
|
||||
issuedAt DateTime @default(now()) @map("issued_at") @db.Timestamptz(6)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
name String? @db.VarChar(255)
|
||||
topText String? @map("top_text")
|
||||
invoiceTemplateId BigInt? @map("invoice_template_id")
|
||||
publicId String @unique(map: "idx_invoices_public_id") @map("public_id") @db.VarChar(32)
|
||||
accounts InvoiceAccount[]
|
||||
items InvoiceItem[]
|
||||
keyPoints InvoiceKeyPoint[]
|
||||
business Business @relation("InvoiceBusiness", fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
invoiceTemplate InvoiceTemplate? @relation(fields: [invoiceTemplateId], references: [id], onUpdate: NoAction)
|
||||
issuer User? @relation("InvoiceIssuer", fields: [issuedBy], references: [id], onUpdate: NoAction)
|
||||
issuerBusiness Business? @relation("InvoiceIssuerBusiness", fields: [issuerBusinessId], references: [id], onUpdate: NoAction)
|
||||
|
||||
@@index([businessId, createdAt(sort: Desc)], map: "idx_invoices_business_created")
|
||||
@@index([ownerScope, createdAt(sort: Desc)], map: "idx_invoices_owner_scope")
|
||||
@@index([status], map: "idx_invoices_status")
|
||||
@@map("invoices")
|
||||
}
|
||||
|
||||
model InvoiceItem {
|
||||
id BigInt @id @default(autoincrement())
|
||||
invoiceId BigInt @map("invoice_id")
|
||||
templateId BigInt? @map("template_id")
|
||||
title String @db.VarChar(255)
|
||||
duration String? @db.VarChar(100)
|
||||
worktime String? @db.VarChar(100)
|
||||
description String?
|
||||
price Decimal @default(0) @db.Decimal(12, 2)
|
||||
discountedPrice Decimal? @map("discounted_price") @db.Decimal(12, 2)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
template InvoiceItemTemplate? @relation(fields: [templateId], references: [id], onUpdate: NoAction)
|
||||
|
||||
@@index([invoiceId, sortOrder], map: "idx_invoice_items_invoice_id")
|
||||
@@map("invoice_items")
|
||||
}
|
||||
|
||||
model InvoiceKeyPoint {
|
||||
id BigInt @id @default(autoincrement())
|
||||
invoiceId BigInt @map("invoice_id")
|
||||
text String
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([invoiceId, sortOrder], map: "idx_invoice_key_points_invoice_id")
|
||||
@@map("invoice_key_points")
|
||||
}
|
||||
|
||||
model InvoiceAccount {
|
||||
id BigInt @id @default(autoincrement())
|
||||
invoiceId BigInt @map("invoice_id")
|
||||
bankName String @map("bank_name") @db.VarChar(255)
|
||||
cardNumber String? @map("card_number") @db.VarChar(64)
|
||||
iban String? @db.VarChar(64)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
accountHolderName String? @map("account_holder_name") @db.VarChar(255)
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([invoiceId, sortOrder], map: "idx_invoice_accounts_invoice_id")
|
||||
@@map("invoice_accounts")
|
||||
}
|
||||
|
||||
enum MediaType {
|
||||
image
|
||||
video
|
||||
@@ -1050,6 +1231,7 @@ enum MediaEntityType {
|
||||
product
|
||||
blog
|
||||
portfolio
|
||||
customer
|
||||
|
||||
@@map("media_entity_type")
|
||||
}
|
||||
@@ -1141,183 +1323,9 @@ enum InvoiceOwnerScope {
|
||||
enum InvoiceStatus {
|
||||
draft
|
||||
issued
|
||||
approved
|
||||
paid
|
||||
cancelled
|
||||
approved
|
||||
|
||||
@@map("invoice_status")
|
||||
}
|
||||
|
||||
model InvoiceItemTemplate {
|
||||
id BigInt @id @default(autoincrement())
|
||||
ownerScope InvoiceOwnerScope @map("owner_scope")
|
||||
businessId BigInt? @map("business_id")
|
||||
title String @db.VarChar(255)
|
||||
duration String? @db.VarChar(100)
|
||||
worktime String? @db.VarChar(100)
|
||||
description String?
|
||||
price Decimal @default(0) @db.Decimal(12, 2)
|
||||
discountedPrice Decimal? @map("discounted_price") @db.Decimal(12, 2)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
business Business? @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
invoiceItems InvoiceItem[]
|
||||
invoiceTemplateItems InvoiceTemplateItem[]
|
||||
|
||||
@@index([ownerScope, sortOrder], map: "idx_invoice_item_templates_owner_scope")
|
||||
@@index([businessId, sortOrder], map: "idx_invoice_item_templates_business_id")
|
||||
@@map("invoice_item_templates")
|
||||
}
|
||||
|
||||
model InvoiceTemplate {
|
||||
id BigInt @id @default(autoincrement())
|
||||
ownerScope InvoiceOwnerScope @map("owner_scope")
|
||||
businessId BigInt? @map("business_id")
|
||||
name String @db.VarChar(255)
|
||||
topText String? @map("top_text")
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
business Business? @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
items InvoiceTemplateItem[]
|
||||
keyPoints InvoiceTemplateKeyPoint[]
|
||||
accounts InvoiceTemplateAccount[]
|
||||
invoices Invoice[]
|
||||
|
||||
@@index([ownerScope, sortOrder], map: "idx_invoice_templates_owner_scope")
|
||||
@@index([businessId, sortOrder], map: "idx_invoice_templates_business_id")
|
||||
@@map("invoice_templates")
|
||||
}
|
||||
|
||||
model InvoiceTemplateItem {
|
||||
id BigInt @id @default(autoincrement())
|
||||
templateId BigInt @map("template_id")
|
||||
itemTemplateId BigInt? @map("item_template_id")
|
||||
title String @db.VarChar(255)
|
||||
duration String? @db.VarChar(100)
|
||||
worktime String? @db.VarChar(100)
|
||||
description String?
|
||||
price Decimal @default(0) @db.Decimal(12, 2)
|
||||
discountedPrice Decimal? @map("discounted_price") @db.Decimal(12, 2)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
template InvoiceTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
itemTemplate InvoiceItemTemplate? @relation(fields: [itemTemplateId], references: [id], onUpdate: NoAction)
|
||||
|
||||
@@index([templateId, sortOrder], map: "idx_invoice_template_items_template_id")
|
||||
@@map("invoice_template_items")
|
||||
}
|
||||
|
||||
model InvoiceTemplateKeyPoint {
|
||||
id BigInt @id @default(autoincrement())
|
||||
templateId BigInt @map("template_id")
|
||||
text String
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
template InvoiceTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([templateId, sortOrder], map: "idx_invoice_template_key_points_template_id")
|
||||
@@map("invoice_template_key_points")
|
||||
}
|
||||
|
||||
model InvoiceTemplateAccount {
|
||||
id BigInt @id @default(autoincrement())
|
||||
templateId BigInt @map("template_id")
|
||||
bankName String @map("bank_name") @db.VarChar(255)
|
||||
accountHolderName String? @map("account_holder_name") @db.VarChar(255)
|
||||
cardNumber String? @map("card_number") @db.VarChar(64)
|
||||
iban String? @db.VarChar(64)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
template InvoiceTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([templateId, sortOrder], map: "idx_invoice_template_accounts_template_id")
|
||||
@@map("invoice_template_accounts")
|
||||
}
|
||||
|
||||
model Invoice {
|
||||
id BigInt @id @default(autoincrement())
|
||||
publicId String @unique(map: "idx_invoices_public_id") @map("public_id") @db.VarChar(32)
|
||||
businessId BigInt @map("business_id")
|
||||
ownerScope InvoiceOwnerScope @default(platform) @map("owner_scope")
|
||||
issuerBusinessId BigInt? @map("issuer_business_id")
|
||||
status InvoiceStatus @default(issued)
|
||||
name String? @db.VarChar(255)
|
||||
topText String? @map("top_text")
|
||||
notes String?
|
||||
invoiceTemplateId BigInt? @map("invoice_template_id")
|
||||
issuedBy BigInt? @map("issued_by")
|
||||
issuedAt DateTime @default(now()) @map("issued_at") @db.Timestamptz(6)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
business Business @relation("InvoiceBusiness", fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
issuerBusiness Business? @relation("InvoiceIssuerBusiness", fields: [issuerBusinessId], references: [id], onUpdate: NoAction)
|
||||
issuer User? @relation("InvoiceIssuer", fields: [issuedBy], references: [id], onUpdate: NoAction)
|
||||
invoiceTemplate InvoiceTemplate? @relation(fields: [invoiceTemplateId], references: [id], onUpdate: NoAction)
|
||||
items InvoiceItem[]
|
||||
keyPoints InvoiceKeyPoint[]
|
||||
accounts InvoiceAccount[]
|
||||
|
||||
@@index([businessId, createdAt(sort: Desc)], map: "idx_invoices_business_created")
|
||||
@@index([ownerScope, createdAt(sort: Desc)], map: "idx_invoices_owner_scope")
|
||||
@@index([issuerBusinessId, createdAt(sort: Desc)], map: "idx_invoices_issuer_business_id")
|
||||
@@index([status], map: "idx_invoices_status")
|
||||
@@index([invoiceTemplateId], map: "idx_invoices_invoice_template_id")
|
||||
@@map("invoices")
|
||||
}
|
||||
|
||||
model InvoiceItem {
|
||||
id BigInt @id @default(autoincrement())
|
||||
invoiceId BigInt @map("invoice_id")
|
||||
templateId BigInt? @map("template_id")
|
||||
title String @db.VarChar(255)
|
||||
duration String? @db.VarChar(100)
|
||||
worktime String? @db.VarChar(100)
|
||||
description String?
|
||||
price Decimal @default(0) @db.Decimal(12, 2)
|
||||
discountedPrice Decimal? @map("discounted_price") @db.Decimal(12, 2)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
template InvoiceItemTemplate? @relation(fields: [templateId], references: [id], onUpdate: NoAction)
|
||||
|
||||
@@index([invoiceId, sortOrder], map: "idx_invoice_items_invoice_id")
|
||||
@@index([templateId], map: "idx_invoice_items_template_id")
|
||||
@@map("invoice_items")
|
||||
}
|
||||
|
||||
model InvoiceKeyPoint {
|
||||
id BigInt @id @default(autoincrement())
|
||||
invoiceId BigInt @map("invoice_id")
|
||||
text String
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([invoiceId, sortOrder], map: "idx_invoice_key_points_invoice_id")
|
||||
@@map("invoice_key_points")
|
||||
}
|
||||
|
||||
model InvoiceAccount {
|
||||
id BigInt @id @default(autoincrement())
|
||||
invoiceId BigInt @map("invoice_id")
|
||||
bankName String @map("bank_name") @db.VarChar(255)
|
||||
accountHolderName String? @map("account_holder_name") @db.VarChar(255)
|
||||
cardNumber String? @map("card_number") @db.VarChar(64)
|
||||
iban String? @db.VarChar(64)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([invoiceId, sortOrder], map: "idx_invoice_accounts_invoice_id")
|
||||
@@map("invoice_accounts")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user