fix bug of edit product
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
-- Remove Catalog as independent entity; Product is the sole merchandise unit.
|
||||
ALTER TABLE "Product" DROP CONSTRAINT IF EXISTS "Product_catalogId_fkey";
|
||||
DROP INDEX IF EXISTS "Product_catalogId_idx";
|
||||
ALTER TABLE "Product" DROP COLUMN IF EXISTS "catalogId";
|
||||
DROP TABLE IF EXISTS "Catalog";
|
||||
+1
-23
@@ -143,7 +143,6 @@ model Company {
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
bankAccounts BankAccount[]
|
||||
catalogs Catalog[]
|
||||
products Product[]
|
||||
orders Order[]
|
||||
customers Customer[]
|
||||
@@ -169,35 +168,16 @@ model BankAccount {
|
||||
@@index([companyId])
|
||||
}
|
||||
|
||||
model Catalog {
|
||||
id String @id @default(cuid())
|
||||
companyId String
|
||||
name String
|
||||
code String
|
||||
description String?
|
||||
imageUrl String?
|
||||
displayOrder Int @default(0)
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
|
||||
products Product[]
|
||||
|
||||
@@unique([companyId, code])
|
||||
@@index([companyId])
|
||||
}
|
||||
|
||||
model Product {
|
||||
id String @id @default(cuid())
|
||||
companyId String
|
||||
catalogId String
|
||||
name String
|
||||
code String
|
||||
color String
|
||||
description String?
|
||||
minMeterage Float @default(30)
|
||||
orderMultiplier Float @default(10)
|
||||
/// قیمت هر متر (تومان) برای نمایش کاتالوگ / پیشفاکتور
|
||||
basePrice Float?
|
||||
stock Float?
|
||||
isActive Boolean @default(true)
|
||||
@@ -219,7 +199,6 @@ model Product {
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
|
||||
catalog Catalog @relation(fields: [catalogId], references: [id], onDelete: Cascade)
|
||||
brand Brand? @relation(fields: [brandId], references: [id], onDelete: SetNull)
|
||||
cartItems CartItem[]
|
||||
orderItems OrderItem[]
|
||||
@@ -229,7 +208,6 @@ model Product {
|
||||
productSuggestions ProductSuggestion[]
|
||||
|
||||
@@unique([companyId, code])
|
||||
@@index([catalogId])
|
||||
@@index([companyId])
|
||||
@@index([brandId])
|
||||
@@index([usageCategory])
|
||||
|
||||
@@ -40,7 +40,6 @@ async function main() {
|
||||
await prisma.otpChallenge.deleteMany();
|
||||
await prisma.customerNotification.deleteMany();
|
||||
await prisma.product.deleteMany();
|
||||
await prisma.catalog.deleteMany();
|
||||
await prisma.bankAccount.deleteMany();
|
||||
await prisma.levelBenefit.deleteMany();
|
||||
await prisma.customerLevelDef.deleteMany();
|
||||
@@ -130,24 +129,11 @@ async function main() {
|
||||
],
|
||||
});
|
||||
|
||||
await prisma.catalog.createMany({
|
||||
data: [
|
||||
{ id: 'cat-377', companyId: 'company-par', name: 'کالیته ۳۷۷', code: '377', displayOrder: 1, isActive: true },
|
||||
{ id: 'cat-378', companyId: 'company-par', name: 'کالیته ۳۷۸', code: '378', displayOrder: 2, isActive: true },
|
||||
{ id: 'cat-379', companyId: 'company-par', name: 'کالیته ۳۷۹', code: '379', displayOrder: 3, isActive: true },
|
||||
{ id: 'cat-380', companyId: 'company-par', name: 'کالیته ۳۸۰', code: '380', displayOrder: 4, isActive: true },
|
||||
{ id: 'cat-381', companyId: 'company-par', name: 'کالیته ۳۸۱', code: '381', displayOrder: 5, isActive: true },
|
||||
{ id: 'cat-fam-401', companyId: 'company-fam-baft', name: 'کالیته ۴۰۱', code: '401', displayOrder: 1, isActive: true },
|
||||
{ id: 'cat-fam-402', companyId: 'company-fam-baft', name: 'کالیته ۴۰۲', code: '402', displayOrder: 2, isActive: true },
|
||||
],
|
||||
});
|
||||
|
||||
await prisma.product.createMany({
|
||||
data: [
|
||||
{
|
||||
id: 'prod-377-blue',
|
||||
companyId: 'company-par',
|
||||
catalogId: 'cat-377',
|
||||
name: 'فاستونی ایتالیایی',
|
||||
code: '377-BL',
|
||||
color: 'آبی',
|
||||
@@ -171,7 +157,6 @@ async function main() {
|
||||
{
|
||||
id: 'prod-377-black',
|
||||
companyId: 'company-par',
|
||||
catalogId: 'cat-377',
|
||||
name: 'پارچه مشکی رسمی',
|
||||
code: '377-BK',
|
||||
color: 'مشکی',
|
||||
@@ -195,7 +180,6 @@ async function main() {
|
||||
{
|
||||
id: 'prod-378-blue',
|
||||
companyId: 'company-par',
|
||||
catalogId: 'cat-378',
|
||||
name: 'پیراهنی نخی آبی',
|
||||
code: '378-BL',
|
||||
color: 'آبی',
|
||||
@@ -219,7 +203,6 @@ async function main() {
|
||||
{
|
||||
id: 'prod-378-black',
|
||||
companyId: 'company-par',
|
||||
catalogId: 'cat-378',
|
||||
name: 'پیراهنی مشکی',
|
||||
code: '378-BK',
|
||||
color: 'مشکی',
|
||||
@@ -242,7 +225,6 @@ async function main() {
|
||||
{
|
||||
id: 'prod-378-blue-white',
|
||||
companyId: 'company-par',
|
||||
catalogId: 'cat-378',
|
||||
name: 'آبی پشت سفید',
|
||||
code: '378-BLW',
|
||||
color: 'آبی پشت سفید',
|
||||
@@ -265,7 +247,6 @@ async function main() {
|
||||
{
|
||||
id: 'prod-378-black-white',
|
||||
companyId: 'company-par',
|
||||
catalogId: 'cat-378',
|
||||
name: 'مشکی پشت سفید',
|
||||
code: '378-BKW',
|
||||
color: 'مشکی پشت سفید',
|
||||
@@ -288,7 +269,6 @@ async function main() {
|
||||
{
|
||||
id: 'prod-fam-401-1',
|
||||
companyId: 'company-fam-baft',
|
||||
catalogId: 'cat-fam-401',
|
||||
name: 'پارچه مخمل',
|
||||
code: '401-MV',
|
||||
color: 'سرمهای',
|
||||
@@ -311,7 +291,6 @@ async function main() {
|
||||
{
|
||||
id: 'prod-fam-401-2',
|
||||
companyId: 'company-fam-baft',
|
||||
catalogId: 'cat-fam-401',
|
||||
name: 'پارچه کجراه',
|
||||
code: '401-KJ',
|
||||
color: 'کرم',
|
||||
|
||||
Reference in New Issue
Block a user