@@ -12,6 +12,12 @@ import {
1212
1313export type ProgramSlot = { dayOfWeek : number ; time : string } ;
1414
15+ export type ExtraQuestionOption = {
16+ id : string ;
17+ title : string ;
18+ description ?: string ;
19+ } ;
20+
1521export const roleEnum = pgEnum ( "role" , [ "user" , "admin" , "coach" ] ) ;
1622export const serviceTypeEnum = pgEnum ( "service_type" , [
1723 "private_lessons" ,
@@ -35,6 +41,13 @@ export const serviceStatusEnum = pgEnum("service_status", [
3541 "deleted" ,
3642 "disabled" ,
3743] ) ;
44+ export const genderEnum = pgEnum ( "gender" , [ "male" , "female" , "prefer_not_to_say" ] ) ;
45+ export const extraQuestionTypeEnum = pgEnum ( "extra_question_type" , [
46+ "text" ,
47+ "multiple_choices" ,
48+ "checkboxes" ,
49+ "user_agreement" ,
50+ ] ) ;
3851
3952export const profiles = pgTable ( "profiles" , {
4053 id : uuid ( "id" ) . primaryKey ( ) ,
@@ -136,3 +149,57 @@ export const purchases = pgTable("purchases", {
136149 createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
137150 updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
138151} ) ;
152+
153+ export const children = pgTable ( "children" , {
154+ id : uuid ( "id" ) . primaryKey ( ) . defaultRandom ( ) ,
155+ parentId : uuid ( "parent_id" )
156+ . references ( ( ) => profiles . id , { onDelete : "cascade" } )
157+ . notNull ( ) ,
158+ gender : genderEnum ( "gender" ) . notNull ( ) ,
159+ firstName : text ( "first_name" ) . notNull ( ) ,
160+ lastName : text ( "last_name" ) . notNull ( ) ,
161+ dob : date ( "dob" , { mode : "string" } ) . notNull ( ) ,
162+ allergies : text ( "allergies" ) ,
163+ medicalConditions : text ( "medical_conditions" ) ,
164+ medications : text ( "medications" ) ,
165+ createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
166+ updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
167+ } ) ;
168+
169+ export const emergencyContacts = pgTable ( "emergency_contacts" , {
170+ id : uuid ( "id" ) . primaryKey ( ) . defaultRandom ( ) ,
171+ childId : uuid ( "child_id" )
172+ . references ( ( ) => children . id , { onDelete : "cascade" } )
173+ . notNull ( ) ,
174+ fullName : text ( "full_name" ) . notNull ( ) ,
175+ emailAddress : text ( "email_address" ) . notNull ( ) ,
176+ phoneNumber : text ( "phone_number" ) . notNull ( ) ,
177+ relationship : text ( "relationship" ) . notNull ( ) ,
178+ createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
179+ updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
180+ } ) ;
181+
182+ export const extraQuestions = pgTable ( "extra_questions" , {
183+ id : uuid ( "id" ) . primaryKey ( ) . defaultRandom ( ) ,
184+ serviceId : uuid ( "service_id" )
185+ . references ( ( ) => services . id , { onDelete : "cascade" } )
186+ . notNull ( ) ,
187+ type : extraQuestionTypeEnum ( "type" ) . notNull ( ) ,
188+ prompt : text ( "prompt" ) . notNull ( ) ,
189+ options : jsonb ( "options" ) . $type < ExtraQuestionOption [ ] > ( ) ,
190+ createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
191+ updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
192+ } ) ;
193+
194+ export const extraQuestionAnswers = pgTable ( "extra_question_answers" , {
195+ id : uuid ( "id" ) . primaryKey ( ) . defaultRandom ( ) ,
196+ extraQuestionId : uuid ( "extra_question_id" )
197+ . references ( ( ) => extraQuestions . id , { onDelete : "cascade" } )
198+ . notNull ( ) ,
199+ childId : uuid ( "child_id" )
200+ . references ( ( ) => children . id , { onDelete : "cascade" } )
201+ . notNull ( ) ,
202+ answer : text ( "answer" ) . array ( ) . notNull ( ) ,
203+ createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
204+ updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
205+ } ) ;
0 commit comments