Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .env.example

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why did you remove the .env.example in this pr? is there any particular reason of that choice?

This file was deleted.

47 changes: 47 additions & 0 deletions lib/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export const serviceStatusEnum = pgEnum("service_status", [
"deleted",
"disabled",
]);
export const genderEnum = pgEnum("gender", ["male", "female", "other"]);
Comment thread
achneerov marked this conversation as resolved.
Outdated
export const extraQuestionTypeEnum = pgEnum("extra_question_type", [
"text",
"multiple_choices",
"checkboxes",
"user_agreement",
]);

export const profiles = pgTable("profiles", {
id: uuid("id").primaryKey(),
Expand Down Expand Up @@ -136,3 +143,43 @@ export const purchases = pgTable("purchases", {
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});

export const children = pgTable("children", {
id: uuid("id").primaryKey().defaultRandom(),
parentId: uuid("parent_id")
.references(() => profiles.id, { onDelete: "cascade" })
.notNull(),
gender: genderEnum("gender").notNull(),
firstName: text("first_name").notNull(),
lastName: text("last_name").notNull(),
dob: date("dob", { mode: "string" }).notNull(),
allergies: text("allergies"),
medicalConditions: text("medical_conditions"),
medications: text("medications"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});

export const emergencyContacts = pgTable("emergency_contacts", {
id: uuid("id").primaryKey().defaultRandom(),
childId: uuid("child_id")
.references(() => children.id, { onDelete: "cascade" })
.notNull(),
Comment on lines +171 to +173

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

childId FK with no uniqueness means contacts are duplicated per sibling.
if a family has 3 kids the same grandparent gets 3 rows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems fine? if it is unique then we can't have multiple emergency contacts per child unless its some composite, idk it seems kinda overkill. What are you suggesting exactly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked with Mattia. You're right Alex, we're keeping it like this.

fullName: text("full_name").notNull(),
emailAddress: text("email_address").notNull(),
phoneNumber: text("phone_number").notNull(),
relationship: text("relationship").notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});

export const extraQuestions = pgTable("extra_questions", {
id: uuid("id").primaryKey().defaultRandom(),
serviceId: uuid("service_id")
.references(() => services.id, { onDelete: "cascade" })
.notNull(),
type: extraQuestionTypeEnum("type").notNull(),
content: text("content").notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
Comment thread
martin0024 marked this conversation as resolved.
Loading