-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-admin.ts
More file actions
32 lines (27 loc) · 863 Bytes
/
create-admin.ts
File metadata and controls
32 lines (27 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { PrismaClient } = require('@prisma/client')
const bcrypt = require('bcrypt')
const prisma = new PrismaClient()
async function createAdmin() {
try {
const hashedPassword = await bcrypt.hash('Sabri@@12345', 10)
const admin = await prisma.user.upsert({
where: { email: 'sabrielevage@gmail.com' },
update: {
isAdmin: true,
password: hashedPassword
},
create: {
email: 'sabrielevage@gmail.com',
name: 'Admin',
password: hashedPassword,
isAdmin: true,
},
})
console.log('Admin user created:', admin)
} catch (error) {
console.error('Error creating admin:', error)
} finally {
await prisma.$disconnect()
}
}
createAdmin()