File size: 1,119 Bytes
ca816a7 f04a1e3 ca816a7 d9879cf ca816a7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import path from 'path';
import dotenv from 'dotenv';
// Load root .env
dotenv.config({ path: path.resolve(__dirname, '../../../../.env') });
import { PrismaClient } from '@repo/database';
// @ts-ignore
import { seedDatabase } from '@repo/database/seed';
const prisma = new PrismaClient();
async function runSync() {
try {
console.log('🚀 Starting content synchronization...');
// Ensure Database URL is present
if (!process.env.DATABASE_URL) {
throw new Error('DATABASE_URL is not defined in .env');
}
const result = await seedDatabase(prisma);
if (result.seeded) {
console.log(`✅ Success: ${result.message}`);
} else {
console.warn(`⚠️ Warning: ${result.message}`);
}
} catch (err: unknown) {
console.error('❌ Sync failed:', (err instanceof Error ? (err instanceof Error ? err.message : String(err)) : String(err)));
if ((err as Error).stack) console.debug((err as Error).stack);
process.exit(1);
} finally {
await prisma.$disconnect();
}
}
runSync();
|