This commit is contained in:
unknown committed 2026-06-30 12:37:37 +07:00
1 parent 0144545166
commit be0ee265d5
9 files changed
+43 -11

No files matched your search

+2 -11
View File
@@ -6,6 +6,7 @@ const { PrismaClient } = require('@prisma/client');
const { Pool } = require('pg');
const { PrismaPg } = require('@prisma/adapter-pg');
const bcrypt = require('bcryptjs');
const seedAdmin = require('./seedAdmin.cjs');
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const adapter = new PrismaPg(pool);
@@ -86,17 +87,7 @@ async function main() {
}
// 0. Seed Admin User
const adminPassword = await bcrypt.hash('homaroma123', 10);
await prisma.user.upsert({
where: { username: 'admin' },
update: { password: adminPassword },
create: {
username: 'admin',
password: adminPassword,
role: 'ADMIN'
}
});
process.stdout.write('✅ Seeded Admin User (admin / homaroma123).\n');
await seedAdmin(prisma);
// 0.5 Seed Core Menus
const coreMenus = [
+36
View File
@@ -0,0 +1,36 @@
const bcrypt = require('bcryptjs');
async function seedAdmin(prisma) {
const adminPassword = await bcrypt.hash('homaroma123', 10);
await prisma.user.upsert({
where: { username: 'admin' },
update: { password: adminPassword },
create: {
username: 'admin',
password: adminPassword,
role: 'ADMIN'
}
});
process.stdout.write('✅ Seeded Admin User (admin / homaroma123).\n');
}
module.exports = seedAdmin;
if (require.main === module) {
const { PrismaClient } = require('@prisma/client');
const { Pool } = require('pg');
const { PrismaPg } = require('@prisma/adapter-pg');
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const adapter = new PrismaPg(pool);
const prisma = new PrismaClient({ adapter });
seedAdmin(prisma)
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
}