From e7df5b3964fd192ce6fea9e3131906bf113b7539 Mon Sep 17 00:00:00 2001 From: parsa aghaei Date: Mon, 27 Jul 2026 20:00:08 +0330 Subject: [PATCH] fix(prisma): export main in seed modules and execute directly in seed.ts --- backend/prisma/seed-home.ts | 2 +- backend/prisma/seed-products.ts | 2 +- backend/prisma/seed.ts | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/prisma/seed-home.ts b/backend/prisma/seed-home.ts index b1157d1..c89639b 100644 --- a/backend/prisma/seed-home.ts +++ b/backend/prisma/seed-home.ts @@ -2,7 +2,7 @@ import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); -async function main() { +export async function main() { console.log('Seeding Home Page Components...'); // 1. Seed Hero Banners diff --git a/backend/prisma/seed-products.ts b/backend/prisma/seed-products.ts index de0ee1a..57d64bf 100644 --- a/backend/prisma/seed-products.ts +++ b/backend/prisma/seed-products.ts @@ -151,7 +151,7 @@ const PRODUCT_TAGLINES_MAP: Record = { 'canina-novagard-green-pfotenpflege': "مومیایی محافظ پنجه‌ها برای التیام خشکی، قرمزی و ترک خوردگی پنجه‌ها در برف و سرما" }; -async function main() { +export async function main() { console.log('Seeding products from seed-products-data.json...'); // 2. Read JSON data diff --git a/backend/prisma/seed.ts b/backend/prisma/seed.ts index 13a2fde..889620c 100644 --- a/backend/prisma/seed.ts +++ b/backend/prisma/seed.ts @@ -296,8 +296,10 @@ async function main() { // 3. Seed Products & Categories console.log('Seeding Products & Categories...'); try { - const { execSync } = require('child_process'); - execSync('npx ts-node prisma/seed-products.ts', { stdio: 'inherit' }); + const seedProducts = require('./seed-products'); + if (seedProducts && typeof seedProducts.main === 'function') { + await seedProducts.main(); + } } catch (err) { console.error('Failed to seed products:', err); } @@ -305,8 +307,10 @@ async function main() { // 4. Seed Home Components & Testimonials console.log('Seeding Home Components...'); try { - const { execSync } = require('child_process'); - execSync('npx ts-node prisma/seed-home.ts', { stdio: 'inherit' }); + const seedHome = require('./seed-home'); + if (seedHome && typeof seedHome.main === 'function') { + await seedHome.main(); + } } catch (err) { console.error('Failed to seed home components:', err); }