fix: correct db port, localhost defaults, hashed passwords in seed

This commit is contained in:
ff
2026-04-04 23:30:05 -04:00
parent 0b854963bd
commit 608a577b1c
3 changed files with 15 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
import { PrismaClient } from "../generated/prisma";
import bcrypt from "bcrypt";
const prisma = new PrismaClient();
function formatTime(date: Date): string {
@@ -6,28 +7,30 @@ function formatTime(date: Date): string {
}
async function main() {
const hashedPassword = await bcrypt.hash("123456", 10);
// Create multiple users
const users = await prisma.user.createMany({
await prisma.user.createMany({
data: [
{ username: "admin2", password: "123456" },
{ username: "bob", password: "123456" },
{ username: "admin2", password: hashedPassword },
{ username: "bob", password: hashedPassword },
],
});
const createdUsers = await prisma.user.findMany();
// Creatin staff
// Create staff (userId links staff to a user account)
await prisma.staff.createMany({
data: [
{ name: "Dr. Kai Gao", role: "Doctor" },
{ name: "Dr. Jane Smith", role: "Doctor" },
{ name: "Dr. Kai Gao", role: "Doctor", userId: createdUsers[0].id },
{ name: "Dr. Jane Smith", role: "Doctor", userId: createdUsers[1].id },
],
});
const staffMembers = await prisma.staff.findMany();
// Create multiple patients
const patients = await prisma.patient.createMany({
await prisma.patient.createMany({
data: [
{
firstName: "Emily",
@@ -64,6 +67,7 @@ async function main() {
{
patientId: createdPatients[0].id,
userId: createdUsers[0].id,
staffId: staffMembers[0].id,
title: "Initial Consultation",
date: new Date("2025-06-01"),
startTime: formatTime(new Date("2025-06-01T10:00:00")),
@@ -73,6 +77,7 @@ async function main() {
{
patientId: createdPatients[1].id,
userId: createdUsers[1].id,
staffId: staffMembers[1].id,
title: "Follow-up",
date: new Date("2025-06-02"),
startTime: formatTime(new Date("2025-06-01T10:00:00")),