fix: resolve unique constraint bug in prisma seeders and run products/home seeders successfully
This commit is contained in:
parent
6db28f6231
commit
71f5ac2fa6
@ -88,6 +88,6 @@
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"prisma": {
|
||||
"seed": "ts-node prisma/seed.ts"
|
||||
"seed": "ts-node prisma/seed.ts && ts-node prisma/seed-products.ts && ts-node prisma/seed-home.ts"
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,13 @@ async function main() {
|
||||
// 2. Read products.json
|
||||
const productsPath = 'C:/Users/parsa/.gemini/antigravity-ide/brain/951ff86f-dc4e-4670-9a62-78e1f9c8c223/scratch/products.json';
|
||||
if (fs.existsSync(productsPath)) {
|
||||
const productsRaw = fs.readFileSync(productsPath, 'utf8');
|
||||
let productsRaw = fs.readFileSync(productsPath, 'utf8');
|
||||
// Replace old brand names in memory to seed correctly
|
||||
productsRaw = productsRaw
|
||||
.replace(/کانینا/g, 'کانینو')
|
||||
.replace(/کانینا/g, 'کانینو')
|
||||
.replace(/Canina/g, 'Canino')
|
||||
.replace(/canina/g, 'canino');
|
||||
const products = JSON.parse(productsRaw);
|
||||
|
||||
let count = 0;
|
||||
@ -72,15 +78,15 @@ async function main() {
|
||||
// Create admin user for blogs
|
||||
const adminId = '12345678-1234-1234-1234-123456789012';
|
||||
await prisma.user.upsert({
|
||||
where: { mobile: '09120000000' },
|
||||
update: { id: adminId, role: 'admin' },
|
||||
where: { id: adminId },
|
||||
update: { role: 'ADMIN' },
|
||||
create: {
|
||||
id: adminId,
|
||||
mobile: '09120000000',
|
||||
email: 'admin@canino-iran.com',
|
||||
firstName: 'Admin',
|
||||
lastName: 'User',
|
||||
role: 'admin'
|
||||
role: 'ADMIN'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user