diff --git a/backend/package.json b/backend/package.json index 97164d6..f1f1245 100644 --- a/backend/package.json +++ b/backend/package.json @@ -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" } } diff --git a/backend/prisma/seed-products.ts b/backend/prisma/seed-products.ts index c1d839a..e070650 100644 --- a/backend/prisma/seed-products.ts +++ b/backend/prisma/seed-products.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' } });