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

const prisma = new PrismaClient({
  datasources: {
    db: {
      url: process.env.DATABASE_URL,
    },
  },
});

export async function connectDatabase(): Promise<void> {
  try {
    await prisma.$connect();
    console.log('📦 MySQL 连接成功 (Asia/Shanghai)');
  } catch (error) {
    console.error('📦 MySQL 连接失败:', error);
    throw error;
  }
}

export { prisma };