@@ -7,19 +7,31 @@ erDiagram
77 text first_name
88 text last_name
99 role role
10+ text stripe_customer_id
11+ timestamp last_login_at
12+ timestamp created_at
13+ timestamp updated_at
14+ }
15+
16+ forms {
17+ uuid id PK
18+ text name
1019 timestamp created_at
1120 timestamp updated_at
1221 }
1322
1423 services {
1524 uuid id PK
16- text title
17- text description
1825 service_type type
19- jsonb scheduled_at "null for coaching_session"
26+ date start_date "null for private_lessons"
27+ date end_date "null for private_lessons"
28+ jsonb slots "array of {dayOfWeek, time}; null for private_lessons"
2029 int duration_minutes
21- int price
22- boolean is_active
30+ text stripe_product_id
31+ service_status status
32+ uuid coach_id FK "null for programs"
33+ uuid form_id FK "nullable"
34+ boolean is_for_children
2335 timestamp created_at
2436 timestamp updated_at
2537 }
@@ -28,9 +40,11 @@ erDiagram
2840 uuid id PK
2941 uuid user_id FK
3042 uuid service_id FK
43+ uuid child_id FK "nullable; null means adult registration"
3144 booking_status status
3245 text notes
3346 boolean is_active
47+ text stripe_order_id
3448 timestamp created_at
3549 timestamp updated_at
3650 }
@@ -52,12 +66,41 @@ erDiagram
5266 uuid service_id FK
5367 uuid coach_id FK
5468 uuid user_id FK
55- timestamp scheduled_at
56- int duration_minutes
69+ uuid child_id FK "nullable; null means adult registration"
70+ timestamp scheduled_at "set when slot is confirmed"
5771 session_status status
5872 text meeting_url
5973 text notes
6074 jsonb selected_time_slots "array of {start, end} objects"
75+ jsonb coach_time_slots
76+ text coach_token
77+ text client_token
78+ text stripe_order_id
79+ timestamp created_at
80+ timestamp updated_at
81+ }
82+
83+ subscriptions {
84+ uuid id PK
85+ uuid user_id FK
86+ text stripe_subscription_id
87+ text status
88+ text stripe_price_id
89+ boolean cancel_at_period_end
90+ text payment_method_brand
91+ text payment_method_last4
92+ timestamp created_at
93+ timestamp updated_at
94+ }
95+
96+ purchases {
97+ uuid id PK
98+ uuid user_id FK
99+ text stripe_price_id
100+ text stripe_session_id
101+ text product_name
102+ int amount
103+ text currency
61104 timestamp created_at
62105 timestamp updated_at
63106 }
@@ -87,19 +130,20 @@ erDiagram
87130 timestamp updated_at
88131 }
89132
90- extra_questions {
133+ form_questions {
91134 uuid id PK
92- uuid service_id FK
93- extra_question_type type
135+ uuid form_id FK
136+ form_question_type type
94137 text prompt
95138 jsonb options
139+ int sort_order
96140 timestamp created_at
97141 timestamp updated_at
98142 }
99143
100- extra_question_answers {
144+ form_question_answers {
101145 uuid id PK
102- uuid extra_question_id FK
146+ uuid form_question_id FK
103147 uuid child_id FK
104148 text answer "text[]"
105149 timestamp created_at
@@ -108,24 +152,37 @@ erDiagram
108152
109153 profiles ||--o{ service_bookings : "books"
110154 services ||--o{ service_bookings : "booked via"
155+ children |o--o{ service_bookings : "registered for"
111156 profiles ||--o{ coaching_sessions : "coaches"
112157 profiles ||--o{ coaching_sessions : "attends"
113158 services ||--o{ coaching_sessions : "fulfilled by"
159+ children |o--o{ coaching_sessions : "registered for"
114160 profiles ||--o{ children : "parent of"
115161 children ||--o{ emergency_contacts : "has"
116- services ||--o{ extra_questions : "defines"
117- extra_questions ||--o{ extra_question_answers : "answered via"
118- children ||--o{ extra_question_answers : "submits"
162+ profiles ||--o| subscriptions : "has"
163+ profiles ||--o{ purchases : "makes"
164+ profiles |o--o{ services : "coaches"
165+ forms ||--o{ form_questions : "contains"
166+ services }o--o| forms : "uses"
167+ form_questions ||--o{ form_question_answers : "answered via"
168+ children ||--o{ form_question_answers : "submits"
119169```
120170
171+ ## Indexes
172+
173+ | Table | Index | Type | Condition |
174+ | ---| ---| ---| ---|
175+ | ` service_bookings ` | ` service_bookings_service_id_child_id_idx ` | Unique (partial) | ` WHERE child_id IS NOT NULL ` — prevents the same child from registering for the same program twice |
176+
121177## Enums
122178
123179| Enum | Values |
124180| ---| ---|
125181| ` role ` | ` user ` , ` admin ` , ` coach ` |
126- | ` service_type ` | ` coaching_session ` , ` booking ` |
127- | ` booking_status ` | ` pending ` , ` confirmed ` , ` cancelled ` |
182+ | ` service_type ` | ` private_lessons ` , ` programs ` |
183+ | ` service_status ` | ` active ` , ` disabled ` , ` archived ` , ` deleted ` |
184+ | ` booking_status ` | ` awaiting_payment ` , ` pending ` , ` confirmed ` , ` cancelled ` |
185+ | ` session_status ` | ` awaiting_payment ` , ` pending ` , ` confirmed ` , ` cancelled ` , ` completed ` |
128186| ` webinar_tier ` | ` free ` , ` premium ` |
129- | ` session_status ` | ` pending ` , ` confirmed ` , ` cancelled ` , ` completed ` |
130187| ` gender ` | ` male ` , ` female ` , ` prefer_not_to_say ` |
131- | ` extra_question_type ` | ` text ` , ` multiple_choices ` , ` checkboxes ` , ` user_agreement ` |
188+ | ` form_question_type ` | ` text ` , ` multiple_choices ` , ` checkboxes ` , ` user_agreement ` |
0 commit comments