// Domain models model Group { id String @id @default(cuid()) name String description String? days WeekDay[] time String? capacity Int? price Decimal? @db.Decimal(10, 2) billingType BillingType? @map("billing_type") dueDay Int? @map("due_day") inviteToken String? @unique(map: "groups_inviteToken_key") @map("invite_token") createdById String @map("created_by_id") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") owner User @relation("OwnerGroups", fields: [createdById], references: [id], onDelete: Cascade, map: "groups_createdById_fkey") members GroupMember[] attendees Attendee[] payments Payment[] waitlist GroupWaitlistEntry[] preRegistrations GroupPreRegistration[] classSessions ClassSession[] @@map("groups") } enum WeekDay { MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY } enum BillingType { MONTHLY PER_CLASS } model GroupMember { id String @id @default(cuid()) groupId String @map("group_id") userId String @map("user_id") role Role @default(MEMBER) // OWNER, ADMIN, MEMBER joinedAt DateTime @default(now()) @map("joined_at") group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "group_members_groupId_fkey") user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "group_members_userId_fkey") @@unique([groupId, userId], map: "group_members_groupId_userId_key") @@map("group_members") } enum Role { OWNER ADMIN MEMBER } enum AttendeeStatus { ACTIVE PAUSED DROPPED } model Attendee { id String @id @default(cuid()) groupId String @map("group_id") fullName String @map("full_name") email String? phone String? guardianName String? @map("guardian_name") guardianPhone String? @map("guardian_phone") notes String? notifyToken String? @unique(map: "attendees_notifyToken_key") @default(cuid()) @map("notify_token") status AttendeeStatus @default(ACTIVE) createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "attendees_groupId_fkey") payments Payment[] attendances Attendance[] slotReleases SlotRelease[] @@index([groupId], map: "attendees_groupId_idx") @@map("attendees") } model Payment { id String @id @default(cuid()) groupId String @map("group_id") attendeeId String @map("attendee_id") amount Decimal @db.Decimal(10, 2) currency String @default("MXN") status PaymentStatus @default(PENDING) // PENDING, PAID, OVERDUE, CANCELLED dueDate DateTime @map("due_date") paidAt DateTime? @map("paid_at") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "payments_groupId_fkey") attendee Attendee @relation(fields: [attendeeId], references: [id], onDelete: Cascade, map: "payments_attendeeId_fkey") @@index([groupId], map: "payments_groupId_idx") @@index([attendeeId], map: "payments_attendeeId_idx") @@map("payments") } enum PaymentStatus { PENDING PAID OVERDUE CANCELLED } model WaitlistEntry { id String @id @default(cuid()) email String name String? status WaitlistStatus @default(PENDING) // PENDING, INVITED, JOINED, DECLINED createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") userId String? @unique(map: "waitlist_entries_userId_key") @map("user_id") user User? @relation(fields: [userId], references: [id], onDelete: SetNull, map: "waitlist_entries_userId_fkey") @@unique([email]) @@map("waitlist_entries") } model GroupWaitlistEntry { id String @id @default(cuid()) groupId String @map("group_id") fullName String @map("full_name") phone String email String? notes String? status WaitlistStatus @default(PENDING) // PENDING, INVITED, JOINED, DECLINED createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "group_waitlist_entries_groupId_fkey") @@unique([groupId, phone], map: "group_waitlist_entries_groupId_phone_key") @@index([groupId], map: "group_waitlist_entries_groupId_idx") @@map("group_waitlist_entries") } enum WaitlistStatus { PENDING INVITED JOINED DECLINED } enum PreRegistrationStatus { PENDING APPROVED REJECTED } model GroupPreRegistration { id String @id @default(cuid()) groupId String @map("group_id") fullName String @map("full_name") phone String email String? status PreRegistrationStatus @default(PENDING) reviewedAt DateTime? @map("reviewed_at") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "group_pre_registrations_groupId_fkey") @@unique([groupId, phone], map: "group_pre_registrations_groupId_phone_key") @@index([groupId], map: "group_pre_registrations_groupId_idx") @@map("group_pre_registrations") } enum PaymentProvider { MERCADO_PAGO STRIPE } model MerchantAccount { id String @id @default(cuid()) userId String @unique(map: "merchant_accounts_userId_key") @map("user_id") provider PaymentProvider accessToken String? @map("access_token") sandbox Boolean @default(true) connectedAt DateTime @default(now()) @map("connected_at") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "merchant_accounts_userId_fkey") @@map("merchant_accounts") }