36 lines
769 B
TypeScript
36 lines
769 B
TypeScript
import { PrismaClient } from '@prisma/client'
|
|
import bcrypt from 'bcryptjs'
|
|
|
|
const prisma = new PrismaClient()
|
|
|
|
async function main() {
|
|
const superadminUsername = 'superadmin'
|
|
const superadminPassword = 'titipin123!'
|
|
|
|
const hashedPassword = await bcrypt.hash(superadminPassword, 10)
|
|
|
|
const superadmin = await prisma.user.upsert({
|
|
where: { username: superadminUsername },
|
|
update: {},
|
|
create: {
|
|
username: superadminUsername,
|
|
name: 'Super Admin',
|
|
password: hashedPassword,
|
|
role: 'superadmin',
|
|
is_active: true,
|
|
},
|
|
})
|
|
|
|
console.log({ superadmin })
|
|
}
|
|
|
|
main()
|
|
.then(async () => {
|
|
await prisma.$disconnect()
|
|
})
|
|
.catch(async (e) => {
|
|
console.error(e)
|
|
await prisma.$disconnect()
|
|
process.exit(1)
|
|
})
|