x
This commit is contained in:
1 parent
0144545166
commit
be0ee265d5
9 files changed
+43
-11
No files matched your search
@@ -3,3 +3,7 @@ node_modules
|
|||||||
.env
|
.env
|
||||||
|
|
||||||
/generated/prisma
|
/generated/prisma
|
||||||
|
|
||||||
|
# Ignore uploaded files but keep the directory
|
||||||
|
public/uploads/*
|
||||||
|
!public/uploads/.gitkeep
|
||||||
@@ -6,6 +6,7 @@ const { PrismaClient } = require('@prisma/client');
|
|||||||
const { Pool } = require('pg');
|
const { Pool } = require('pg');
|
||||||
const { PrismaPg } = require('@prisma/adapter-pg');
|
const { PrismaPg } = require('@prisma/adapter-pg');
|
||||||
const bcrypt = require('bcryptjs');
|
const bcrypt = require('bcryptjs');
|
||||||
|
const seedAdmin = require('./seedAdmin.cjs');
|
||||||
|
|
||||||
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
||||||
const adapter = new PrismaPg(pool);
|
const adapter = new PrismaPg(pool);
|
||||||
@@ -86,17 +87,7 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0. Seed Admin User
|
// 0. Seed Admin User
|
||||||
const adminPassword = await bcrypt.hash('homaroma123', 10);
|
await seedAdmin(prisma);
|
||||||
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');
|
|
||||||
|
|
||||||
// 0.5 Seed Core Menus
|
// 0.5 Seed Core Menus
|
||||||
const coreMenus = [
|
const coreMenus = [
|
||||||
|
|||||||
@@ -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();
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Keep this directory
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 301 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 592 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 511 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 694 KiB |
Reference in new issue
Block a user