import { PrismaClient } from '@prisma/client';

export const prisma = new PrismaClient({
  log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
});

export default {
  client: prisma,
  connect: async () => {
    try {
      await prisma.$connect();
      console.log('✅ Database connected');
    } catch (error) {
      console.error('❌ Database connection failed:', error);
      process.exit(1);
    }
  },
  disconnect: async () => {
    await prisma.$disconnect();
    console.log('Database disconnected');
  }
};
