first commit
This commit is contained in:
commit
c9fb67e751
423 files changed
+53287
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import { PrismaClient, PerfilUsuario } from "@prisma/client";
|
||||
import bcrypt from "bcryptjs";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
// Criar usuário admin inicial
|
||||
const adminEmail = "admin@advx.com.br";
|
||||
|
||||
const existingAdmin = await prisma.usuario.findUnique({
|
||||
where: { email: adminEmail },
|
||||
});
|
||||
|
||||
if (existingAdmin) {
|
||||
await prisma.usuario.update({
|
||||
where: { email: adminEmail },
|
||||
data: {
|
||||
perfil: PerfilUsuario.ADVOGADO_ADMIN,
|
||||
nome: "Administrador",
|
||||
senha: await bcrypt.hash("admin123", 10),
|
||||
ativo: true,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await prisma.usuario.create({
|
||||
data: {
|
||||
nome: "Administrador",
|
||||
email: adminEmail,
|
||||
senha: await bcrypt.hash("admin123", 10),
|
||||
perfil: PerfilUsuario.ADVOGADO_ADMIN,
|
||||
ativo: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`Seed concluído com sucesso!`);
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error("Erro durante o seed:", e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in new issue
Block a user