const { PrismaClient } = require('@prisma/client'); const bcrypt = require('bcryptjs'); const { PrismaPg } = require('@prisma/adapter-pg'); // Load environment variables from .env file require('dotenv').config(); // Create PrismaClient with PostgreSQL adapter (matching src/lib/prisma.ts) const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL }); const prisma = new PrismaClient({ adapter }); async function main() { try { const newPassword = 'adminadmin'; // Find the admin user const user = await prisma.user.findUnique({ where: { email: 'david@dhg.lol' } }); if (!user) { console.log('❌ Admin user not found'); return; } // Find the account const account = await prisma.account.findFirst({ where: { userId: user.id } }); if (!account) { console.log('❌ Account not found for user'); return; } // Hash new password using bcrypt const salt = await bcrypt.genSalt(12); const passwordHash = await bcrypt.hash(newPassword, salt); // Update the password await prisma.account.update({ where: { id: account.id }, data: { password: passwordHash } }); console.log('✅ Admin password updated successfully!'); console.log(' Email:', user.email); console.log(' New Password:', newPassword); } catch (error) { console.error('❌ Error:', error.message); } finally { await prisma.$disconnect(); } } main();