Skip to content

Commit 9f607ff

Browse files
committed
removed the schedules table , added a scheduled at blob to services to log time for services of type coaching
1 parent f57b223 commit 9f607ff

3 files changed

Lines changed: 9 additions & 41 deletions

File tree

docs/schema-overview.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,14 @@ erDiagram
1616
text title
1717
text description
1818
service_type type
19-
uuid scheduling_id
19+
jsonb scheduled_at "null for coaching_session"
2020
int duration_minutes
2121
int price
2222
boolean is_active
2323
timestamp created_at
2424
timestamp updated_at
2525
}
2626
27-
service_schedules {
28-
uuid id PK
29-
uuid service_id FK
30-
jsonb data
31-
timestamp created_at
32-
timestamp updated_at
33-
}
34-
3527
service_bookings {
3628
uuid id PK
3729
uuid user_id FK
@@ -70,7 +62,6 @@ erDiagram
7062
timestamp updated_at
7163
}
7264
73-
services ||--o| service_schedules : "has schedule"
7465
profiles ||--o{ service_bookings : "books"
7566
services ||--o{ service_bookings : "booked via"
7667
profiles ||--o{ coaching_sessions : "coaches"

docs/services.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Services, Schedules & Service Bookings Tables
1+
# Services & Service Bookings Tables
22

33
## Services
44

55
The central catalog of offerings on the platform. Two types:
6-
- **`booking`** — a bookable service; has an associated `service_schedules` row (via `scheduling_id`).
7-
- **`coaching_session`** — a coaching offering; `scheduling_id` is null — the scheduling is handled through the `coaching_sessions` table.
6+
- **`booking`** — a fixed event with predetermined time slots set by the admin. Users buy it like a product with no input on timing. `scheduled_at` holds the time slots as a JSON array.
7+
- **`coaching_session`** — a coaching offering where the user proposes availability. `scheduled_at` is null — timing is handled through the `coaching_sessions` table.
88

99
```mermaid
1010
erDiagram
@@ -13,32 +13,18 @@ erDiagram
1313
text title
1414
text description
1515
service_type type "coaching_session | booking"
16-
uuid scheduling_id "null for coaching_session"
16+
jsonb scheduled_at "array of {start, end} objects — null for coaching_session"
1717
int duration_minutes
1818
int price "in cents"
1919
boolean is_active
2020
timestamp created_at
21-
}
22-
```
23-
24-
## Service Schedules
25-
26-
Holds the scheduling data for `booking`-type services. Format of `data` is TBD.
27-
28-
```mermaid
29-
erDiagram
30-
service_schedules {
31-
uuid id PK
32-
uuid service_id FK
33-
jsonb data "scheduling format TBD"
34-
timestamp created_at
3521
timestamp updated_at
3622
}
3723
```
3824

3925
## Service Bookings
4026

41-
A user's booking of a service.
27+
A user's purchase of a booking-type service.
4228

4329
```mermaid
4430
erDiagram
@@ -50,14 +36,14 @@ erDiagram
5036
text notes
5137
boolean is_active
5238
timestamp created_at
39+
timestamp updated_at
5340
}
5441
55-
services ||--o| service_schedules : "has schedule"
5642
services ||--o{ service_bookings : "booked via"
5743
```
5844

5945
## Notes
6046

6147
- `price` is stored in **cents** (integer) to avoid floating-point issues.
6248
- `is_active = false` hides a service without deleting historical bookings.
63-
- `scheduling_id` is a soft reference to `service_schedules.id` — cascade is handled from `service_schedules.service_id → services.id`.
49+
- `scheduled_at` is a JSON array of `{ start, end }` ISO 8601 objects e.g. `[{ "start": "2026-04-15T14:00:00Z", "end": "2026-04-15T16:00:00Z" }]`.

lib/db/schema.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,12 @@ export const profiles = pgTable("profiles", {
1717
updatedAt: timestamp("updated_at").defaultNow().notNull(),
1818
})
1919

20-
export const serviceSchedules = pgTable("service_schedules", {
21-
id: uuid("id").primaryKey().defaultRandom(),
22-
serviceId: uuid("service_id").references(() => services.id, { onDelete: "cascade" }).notNull(),
23-
data: jsonb("data").notNull(),
24-
createdAt: timestamp("created_at").defaultNow().notNull(),
25-
updatedAt: timestamp("updated_at").defaultNow().notNull(),
26-
});
27-
28-
2920
export const services = pgTable("services", {
3021
id: uuid("id").primaryKey().defaultRandom(),
3122
title: text("title").notNull(),
3223
description: text("description"),
3324
type: serviceTypeEnum("type").notNull(),
34-
schedulingId: uuid("scheduling_id"),
25+
scheduledAt: jsonb("scheduled_at"),
3526
durationMinutes: integer("duration_minutes").notNull(),
3627
price: integer("price").notNull().default(0),
3728
isActive: boolean("is_active").notNull().default(true),

0 commit comments

Comments
 (0)