1- import { pgTable , text , timestamp , uuid , pgEnum , integer , boolean , jsonb } from "drizzle-orm/pg-core" ;
1+ import {
2+ pgTable ,
3+ text ,
4+ timestamp ,
5+ uuid ,
6+ pgEnum ,
7+ integer ,
8+ boolean ,
9+ jsonb ,
10+ } from "drizzle-orm/pg-core" ;
211
312export const roleEnum = pgEnum ( "role" , [ "user" , "admin" , "coach" ] ) ;
4- export const serviceTypeEnum = pgEnum ( 'service_type' , [ "coaching_session" , "booking" ] ) ;
5- export const bookingStatusEnum = pgEnum ( 'booking_status' , [ "pending" , "confirmed" , "cancelled" ] ) ;
6- export const webinarTierEnum = pgEnum ( 'webinar_tier' , [ "free" , "premium" ] ) ;
7- export const sessionStatusEnum = pgEnum ( "session_status" , [ "pending" , "confirmed" , "cancelled" , "completed" ] ) ;
8-
13+ export const serviceTypeEnum = pgEnum ( "service_type" , [
14+ "coaching_session" ,
15+ "booking" ,
16+ ] ) ;
17+ export const bookingStatusEnum = pgEnum ( "booking_status" , [
18+ "pending" ,
19+ "confirmed" ,
20+ "cancelled" ,
21+ ] ) ;
22+ export const webinarTierEnum = pgEnum ( "webinar_tier" , [ "free" , "premium" ] ) ;
23+ export const sessionStatusEnum = pgEnum ( "session_status" , [
24+ "pending" ,
25+ "confirmed" ,
26+ "cancelled" ,
27+ "completed" ,
28+ ] ) ;
929
1030export const profiles = pgTable ( "profiles" , {
1131 id : uuid ( "id" ) . primaryKey ( ) ,
@@ -15,7 +35,7 @@ export const profiles = pgTable("profiles", {
1535 stripeCustomerId : text ( "stripe_customer_id" ) . unique ( ) ,
1636 createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
1737 updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
18- } )
38+ } ) ;
1939
2040export const services = pgTable ( "services" , {
2141 id : uuid ( "id" ) . primaryKey ( ) . defaultRandom ( ) ,
@@ -28,12 +48,16 @@ export const services = pgTable("services", {
2848 isActive : boolean ( "is_active" ) . notNull ( ) . default ( true ) ,
2949 createdAt : timestamp ( "created_at" ) . defaultNow ( ) . notNull ( ) ,
3050 updatedAt : timestamp ( "updated_at" ) . defaultNow ( ) . notNull ( ) ,
31- } )
51+ } ) ;
3252
3353export const serviceBookings = pgTable ( "service_bookings" , {
3454 id : uuid ( "id" ) . primaryKey ( ) . defaultRandom ( ) ,
35- userId : uuid ( "user_id" ) . references ( ( ) => profiles . id , { onDelete : "cascade" } ) . notNull ( ) ,
36- serviceId : uuid ( "service_id" ) . references ( ( ) => services . id , { onDelete : "cascade" } ) . notNull ( ) ,
55+ userId : uuid ( "user_id" )
56+ . references ( ( ) => profiles . id , { onDelete : "cascade" } )
57+ . notNull ( ) ,
58+ serviceId : uuid ( "service_id" )
59+ . references ( ( ) => services . id , { onDelete : "cascade" } )
60+ . notNull ( ) ,
3761 status : bookingStatusEnum ( "status" ) . notNull ( ) . default ( "pending" ) ,
3862 notes : text ( "notes" ) ,
3963 isActive : boolean ( "is_active" ) . notNull ( ) . default ( true ) ,
@@ -55,9 +79,15 @@ export const webinars = pgTable("webinars", {
5579
5680export const coachingSessions = pgTable ( "coaching_sessions" , {
5781 id : uuid ( "id" ) . primaryKey ( ) . defaultRandom ( ) ,
58- serviceId : uuid ( "service_id" ) . references ( ( ) => services . id , { onDelete : "cascade" } ) . notNull ( ) ,
59- coachId : uuid ( "coach_id" ) . references ( ( ) => profiles . id , { onDelete : "cascade" } ) . notNull ( ) ,
60- userId : uuid ( "user_id" ) . references ( ( ) => profiles . id , { onDelete : "cascade" } ) . notNull ( ) ,
82+ serviceId : uuid ( "service_id" )
83+ . references ( ( ) => services . id , { onDelete : "cascade" } )
84+ . notNull ( ) ,
85+ coachId : uuid ( "coach_id" )
86+ . references ( ( ) => profiles . id , { onDelete : "cascade" } )
87+ . notNull ( ) ,
88+ userId : uuid ( "user_id" )
89+ . references ( ( ) => profiles . id , { onDelete : "cascade" } )
90+ . notNull ( ) ,
6191 scheduledAt : timestamp ( "scheduled_at" ) ,
6292 durationMinutes : integer ( "duration_minutes" ) . notNull ( ) . default ( 60 ) ,
6393 status : sessionStatusEnum ( "status" ) . notNull ( ) . default ( "pending" ) ,
@@ -70,7 +100,10 @@ export const coachingSessions = pgTable("coaching_sessions", {
70100
71101export const subscriptions = pgTable ( "subscriptions" , {
72102 id : uuid ( "id" ) . primaryKey ( ) . defaultRandom ( ) ,
73- userId : uuid ( "user_id" ) . references ( ( ) => profiles . id , { onDelete : "cascade" } ) . notNull ( ) . unique ( ) ,
103+ userId : uuid ( "user_id" )
104+ . references ( ( ) => profiles . id , { onDelete : "cascade" } )
105+ . notNull ( )
106+ . unique ( ) ,
74107 stripeSubscriptionId : text ( "stripe_subscription_id" ) . unique ( ) ,
75108 status : text ( "status" ) . notNull ( ) . default ( "none" ) ,
76109 stripePriceId : text ( "stripe_price_id" ) ,
@@ -83,7 +116,9 @@ export const subscriptions = pgTable("subscriptions", {
83116
84117export const purchases = pgTable ( "purchases" , {
85118 id : uuid ( "id" ) . primaryKey ( ) . defaultRandom ( ) ,
86- userId : uuid ( "user_id" ) . references ( ( ) => profiles . id , { onDelete : "cascade" } ) . notNull ( ) ,
119+ userId : uuid ( "user_id" )
120+ . references ( ( ) => profiles . id , { onDelete : "cascade" } )
121+ . notNull ( ) ,
87122 stripePriceId : text ( "stripe_price_id" ) . notNull ( ) ,
88123 stripeSessionId : text ( "stripe_session_id" ) . notNull ( ) . unique ( ) ,
89124 productName : text ( "product_name" ) . notNull ( ) ,
0 commit comments