import { pgTable, pgEnum, uuid, timestamp, text, integer, boolean, date, real } from "drizzle-orm/pg-core"; import { children as childrenTable } from "./family"; const children = childrenTable; // Feed types export const feedType = pgEnum("feed_type", ["breast_milk", "formula", "solid", "water", "other"]); export const feedMethod = pgEnum("feed_method", ["bottle", "breast_left", "breast_right", "breast_both", "cup", "spoon", "finger", "self"]); // Diaper types export const diaperType = pgEnum("diaper_type", ["wet", "dirty", "both", "dry"]); // Sleep types export const sleepType = pgEnum("sleep_type", ["nap", "night"]); // Logs: feeds export const feeds = pgTable("feeds", { id: uuid("id").primaryKey().defaultRandom(), childId: uuid("child_id").references(() => children.id).notNull(), type: feedType("type").notNull(), method: feedMethod("method"), amountMl: real("amount_ml"), notes: text("notes"), loggedAt: timestamp("logged_at").defaultNow().notNull(), createdAt: timestamp("created_at").defaultNow().notNull(), }); // Logs: diapers export const diapers = pgTable("diapers", { id: uuid("id").primaryKey().defaultRandom(), childId: uuid("child_id").references(() => children.id).notNull(), type: diaperType("type").notNull(), notes: text("notes"), loggedAt: timestamp("logged_at").defaultNow().notNull(), createdAt: timestamp("created_at").defaultNow().notNull(), }); // Logs: sleep export const sleeps = pgTable("sleeps", { id: uuid("id").primaryKey().defaultRandom(), childId: uuid("child_id").references(() => children.id).notNull(), type: sleepType("type").notNull(), startedAt: timestamp("started_at").notNull(), endedAt: timestamp("ended_at"), durationMinutes: integer("duration_minutes"), notes: text("notes"), loggedAt: timestamp("logged_at").defaultNow().notNull(), createdAt: timestamp("created_at").defaultNow().notNull(), }); // Logs: vaccinations export const vaccinations = pgTable("vaccinations", { id: uuid("id").primaryKey().defaultRandom(), childId: uuid("child_id").references(() => children.id).notNull(), vaccineName: text("vaccine_name").notNull(), scheduledDate: date("scheduled_date").notNull(), givenDate: date("given_date"), status: text("status").notNull().default("pending"), // pending, given, skipped, delayed provider: text("provider"), lotNumber: text("lot_number"), notes: text("notes"), createdAt: timestamp("created_at").defaultNow().notNull(), }); // Logs: growth export const growth = pgTable("growth", { id: uuid("id").primaryKey().defaultRandom(), childId: uuid("child_id").references(() => children.id).notNull(), measuredAt: timestamp("measured_at").notNull(), weightKg: real("weight_kg"), heightCm: real("height_cm"), headCircumferenceCm: real("head_circumference_cm"), notes: text("notes"), createdAt: timestamp("created_at").defaultNow().notNull(), }); // Logs: medications export const medications = pgTable("medications", { id: uuid("id").primaryKey().defaultRandom(), childId: uuid("child_id").references(() => children.id).notNull(), name: text("name").notNull(), dosage: text("dosage"), frequency: text("frequency"), startDate: date("start_date").notNull(), endDate: date("end_date"), active: boolean("active").notNull().default(true), notes: text("notes"), createdAt: timestamp("created_at").defaultNow().notNull(), }); // Type exports export type Feed = typeof feeds.$inferSelect; export type Diaper = typeof diapers.$inferSelect; export type Sleep = typeof sleeps.$inferSelect; export type Vaccination = typeof vaccinations.$inferSelect; export type Growth = typeof growth.$inferSelect; export type Medication = typeof medications.$inferSelect;