fix(prisma): export main in seed modules and execute directly in seed.ts

This commit is contained in:
parsa aghaei 2026-07-27 20:00:08 +03:30
parent 027f169830
commit e7df5b3964
3 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -151,7 +151,7 @@ const PRODUCT_TAGLINES_MAP: Record<string, string> = {
'canina-novagard-green-pfotenpflege': "مومیایی محافظ پنجه‌ها برای التیام خشکی، قرمزی و ترک خوردگی پنجه‌ها در برف و سرما"
};
async function main() {
export async function main() {
console.log('Seeding products from seed-products-data.json...');
// 2. Read JSON data

View File

@ -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);
}