Skip to content

Commit

Permalink
hotfix: create user and admin models programatically
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloose committed Nov 18, 2023
1 parent 9879fcb commit ec3db71
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/setup-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ async function main() {
},
},
});
await prisma.doctor.create({
data: {
documentType: "DNI",
document: "75413034",
gender: "F",
id_user: superUser.id,
},
});
await prisma.admin.create({
data: {
id_user: superUser.id,
},
});
roles = await prisma.userRole.findMany();
done("Created super user with id =", superUser.id);
} else {
Expand Down
14 changes: 14 additions & 0 deletions src/services/users.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ export class UsersService {
roles: {
connect: roles.map((role) => ({ name: role })),
},
Admin: roles.some((role) => role === "ADMIN")
? {
create: {},
}
: undefined,
doctor: roles.some((role) => role === "DOCTOR")
? {
create: {
documentType: "DNI", // TODO: currently hardcoding this
document: "75413034", // we need to update the schema requirements and the UI
gender: "F",
},
}
: undefined,
},
select: {
id: true,
Expand Down

0 comments on commit ec3db71

Please sign in to comment.