-
Notifications
You must be signed in to change notification settings - Fork 0
feat(db): add children and emergency_contacts tables with related fields #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
09a604f
1a49659
e20939c
8eb3910
77c5905
ed808ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,12 @@ import { | |
|
|
||
| export type ProgramSlot = { dayOfWeek: number; time: string }; | ||
|
|
||
| export type ExtraQuestionOption = { | ||
| id: string; | ||
| title: string; | ||
| description?: string; | ||
| }; | ||
|
|
||
| export const roleEnum = pgEnum("role", ["user", "admin", "coach"]); | ||
| export const serviceTypeEnum = pgEnum("service_type", [ | ||
| "private_lessons", | ||
|
|
@@ -35,6 +41,13 @@ export const serviceStatusEnum = pgEnum("service_status", [ | |
| "deleted", | ||
| "disabled", | ||
| ]); | ||
| export const genderEnum = pgEnum("gender", ["male", "female", "other"]); | ||
|
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(), | ||
|
|
@@ -136,3 +149,57 @@ 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(), | ||
| prompt: text("prompt").notNull(), | ||
| options: jsonb("options").$type<ExtraQuestionOption[]>(), | ||
| createdAt: timestamp("created_at").defaultNow().notNull(), | ||
| updatedAt: timestamp("updated_at").defaultNow().notNull(), | ||
| }); | ||
|
|
||
| export const extraQuestionAnswers = pgTable("extra_question_answers", { | ||
| id: uuid("id").primaryKey().defaultRandom(), | ||
| extraQuestionId: uuid("extra_question_id") | ||
| .references(() => extraQuestions.id, { onDelete: "cascade" }) | ||
| .notNull(), | ||
| childId: uuid("child_id") | ||
| .references(() => children.id, { onDelete: "cascade" }) | ||
| .notNull(), | ||
| answer: text("answer").array().notNull(), | ||
| createdAt: timestamp("created_at").defaultNow().notNull(), | ||
| updatedAt: timestamp("updated_at").defaultNow().notNull(), | ||
| }); | ||
|
martin0024 marked this conversation as resolved.
|
||
There was a problem hiding this comment.
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?