development #14
@@ -48,7 +48,7 @@ bun --filter @gruperly/web icons # regenera los iconos PWA de apps/web
|
||||
## Convenciones repo-específicas
|
||||
|
||||
- **Frontend en español**: copy de UI, comentarios y textos en español.
|
||||
- **Base de datos**: todas las tablas usan **snake_case** vía `@@map` en `prisma/models/*.prisma` (p. ej. `User` → `users`, `WaitlistEntry` → `waitlist_entries`). Al agregar un modelo nuevo, incluir siempre `@@map("nombre_tabla")`.
|
||||
- **Base de datos**: todas las tablas y columnas físicas usan **snake_case**. Los modelos declaran `@@map` (p. ej. `User` → `users`, `WaitlistEntry` → `waitlist_entries`) y todo campo Prisma camelCase que cree una columna debe declarar `@map("nombre_campo")` (p. ej. `createdAt @map("created_at")`). Al agregar un modelo o campo nuevo, incluir siempre el mapping correspondiente sin cambiar la API camelCase de Prisma Client.
|
||||
- **API** responde errores en **Problem Details RFC 7807** (`application/problem+json`) y resultados como `{ data, pagination }`; los "use cases" devuelven `Result` y nunca lanzan excepciones de dominio.
|
||||
- **Tailwind v4** con tokens en `@theme` dentro de `apps/web/src/index.css` (p. ej. `--color-accent: #1e90ff`). Se usan como clases auto-generadas: `text-accent`, `bg-success-soft`, etc. Radius por defecto `0.75rem` (`rounded-xl`).
|
||||
- **Router ES file-based** (TanStack Router + `@tanstack/router-plugin`): las rutas viven en `apps/web/src/routes/` y solo contienen definiciones (`createFileRoute` + `component`), sin lógica de UI. `src/router.tsx` solo crea el router con el `routeTree` importado de `src/routeTree.gen.ts` (**archivo generado por el plugin en build/dev, versionado en git**: si agregás/renombrás una ruta, corré `bun --filter @gruperly/web build` para regenerarlo). Las rutas autenticadas cuelgan del layout pathless `_authenticated.tsx` (`AppLayoutGuard` + `RootLayout` con `<Outlet />`).
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
-- Rename camelCase columns to snake_case without recreating them or losing data.
|
||||
|
||||
-- accounts
|
||||
ALTER TABLE "accounts" RENAME COLUMN "userId" TO "user_id";
|
||||
ALTER TABLE "accounts" RENAME COLUMN "providerId" TO "provider_id";
|
||||
ALTER TABLE "accounts" RENAME COLUMN "accountId" TO "account_id";
|
||||
ALTER TABLE "accounts" RENAME COLUMN "accessToken" TO "access_token";
|
||||
ALTER TABLE "accounts" RENAME COLUMN "refreshToken" TO "refresh_token";
|
||||
ALTER TABLE "accounts" RENAME COLUMN "idToken" TO "id_token";
|
||||
ALTER TABLE "accounts" RENAME COLUMN "accessTokenExpiresAt" TO "access_token_expires_at";
|
||||
ALTER TABLE "accounts" RENAME COLUMN "refreshTokenExpiresAt" TO "refresh_token_expires_at";
|
||||
ALTER TABLE "accounts" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "accounts" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- attendances
|
||||
ALTER TABLE "attendances" RENAME COLUMN "attendeeId" TO "attendee_id";
|
||||
ALTER TABLE "attendances" RENAME COLUMN "classSessionId" TO "class_session_id";
|
||||
ALTER TABLE "attendances" RENAME COLUMN "markedAt" TO "marked_at";
|
||||
|
||||
-- attendees
|
||||
ALTER TABLE "attendees" RENAME COLUMN "groupId" TO "group_id";
|
||||
ALTER TABLE "attendees" RENAME COLUMN "fullName" TO "full_name";
|
||||
ALTER TABLE "attendees" RENAME COLUMN "guardianName" TO "guardian_name";
|
||||
ALTER TABLE "attendees" RENAME COLUMN "guardianPhone" TO "guardian_phone";
|
||||
ALTER TABLE "attendees" RENAME COLUMN "notifyToken" TO "notify_token";
|
||||
ALTER TABLE "attendees" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "attendees" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- class_sessions
|
||||
ALTER TABLE "class_sessions" RENAME COLUMN "groupId" TO "group_id";
|
||||
ALTER TABLE "class_sessions" RENAME COLUMN "startsAt" TO "starts_at";
|
||||
ALTER TABLE "class_sessions" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "class_sessions" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- group_members
|
||||
ALTER TABLE "group_members" RENAME COLUMN "groupId" TO "group_id";
|
||||
ALTER TABLE "group_members" RENAME COLUMN "userId" TO "user_id";
|
||||
ALTER TABLE "group_members" RENAME COLUMN "joinedAt" TO "joined_at";
|
||||
|
||||
-- group_pre_registrations
|
||||
ALTER TABLE "group_pre_registrations" RENAME COLUMN "groupId" TO "group_id";
|
||||
ALTER TABLE "group_pre_registrations" RENAME COLUMN "fullName" TO "full_name";
|
||||
ALTER TABLE "group_pre_registrations" RENAME COLUMN "reviewedAt" TO "reviewed_at";
|
||||
ALTER TABLE "group_pre_registrations" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "group_pre_registrations" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- group_waitlist_entries
|
||||
ALTER TABLE "group_waitlist_entries" RENAME COLUMN "groupId" TO "group_id";
|
||||
ALTER TABLE "group_waitlist_entries" RENAME COLUMN "fullName" TO "full_name";
|
||||
ALTER TABLE "group_waitlist_entries" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "group_waitlist_entries" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- groups
|
||||
ALTER TABLE "groups" RENAME COLUMN "billingType" TO "billing_type";
|
||||
ALTER TABLE "groups" RENAME COLUMN "dueDay" TO "due_day";
|
||||
ALTER TABLE "groups" RENAME COLUMN "inviteToken" TO "invite_token";
|
||||
ALTER TABLE "groups" RENAME COLUMN "createdById" TO "created_by_id";
|
||||
ALTER TABLE "groups" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "groups" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- invitations
|
||||
ALTER TABLE "invitations" RENAME COLUMN "organizationId" TO "organization_id";
|
||||
ALTER TABLE "invitations" RENAME COLUMN "inviterId" TO "inviter_id";
|
||||
ALTER TABLE "invitations" RENAME COLUMN "expiresAt" TO "expires_at";
|
||||
ALTER TABLE "invitations" RENAME COLUMN "createdAt" TO "created_at";
|
||||
|
||||
-- members
|
||||
ALTER TABLE "members" RENAME COLUMN "organizationId" TO "organization_id";
|
||||
ALTER TABLE "members" RENAME COLUMN "userId" TO "user_id";
|
||||
ALTER TABLE "members" RENAME COLUMN "createdAt" TO "created_at";
|
||||
|
||||
-- merchant_accounts
|
||||
ALTER TABLE "merchant_accounts" RENAME COLUMN "userId" TO "user_id";
|
||||
ALTER TABLE "merchant_accounts" RENAME COLUMN "accessToken" TO "access_token";
|
||||
ALTER TABLE "merchant_accounts" RENAME COLUMN "connectedAt" TO "connected_at";
|
||||
ALTER TABLE "merchant_accounts" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "merchant_accounts" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- organizations
|
||||
ALTER TABLE "organizations" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "organizations" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- passkeys
|
||||
ALTER TABLE "passkeys" RENAME COLUMN "publicKey" TO "public_key";
|
||||
ALTER TABLE "passkeys" RENAME COLUMN "credentialID" TO "credential_id";
|
||||
ALTER TABLE "passkeys" RENAME COLUMN "userId" TO "user_id";
|
||||
ALTER TABLE "passkeys" RENAME COLUMN "deviceType" TO "device_type";
|
||||
ALTER TABLE "passkeys" RENAME COLUMN "backedUp" TO "backed_up";
|
||||
ALTER TABLE "passkeys" RENAME COLUMN "createdAt" TO "created_at";
|
||||
|
||||
-- payments
|
||||
ALTER TABLE "payments" RENAME COLUMN "groupId" TO "group_id";
|
||||
ALTER TABLE "payments" RENAME COLUMN "attendeeId" TO "attendee_id";
|
||||
ALTER TABLE "payments" RENAME COLUMN "dueDate" TO "due_date";
|
||||
ALTER TABLE "payments" RENAME COLUMN "paidAt" TO "paid_at";
|
||||
ALTER TABLE "payments" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "payments" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- sessions
|
||||
ALTER TABLE "sessions" RENAME COLUMN "userId" TO "user_id";
|
||||
ALTER TABLE "sessions" RENAME COLUMN "expiresAt" TO "expires_at";
|
||||
ALTER TABLE "sessions" RENAME COLUMN "ipAddress" TO "ip_address";
|
||||
ALTER TABLE "sessions" RENAME COLUMN "userAgent" TO "user_agent";
|
||||
ALTER TABLE "sessions" RENAME COLUMN "activeOrganizationId" TO "active_organization_id";
|
||||
ALTER TABLE "sessions" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "sessions" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- slot_releases
|
||||
ALTER TABLE "slot_releases" RENAME COLUMN "attendeeId" TO "attendee_id";
|
||||
ALTER TABLE "slot_releases" RENAME COLUMN "classSessionId" TO "class_session_id";
|
||||
ALTER TABLE "slot_releases" RENAME COLUMN "isClaimed" TO "is_claimed";
|
||||
ALTER TABLE "slot_releases" RENAME COLUMN "createdAt" TO "created_at";
|
||||
|
||||
-- users
|
||||
ALTER TABLE "users" RENAME COLUMN "emailVerified" TO "email_verified";
|
||||
ALTER TABLE "users" RENAME COLUMN "onboardingCompleted" TO "onboarding_completed";
|
||||
ALTER TABLE "users" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "users" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- verifications
|
||||
ALTER TABLE "verifications" RENAME COLUMN "expiresAt" TO "expires_at";
|
||||
ALTER TABLE "verifications" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "verifications" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
|
||||
-- waitlist_entries
|
||||
ALTER TABLE "waitlist_entries" RENAME COLUMN "userId" TO "user_id";
|
||||
ALTER TABLE "waitlist_entries" RENAME COLUMN "createdAt" TO "created_at";
|
||||
ALTER TABLE "waitlist_entries" RENAME COLUMN "updatedAt" TO "updated_at";
|
||||
@@ -8,43 +8,43 @@ enum AttendanceStatus {
|
||||
|
||||
model ClassSession {
|
||||
id String @id @default(cuid())
|
||||
groupId String
|
||||
startsAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
groupId String @map("group_id")
|
||||
startsAt DateTime @map("starts_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade)
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "class_sessions_groupId_fkey")
|
||||
attendances Attendance[]
|
||||
slotReleases SlotRelease[]
|
||||
|
||||
@@unique([groupId, startsAt])
|
||||
@@unique([groupId, startsAt], map: "class_sessions_groupId_startsAt_key")
|
||||
@@map("class_sessions")
|
||||
}
|
||||
|
||||
model Attendance {
|
||||
id String @id @default(cuid())
|
||||
attendeeId String
|
||||
classSessionId String
|
||||
attendeeId String @map("attendee_id")
|
||||
classSessionId String @map("class_session_id")
|
||||
status AttendanceStatus
|
||||
markedAt DateTime @default(now())
|
||||
markedAt DateTime @default(now()) @map("marked_at")
|
||||
|
||||
attendee Attendee @relation(fields: [attendeeId], references: [id], onDelete: Cascade)
|
||||
classSession ClassSession @relation(fields: [classSessionId], references: [id], onDelete: Cascade)
|
||||
attendee Attendee @relation(fields: [attendeeId], references: [id], onDelete: Cascade, map: "attendances_attendeeId_fkey")
|
||||
classSession ClassSession @relation(fields: [classSessionId], references: [id], onDelete: Cascade, map: "attendances_classSessionId_fkey")
|
||||
|
||||
@@unique([attendeeId, classSessionId])
|
||||
@@unique([attendeeId, classSessionId], map: "attendances_attendeeId_classSessionId_key")
|
||||
@@map("attendances")
|
||||
}
|
||||
|
||||
model SlotRelease {
|
||||
id String @id @default(cuid())
|
||||
attendeeId String
|
||||
classSessionId String
|
||||
isClaimed Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
attendeeId String @map("attendee_id")
|
||||
classSessionId String @map("class_session_id")
|
||||
isClaimed Boolean @default(false) @map("is_claimed")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
attendee Attendee @relation(fields: [attendeeId], references: [id], onDelete: Cascade)
|
||||
classSession ClassSession @relation(fields: [classSessionId], references: [id], onDelete: Cascade)
|
||||
attendee Attendee @relation(fields: [attendeeId], references: [id], onDelete: Cascade, map: "slot_releases_attendeeId_fkey")
|
||||
classSession ClassSession @relation(fields: [classSessionId], references: [id], onDelete: Cascade, map: "slot_releases_classSessionId_fkey")
|
||||
|
||||
@@unique([attendeeId, classSessionId])
|
||||
@@unique([attendeeId, classSessionId], map: "slot_releases_attendeeId_classSessionId_key")
|
||||
@@map("slot_releases")
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
// Auth (Better Auth) - required tables
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
email String @unique
|
||||
emailVerified Boolean @default(false)
|
||||
image String?
|
||||
onboardingCompleted Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
email String @unique
|
||||
emailVerified Boolean @default(false) @map("email_verified")
|
||||
image String?
|
||||
onboardingCompleted Boolean @default(false) @map("onboarding_completed")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
passkeys Passkey[]
|
||||
groupsMember GroupMember[]
|
||||
groupsOwner Group[] @relation("OwnerGroups")
|
||||
groupsOwner Group[] @relation("OwnerGroups")
|
||||
orgMemberships Member[]
|
||||
orgInvitations Invitation[] @relation("InvitedBy")
|
||||
orgInvitations Invitation[] @relation("InvitedBy")
|
||||
waitlist WaitlistEntry[]
|
||||
merchantAccount MerchantAccount?
|
||||
|
||||
@@ -24,40 +24,40 @@ model User {
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
providerId String
|
||||
accountId String
|
||||
id String @id @default(cuid())
|
||||
userId String @map("user_id")
|
||||
providerId String @map("provider_id")
|
||||
accountId String @map("account_id")
|
||||
issuer String
|
||||
accessToken String?
|
||||
refreshToken String?
|
||||
idToken String?
|
||||
accessTokenExpiresAt DateTime?
|
||||
refreshTokenExpiresAt DateTime?
|
||||
accessToken String? @map("access_token")
|
||||
refreshToken String? @map("refresh_token")
|
||||
idToken String? @map("id_token")
|
||||
accessTokenExpiresAt DateTime? @map("access_token_expires_at")
|
||||
refreshTokenExpiresAt DateTime? @map("refresh_token_expires_at")
|
||||
scope String?
|
||||
password String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "accounts_userId_fkey")
|
||||
|
||||
@@unique([issuer, accountId])
|
||||
@@index([userId])
|
||||
@@unique([issuer, accountId], map: "accounts_issuer_accountId_key")
|
||||
@@index([userId], map: "accounts_userId_idx")
|
||||
@@map("accounts")
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
userId String @map("user_id")
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
ipAddress String?
|
||||
userAgent String?
|
||||
activeOrganizationId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
expiresAt DateTime @map("expires_at")
|
||||
ipAddress String? @map("ip_address")
|
||||
userAgent String? @map("user_agent")
|
||||
activeOrganizationId String? @map("active_organization_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "sessions_userId_fkey")
|
||||
|
||||
@@map("sessions")
|
||||
}
|
||||
@@ -66,9 +66,9 @@ model Verification {
|
||||
id String @id @default(cuid())
|
||||
identifier String
|
||||
value String
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
expiresAt DateTime @map("expires_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@unique([identifier, value])
|
||||
@@map("verifications")
|
||||
@@ -81,8 +81,8 @@ model Organization {
|
||||
slug String @unique
|
||||
logo String?
|
||||
metadata Json?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
members Member[]
|
||||
invitations Invitation[]
|
||||
@@ -92,32 +92,32 @@ model Organization {
|
||||
|
||||
model Member {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
userId String
|
||||
organizationId String @map("organization_id")
|
||||
userId String @map("user_id")
|
||||
role String @default("member")
|
||||
createdAt DateTime @default(now())
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, map: "members_organizationId_fkey")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "members_userId_fkey")
|
||||
|
||||
@@unique([organizationId, userId])
|
||||
@@unique([organizationId, userId], map: "members_organizationId_userId_key")
|
||||
@@map("members")
|
||||
}
|
||||
|
||||
model Invitation {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organizationId String @map("organization_id")
|
||||
email String
|
||||
role String
|
||||
status String @default("pending")
|
||||
inviterId String
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
inviterId String @map("inviter_id")
|
||||
expiresAt DateTime @map("expires_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
inviter User @relation("InvitedBy", fields: [inviterId], references: [id], onDelete: Cascade)
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, map: "invitations_organizationId_fkey")
|
||||
inviter User @relation("InvitedBy", fields: [inviterId], references: [id], onDelete: Cascade, map: "invitations_inviterId_fkey")
|
||||
|
||||
@@index([organizationId])
|
||||
@@index([organizationId], map: "invitations_organizationId_idx")
|
||||
@@map("invitations")
|
||||
}
|
||||
|
||||
@@ -125,18 +125,18 @@ model Invitation {
|
||||
model Passkey {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
publicKey String
|
||||
credentialID String @unique
|
||||
userId String
|
||||
publicKey String @map("public_key")
|
||||
credentialID String @unique(map: "passkeys_credentialID_key") @map("credential_id")
|
||||
userId String @map("user_id")
|
||||
counter Int
|
||||
deviceType String
|
||||
backedUp Boolean
|
||||
deviceType String @map("device_type")
|
||||
backedUp Boolean @map("backed_up")
|
||||
transports String?
|
||||
createdAt DateTime @default(now())
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
aaguid String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "passkeys_userId_fkey")
|
||||
|
||||
@@index([userId])
|
||||
@@index([userId], map: "passkeys_userId_idx")
|
||||
@@map("passkeys")
|
||||
}
|
||||
@@ -1,27 +1,27 @@
|
||||
// Domain models
|
||||
|
||||
model Group {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
days WeekDay[]
|
||||
time String?
|
||||
capacity Int?
|
||||
price Decimal? @db.Decimal(10, 2)
|
||||
billingType BillingType?
|
||||
dueDay Int?
|
||||
inviteToken String? @unique
|
||||
createdById String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
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)
|
||||
members GroupMember[]
|
||||
attendees Attendee[]
|
||||
payments Payment[]
|
||||
waitlist GroupWaitlistEntry[]
|
||||
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[]
|
||||
classSessions ClassSession[]
|
||||
|
||||
@@map("groups")
|
||||
}
|
||||
@@ -42,16 +42,16 @@ enum BillingType {
|
||||
}
|
||||
|
||||
model GroupMember {
|
||||
id String @id @default(cuid())
|
||||
groupId String
|
||||
userId String
|
||||
role Role @default(MEMBER) // OWNER, ADMIN, MEMBER
|
||||
joinedAt DateTime @default(now())
|
||||
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)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
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])
|
||||
@@unique([groupId, userId], map: "group_members_groupId_userId_key")
|
||||
@@map("group_members")
|
||||
}
|
||||
|
||||
@@ -69,44 +69,44 @@ enum AttendeeStatus {
|
||||
|
||||
model Attendee {
|
||||
id String @id @default(cuid())
|
||||
groupId String
|
||||
fullName String
|
||||
groupId String @map("group_id")
|
||||
fullName String @map("full_name")
|
||||
email String?
|
||||
phone String?
|
||||
guardianName String?
|
||||
guardianPhone String?
|
||||
guardianName String? @map("guardian_name")
|
||||
guardianPhone String? @map("guardian_phone")
|
||||
notes String?
|
||||
notifyToken String? @unique @default(cuid())
|
||||
notifyToken String? @unique(map: "attendees_notifyToken_key") @default(cuid()) @map("notify_token")
|
||||
status AttendeeStatus @default(ACTIVE)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade)
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "attendees_groupId_fkey")
|
||||
payments Payment[]
|
||||
attendances Attendance[]
|
||||
slotReleases SlotRelease[]
|
||||
|
||||
@@index([groupId])
|
||||
@@index([groupId], map: "attendees_groupId_idx")
|
||||
@@map("attendees")
|
||||
}
|
||||
|
||||
model Payment {
|
||||
id String @id @default(cuid())
|
||||
groupId String
|
||||
attendeeId String
|
||||
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
|
||||
paidAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
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)
|
||||
attendee Attendee @relation(fields: [attendeeId], references: [id], onDelete: Cascade)
|
||||
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])
|
||||
@@index([attendeeId])
|
||||
@@index([groupId], map: "payments_groupId_idx")
|
||||
@@index([attendeeId], map: "payments_attendeeId_idx")
|
||||
@@map("payments")
|
||||
}
|
||||
|
||||
@@ -118,16 +118,16 @@ enum PaymentStatus {
|
||||
}
|
||||
|
||||
model WaitlistEntry {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
email String
|
||||
name String?
|
||||
status WaitlistStatus @default(PENDING) // PENDING, INVITED, JOINED, DECLINED
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
userId String? @unique
|
||||
userId String? @unique(map: "waitlist_entries_userId_key") @map("user_id")
|
||||
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: SetNull, map: "waitlist_entries_userId_fkey")
|
||||
|
||||
@@unique([email])
|
||||
@@map("waitlist_entries")
|
||||
@@ -135,19 +135,19 @@ model WaitlistEntry {
|
||||
|
||||
model GroupWaitlistEntry {
|
||||
id String @id @default(cuid())
|
||||
groupId String
|
||||
fullName String
|
||||
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())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade)
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "group_waitlist_entries_groupId_fkey")
|
||||
|
||||
@@unique([groupId, phone])
|
||||
@@index([groupId])
|
||||
@@unique([groupId, phone], map: "group_waitlist_entries_groupId_phone_key")
|
||||
@@index([groupId], map: "group_waitlist_entries_groupId_idx")
|
||||
@@map("group_waitlist_entries")
|
||||
}
|
||||
|
||||
@@ -165,20 +165,20 @@ enum PreRegistrationStatus {
|
||||
}
|
||||
|
||||
model GroupPreRegistration {
|
||||
id String @id @default(cuid())
|
||||
groupId String
|
||||
fullName String
|
||||
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?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
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)
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "group_pre_registrations_groupId_fkey")
|
||||
|
||||
@@unique([groupId, phone])
|
||||
@@index([groupId])
|
||||
@@unique([groupId, phone], map: "group_pre_registrations_groupId_phone_key")
|
||||
@@index([groupId], map: "group_pre_registrations_groupId_idx")
|
||||
@@map("group_pre_registrations")
|
||||
}
|
||||
|
||||
@@ -189,15 +189,15 @@ enum PaymentProvider {
|
||||
|
||||
model MerchantAccount {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
userId String @unique(map: "merchant_accounts_userId_key") @map("user_id")
|
||||
provider PaymentProvider
|
||||
accessToken String?
|
||||
accessToken String? @map("access_token")
|
||||
sandbox Boolean @default(true)
|
||||
connectedAt DateTime @default(now())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
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)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "merchant_accounts_userId_fkey")
|
||||
|
||||
@@map("merchant_accounts")
|
||||
}
|
||||
Reference in New Issue
Block a user