import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); async function main() { console.log('Starting database seeding...'); // Clear existing data await prisma.transaction.deleteMany({}); await prisma.account.deleteMany({}); console.log('Cleared existing data'); // Create accounts const checkingAccount = await prisma.account.create({ data: { bankName: 'First National Bank', accountNumber: '432198', name: 'Checking Account', type: 'CHECKING', balance: 2500.0, notes: 'Primary checking account', }, }); const savingsAccount = await prisma.account.create({ data: { bankName: 'First National Bank', accountNumber: '876543', name: 'Savings Account', type: 'SAVINGS', balance: 10000.0, notes: 'Emergency fund', }, }); console.log('Created accounts:', { checkingAccount: checkingAccount.id, savingsAccount: savingsAccount.id, }); // Create transactions const transactions = await Promise.all([ prisma.transaction.create({ data: { accountId: checkingAccount.id, date: new Date('2025-04-20'), description: 'Grocery Store', amount: -75.5, category: 'Groceries', type: 'WITHDRAWAL', }, }), prisma.transaction.create({ data: { accountId: checkingAccount.id, date: new Date('2025-04-21'), description: 'Salary Deposit', amount: 3000.0, category: 'Income', type: 'DEPOSIT', }, }), prisma.transaction.create({ data: { accountId: savingsAccount.id, date: new Date('2025-04-22'), description: 'Transfer to Savings', amount: 500.0, category: 'Transfer', type: 'TRANSFER', }, }), ]); console.log(`Created ${transactions.length} transactions`); console.log('Seeding completed successfully!'); } main() .catch((e) => { console.error('Error during seeding:', e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });