set consumer customers and saleInvoices
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `customer_individuals` DROP FOREIGN KEY `customer_individuals_customer_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `customer_legal` DROP FOREIGN KEY `customer_legal_customer_id_fkey`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `customers` ADD COLUMN `unknown_customer` JSON NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `customer_individuals_complex_id_idx` ON `customer_individuals`(`complex_id`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `customer_legal_complex_id_idx` ON `customer_legal`(`complex_id`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,46 +1,51 @@
|
||||
model Customer {
|
||||
id String @id @default(uuid())
|
||||
type CustomerType
|
||||
is_favorite Boolean? @default(false)
|
||||
id String @id @default(uuid())
|
||||
is_favorite Boolean? @default(false)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
|
||||
sales_invoices SalesInvoice[]
|
||||
customer_individuals CustomerIndividual?
|
||||
customer_legals CustomerLegal?
|
||||
type CustomerType
|
||||
unknown_customer Json?
|
||||
customer_individual CustomerIndividual?
|
||||
customer_legal CustomerLegal?
|
||||
sales_invoices SalesInvoice[]
|
||||
|
||||
@@map("customers")
|
||||
}
|
||||
|
||||
model CustomerIndividual {
|
||||
customer_id String @id
|
||||
first_name String @db.VarChar(255)
|
||||
last_name String @db.VarChar(255)
|
||||
national_id String @db.Char(10)
|
||||
postal_code String @db.Char(10)
|
||||
economic_code String? @db.Char(10)
|
||||
complex_id String
|
||||
|
||||
customer Customer @relation(fields: [customer_id], references: [id])
|
||||
complex Complex @relation(fields: [complex_id], references: [id])
|
||||
customer_id String @id
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
complex_id String
|
||||
complex Complex @relation(fields: [complex_id], references: [id])
|
||||
|
||||
@@unique([complex_id, national_id])
|
||||
@@index([complex_id])
|
||||
@@map("customer_individuals")
|
||||
}
|
||||
|
||||
model CustomerLegal {
|
||||
customer_id String @id
|
||||
company_name String @db.VarChar(255)
|
||||
economic_code String @db.Char(10)
|
||||
registration_number String @db.Char(20)
|
||||
postal_code String @db.Char(10)
|
||||
complex_id String
|
||||
|
||||
customer Customer @relation(fields: [customer_id], references: [id])
|
||||
complex Complex @relation(fields: [complex_id], references: [id])
|
||||
customer_id String @id
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
complex_id String
|
||||
complex Complex @relation(fields: [complex_id], references: [id])
|
||||
|
||||
@@unique([complex_id, registration_number])
|
||||
@@index([complex_id])
|
||||
@@map("customer_legal")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user