first commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"username" TEXT NOT NULL,
|
||||
"password" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Patient" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"firstName" TEXT NOT NULL,
|
||||
"lastName" TEXT NOT NULL,
|
||||
"dateOfBirth" DATE NOT NULL,
|
||||
"gender" TEXT NOT NULL,
|
||||
"phone" TEXT NOT NULL,
|
||||
"email" TEXT,
|
||||
"address" TEXT,
|
||||
"city" TEXT,
|
||||
"zipCode" TEXT,
|
||||
"insuranceProvider" TEXT,
|
||||
"insuranceId" TEXT,
|
||||
"groupNumber" TEXT,
|
||||
"policyHolder" TEXT,
|
||||
"allergies" TEXT,
|
||||
"medicalConditions" TEXT,
|
||||
"status" TEXT NOT NULL DEFAULT 'active',
|
||||
"userId" INTEGER NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "Patient_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Appointment" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"patientId" INTEGER NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"date" DATE NOT NULL,
|
||||
"startTime" TIME NOT NULL,
|
||||
"endTime" TIME NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"notes" TEXT,
|
||||
"status" TEXT NOT NULL DEFAULT 'scheduled',
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "Appointment_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Patient" ADD CONSTRAINT "Patient_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Appointment" ADD CONSTRAINT "Appointment_patientId_fkey" FOREIGN KEY ("patientId") REFERENCES "Patient"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Appointment" ADD CONSTRAINT "Appointment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
3
packages/db/prisma/migrations/migration_lock.toml
Normal file
3
packages/db/prisma/migrations/migration_lock.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (e.g., Git)
|
||||
provider = "postgresql"
|
||||
70
packages/db/prisma/schema.prisma
Normal file
70
packages/db/prisma/schema.prisma
Normal file
@@ -0,0 +1,70 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated/prisma"
|
||||
}
|
||||
generator zod {
|
||||
provider = "prisma-zod-generator"
|
||||
output = "../shared/" // Zod schemas will be generated here inside `db/shared`
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
username String @unique
|
||||
password String
|
||||
patients Patient[]
|
||||
appointments Appointment[]
|
||||
}
|
||||
|
||||
model Patient {
|
||||
id Int @id @default(autoincrement())
|
||||
firstName String
|
||||
lastName String
|
||||
dateOfBirth DateTime @db.Date
|
||||
gender String
|
||||
phone String
|
||||
email String?
|
||||
address String?
|
||||
city String?
|
||||
zipCode String?
|
||||
insuranceProvider String?
|
||||
insuranceId String?
|
||||
groupNumber String?
|
||||
policyHolder String?
|
||||
allergies String?
|
||||
medicalConditions String?
|
||||
status String @default("active")
|
||||
userId Int
|
||||
createdAt DateTime @default(now())
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
appointments Appointment[]
|
||||
}
|
||||
|
||||
model Appointment {
|
||||
id Int @id @default(autoincrement())
|
||||
patientId Int
|
||||
userId Int
|
||||
title String
|
||||
date DateTime @db.Date
|
||||
startTime DateTime @db.Time
|
||||
endTime DateTime @db.Time
|
||||
type String // e.g., "checkup", "cleaning", "filling", etc.
|
||||
notes String?
|
||||
status String @default("scheduled") // "scheduled", "completed", "cancelled", "no-show"
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
patient Patient @relation(fields: [patientId], references: [id])
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
}
|
||||
Reference in New Issue
Block a user