Base de donnees
Base de donnees
Vue d'ensemble du schema PostgreSQL et de l'ORM Prisma dans etouch
etouch utilise PostgreSQL avec Prisma ORM. Le schema est defini dans packages/db/prisma/schema.prisma.
┌──────────────┐ ┌──────────────────┐ ┌─────────────┐
│ Organization │────>│ UserOrganization │<────│ User │
└──────────────┘ └──────────────────┘ └─────────────┘
│ │
├── Projects ─────────────── Assets ──── RetouchVersions
├── GuidelineFiles │
├── Invoices ──── InvoiceItems UploadSessions
├── Payments │
└── Notifications ─── NotificationRecipients ─┘
| Modele | Description | Table |
|---|
Organization | Organisations multi-tenant (studio, client, retoucher, platform) | Organization |
User | Utilisateurs avec appartenance multi-organisations | User |
UserOrganization | Jointure utilisateur-organisation avec roles | UserOrganization |
Project | Projets de retouche avec machine a etats workflow | Project |
Asset | Fichiers individuels (photos, videos, documents) | Asset |
GuidelineFile | Specifications et images de reference pour la retouche | GuidelineFile |
RetouchRound | Rounds de retouche (iterations) | RetouchRound |
RetouchVersion | Versions de retouche par asset | RetouchVersion |
Comment | Commentaires sur projets et assets | Comment |
WorkflowEvent | Historique des transitions workflow | WorkflowEvent |
| Modele | Description |
|---|
Invoice | Factures integrees Stripe |
InvoiceItem | Lignes de facture |
Payment | Transactions de paiement |
ProjectPricingItem | Tarification par projet |
RetouchCategory | Categories de retouche (studio) |
ClientPricing | Tarifs client par studio |
GuidelinePricingCategory | Categories de prix des guidelines |
GuidelineOrganizationPrice | Prix des guidelines par organisation |
| Modele | Description |
|---|
Notification | Notifications multi-canal |
NotificationRecipient | Livraison par utilisateur |
| Modele | Description |
|---|
Session | Sessions Better Auth avec org active |
Account | Liaison de comptes OAuth |
Verification | Tokens de verification |
Invitation | Invitations utilisateurs |
| Modele | Description |
|---|
IntegrationInstallation | Installations d'integrations par org |
ImportJob | Jobs d'import (Pennylane, etc.) |
FtpSyncJob | Jobs de synchronisation FTP |
| Enum | Valeurs |
|---|
OrganizationType | PLATFORM, STUDIO, CLIENT, RETOUCHER |
UserRole | SUPER_ADMIN, ADMIN, PLATFORM_ADMIN, STUDIO_ADMIN, STUDIO_USER, CLIENT_ADMIN, CLIENT_USER, RETOUCH_ADMIN, RETOUCH_USER |
ProjectWorkflowState | STUDIO_REVIEW, CLIENT_REVIEW, SELECTION_CONFIRMATION, IN_RETOUCH, CLIENT_VALIDATION, DONE, ARCHIVED |
AssetType | PHOTO, VIDEO, DOCUMENT |
AssetStatus | UPLOADING, UPLOADED, PROCESSING, READY, DELIVERED, ARCHIVED |
PaymentStatus | UNPAID, PAID, PENDING, PROCESSING, SUCCEEDED, FAILED, CANCELED, REFUNDED |
InvoiceStatus | DRAFT, OPEN, PAID, VOID, UNCOLLECTIBLE |
-- Organizations
@@index([parentOrganizationId])
@@index([stripeCustomerId])
-- Users
@@index([email])
-- Projects
@@index([studioId])
@@index([clientId])
@@index([workflowState])
@@index([publicToken])
-- Assets
@@index([projectId, status])
@@index([projectId, extraFormat])
@@index([assetType])
-- Notifications
@@index([organizationId])
@@index([projectId])
@@index([createdAt])
# Generer le client Prisma
pnpm prisma:generate
# Appliquer les migrations
pnpm prisma:migrate
# Creer une nouvelle migration
pnpm --filter @etouch/db db:migrate:dev --name nom_migration
# Ouvrir Prisma Studio
pnpm prisma:studio
# Migration securisee (avec backup)
pnpm db:migrate:safe
Le projet utilise prisma migrate deploy (pas de shadow database).