Outils pour utilisateurs

Outils du site


ujusum:3-codage:1-repository:2-prisma-schema

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
ujusum:3-codage:1-repository:2-prisma-schema [2026/06/07 04:44] – créée 91.170.108.99ujusum:3-codage:1-repository:2-prisma-schema [2026/06/07 05:27] (Version actuelle) 91.170.108.99
Ligne 1: Ligne 1:
-====== Gestion Git complète du projet ======+====== Phase 2 — Prisma Schema ======
  
 ===== Objectif ===== ===== Objectif =====
  
-Mettre en place un dépôt Git professionnel prêt pour :+Construire le schéma Prisma qui deviendra la source de vérité unique du système.
  
-  * Développement multi-développeurs +À partir de ce schéma seront générés :
-  * CI/CD +
-  * Revue de code +
-  * Releases +
-  * Hotfixes +
-  * Déploiements automatiques+
  
-À la fin de cette procédure :+  * PostgreSQL 
 +  * Prisma Client 
 +  * DTO 
 +  * Entités NestJS 
 +  * OpenAPI 
 +  * SDK TypeScript 
 +  * Migrations SQL 
 + 
 +Le schéma doit refléter l'intégralité des domaines définis dans les 20 sprints. 
 + 
 +---- 
 + 
 +====== Objectifs techniques ====== 
 + 
 +Le schéma Prisma doit supporter :
  
 <code> <code>
-Git local+Multi-tenant
  
-GitHub+Audit
  
-Branches+Historisation
  
-Protection+Soft Delete
  
-CI+RBAC
  
-Versioning+CRM
  
-Templates+Catalogue
  
-Hooks+Réservations
  
-Documentation+Paiements 
 + 
 +Contrats 
 + 
 +OTA 
 + 
 +IA 
 + 
 +Revenue Management 
 + 
 +Internationalisation 
 + 
 +Sécurité Enterprise
 </code> </code>
  
-seront opérationnels.+---- 
 + 
 +====== Ordre de construction recommandé ====== 
 + 
 +Ne jamais commencer par les 80 tables. 
 + 
 +Construire par couches.
  
 ---- ----
  
-====== Étape 1 — Initialisation locale ======+===== Couche 1 — Fondations =====
  
-===== Création du dépôt =====+Construire en premier :
  
-<code bash+<code> 
-mkdir rental-platform+Tenant 
 + 
 +User 
 + 
 +Role 
 + 
 +Permission
  
-cd rental-platform+UserRole
  
-git init+RolePermission
 </code> </code>
 +
 +Ces tables sont nécessaires partout.
  
 ---- ----
  
-===== Vérification =====+===== Couche 2 — Référentiels =====
  
-<code bash+Créer : 
-git status+ 
 +<code> 
 +Address 
 + 
 +Country 
 + 
 +Language 
 + 
 +Currency 
 + 
 +Timezone
 </code> </code>
  
-Résultat :+---- 
 + 
 +===== Couche 3 — Catalogue ===== 
 + 
 +Créer :
  
 <code> <code>
-On branch main+Property 
 + 
 +PropertyType 
 + 
 +PropertyMedia 
 + 
 +PropertyFeature 
 + 
 +PropertyAvailability
  
-No commits yet+PropertyRate
 </code> </code>
  
 ---- ----
  
-====== Étape 2 — Configuration Git globale ======+===== Couche 4 — Réservations =====
  
-===== Vérifier =====+Créer :
  
-<code bash+<code> 
-git config --global user.name+Reservation 
 + 
 +ReservationGuest 
 + 
 +ReservationStatus
  
-git config --global user.email+ReservationEvent
 </code> </code>
  
 ---- ----
  
-===== Configurer =====+===== Couche 5 — Contrats =====
  
-<code bash> +Créer :
-git config --global user.name "Votre Nom"+
  
-git config --global user.email "email@domaine.com"+<code> 
 +Contract 
 + 
 +ContractTemplate 
 + 
 +ContractSignature 
 + 
 +Document
 </code> </code>
  
 ---- ----
  
-===== Configuration utile =====+===== Couche 6 — Paiements =====
  
-<code bash+Créer : 
-git config --global init.defaultBranch main+ 
 +<code> 
 +Payment 
 + 
 +Invoice
  
-git config --global pull.rebase false+Refund
  
-git config --global core.autocrlf input+AccountingEntry
 </code> </code>
  
 ---- ----
  
-====== Étape 3 — Création du dépôt GitHub ======+===== Couche 7 — CRM =====
  
 Créer : Créer :
  
 <code> <code>
-rental-platform+Lead 
 + 
 +Customer 
 + 
 +Activity 
 + 
 +Task 
 + 
 +Pipeline
 </code> </code>
  
-Options :+----
  
-<code> +===== Couche 8 — Propriétaires =====
-Private+
  
-README+Créer : 
 + 
 +<code> 
 +Owner
  
-.gitignore = Node+OwnerProperty
  
-License = MIT (ou propriétaire)+OwnerDocument
 </code> </code>
  
 ---- ----
  
-===== Ajouter le remote =====+===== Couche 9 — Notifications =====
  
-<code bash+Créer : 
-git remote add origin git@github.com:organisation/rental-platform.git+ 
 +<code> 
 +Notification 
 + 
 +NotificationTemplate 
 + 
 +Message 
 + 
 +Campaign
 </code> </code>
  
 ---- ----
  
-===== Vérifier =====+===== Couche 10 — Administration =====
  
-<code bash+Créer : 
-git remote -v+ 
 +<code> 
 +AuditLog 
 + 
 +FeatureFlag 
 + 
 +CustomField 
 + 
 +Workflow
 </code> </code>
  
 ---- ----
  
-====== Étape 4 — Génération de la clé SSH ======+===== Couche 11 — IA =====
  
-===== Vérifier =====+Créer :
  
-<code bash+<code> 
-ls ~/.ssh+AiConversation 
 + 
 +AiMessage 
 + 
 +KnowledgeDocument 
 + 
 +AutomationRule
 </code> </code>
  
 ---- ----
  
-===== Générer =====+===== Couche 12 — OTA =====
  
-<code bash+Créer : 
-ssh-keygen -t ed25519 \ + 
--C "email@domaine.com"+<code> 
 +Channel 
 + 
 +ChannelConnection 
 + 
 +PropertyDistribution 
 + 
 +ChannelReservation
 </code> </code>
  
 ---- ----
  
-===== Afficher =====+===== Couche 13 — Revenue Management =====
  
-<code bash+Créer : 
-cat ~/.ssh/id_ed25519.pub+ 
 +<code> 
 +PricingRule 
 + 
 +DynamicPrice 
 + 
 +RevenueSimulation 
 + 
 +CompetitorSnapshot
 </code> </code>
  
 ---- ----
  
-===== Ajouter dans GitHub =====+===== Couche 14 — Sécurité ===== 
 + 
 +Créer :
  
 <code> <code>
-Settings+Consent
  
-SSH Keys+SecurityPolicy
  
-New SSH Key+Risk 
 + 
 +ComplianceAudit
 </code> </code>
  
 ---- ----
  
-===== Tester =====+===== Couche 15 — Internationalisation =====
  
-<code bash+Créer : 
-ssh -T git@github.com+ 
 +<code> 
 +Translation 
 + 
 +CurrencyRate 
 + 
 +Region 
 + 
 +EnterpriseLicense
 </code> </code>
  
 ---- ----
  
-====== Étape 5 — Création du .gitignore ======+====== Organisation du dossier Prisma ======
  
-===== Racine =====+Au lieu d'un unique fichier géant :
  
 <code> <code>
-.gitignore+prisma/ 
 + 
 +├── schema.prisma 
 +│ 
 +├── models/ 
 +│ 
 +│   ├── tenant.prisma 
 +│   ├── user.prisma 
 +│   ├── property.prisma 
 +│   ├── reservation.prisma 
 +│   ├── contract.prisma 
 +│   ├── payment.prisma 
 +│   ├── crm.prisma 
 +│   ├── owner.prisma 
 +│   ├── notification.prisma 
 +│   ├── audit.prisma 
 +│   ├── ai.prisma 
 +│   ├── channel.prisma 
 +│   ├── revenue.prisma 
 +│   ├── security.prisma 
 +│   └── localization.prisma
 </code> </code>
  
 ---- ----
  
-===== Contenu =====+====== Configuration initiale ====== 
 + 
 +===== schema.prisma ===== 
 + 
 +Version minimale : 
 + 
 +<code prisma> 
 +generator client { 
 +  provider = "prisma-client-js" 
 +
 + 
 +datasource db { 
 +  provider = "postgresql" 
 +  url      = env("DATABASE_URL"
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Première implémentation ====== 
 + 
 +===== Étape 1 ===== 
 + 
 +Créer :
  
 <code> <code>
-node_modules/+prisma/models/tenant.prisma 
 +</code>
  
-dist/+----
  
-.next/+===== Tenant =====
  
-coverage/+<code prisma> 
 +model Tenant {
  
-.env+  id            String   @id @default(uuid())
  
-.env.*+  code          String   @unique
  
-*.log+  name          String
  
-.prisma/client+  status        TenantStatus
  
-.idea/+  createdAt     DateTime @default(now())
  
-.vscode/+  updatedAt     DateTime @updatedAt
  
-.DS_Store+  users         User[]
  
-tmp/+  properties    Property[]
  
-.cache/+}
 </code> </code>
  
 ---- ----
  
-====== Étape 6 — README principal ======+===== Enum =====
  
-===== Créer =====+<code prisma> 
 +enum TenantStatus { 
 + 
 +  ACTIVE 
 + 
 +  SUSPENDED 
 + 
 +  TRIAL 
 + 
 +  ARCHIVED 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Étape 2 ====== 
 + 
 +Créer :
  
 <code> <code>
-README.md+prisma/models/user.prisma
 </code> </code>
  
 ---- ----
  
-===== Contenu minimal =====+===== User =====
  
-<code markdown+<code prisma
-# Rental Platform+model User {
  
-Property Management System+  id              String @id @default(uuid())
  
-## Installation+  tenantId        String
  
-docker compose up+  email           String @unique
  
-## Documentation+  passwordHash    String
  
-/swagger+  firstName       String
  
-## Architecture+  lastName        String
  
-NestJS +  active          Boolean @default(true) 
-NextJS + 
-Prisma +  createdAt       DateTime @default(now()) 
-PostgreSQL + 
-Redis+  updatedAt       DateTime @updatedAt 
 + 
 +  tenant          Tenant @relation( 
 +                    fields:[tenantId], 
 +                    references:[id] 
 +                  ) 
 + 
 +  roles           UserRole[] 
 + 
 +}
 </code> </code>
  
 ---- ----
  
-====== Étape 7 — Premier commit ======+===== Role ===== 
 + 
 +<code prisma> 
 +model Role { 
 + 
 +  id            String @id @default(uuid()) 
 + 
 +  code          String @unique 
 + 
 +  name          String 
 + 
 +  userRoles     UserRole[] 
 + 
 +  permissions   RolePermission[] 
 +
 +</code> 
 + 
 +---- 
 + 
 +===== Permission ===== 
 + 
 +<code prisma> 
 +model Permission { 
 + 
 +  id            String @id @default(uuid()) 
 + 
 +  code          String @unique 
 + 
 +  name          String 
 + 
 +  rolePermissions RolePermission[] 
 +
 +</code> 
 + 
 +---- 
 + 
 +===== UserRole ===== 
 + 
 +<code prisma> 
 +model UserRole { 
 + 
 +  userId        String 
 + 
 +  roleId        String 
 + 
 +  assignedAt    DateTime @default(now()) 
 + 
 +  user          User @relation( 
 +                  fields:[userId], 
 +                  references:[id] 
 +                ) 
 + 
 +  role          Role @relation( 
 +                  fields:[roleId], 
 +                  references:[id] 
 +                ) 
 + 
 +  @@id([userId, roleId]) 
 +
 +</code> 
 + 
 +---- 
 + 
 +===== RolePermission ===== 
 + 
 +<code prisma> 
 +model RolePermission { 
 + 
 +  roleId        String 
 + 
 +  permissionId  String 
 + 
 +  role          Role @relation( 
 +                  fields:[roleId], 
 +                  references:[id] 
 +                ) 
 + 
 +  permission    Permission @relation( 
 +                  fields:[permissionId], 
 +                  references:[id] 
 +                ) 
 + 
 +  @@id([roleId, permissionId]) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Génération ====== 
 + 
 +Après chaque bloc important :
  
 <code bash> <code bash>
-git add .+npx prisma format 
 +</code>
  
-git commit -m "chore: initial repository setup"+---- 
 + 
 +===== Validation ===== 
 + 
 +<code bash> 
 +npx prisma validate
 </code> </code>
  
 ---- ----
  
-===== Push =====+===== Génération Client =====
  
 <code bash> <code bash>
-git push -u origin main+npx prisma generate
 </code> </code>
  
 ---- ----
  
-====== Étape 8 — Protection de branche ======+===== Migration =====
  
-===== GitHub =====+<code bash> 
 +npx prisma migrate dev \ 
 +--name init_security 
 +</code> 
 + 
 +---- 
 + 
 +====== Vérification ====== 
 + 
 +Ouvrir : 
 + 
 +<code bash> 
 +npx prisma studio 
 +</code> 
 + 
 +Vérifier la présence :
  
 <code> <code>
-Settings+Tenant 
 + 
 +User 
 + 
 +Role 
 + 
 +Permission
  
-Branches+UserRole
  
-Add Rule+RolePermission
 </code> </code>
  
 ---- ----
  
-===== Branche =====+====== Phase 2-A — Fondation complète (Tenant + RBAC + Propriétés de sécurité) ====== 
 + 
 +Vous avez raison. 
 + 
 +La version précédente contient : 
 + 
 +  * Tenant 
 +  * User 
 +  * Role 
 +  * Permission 
 +  * UserRole 
 +  * RolePermission 
 + 
 +mais il manque plusieurs éléments indispensables pour un véritable système Enterprise : 
 + 
 +  * propriétés du compte utilisateur 
 +  * préférences utilisateur 
 +  * sessions 
 +  * refresh tokens 
 +  * MFA 
 +  * audit de connexion 
 +  * catalogue complet des permissions 
 + 
 +Sans ces éléments, le Sprint 1 (Authentification) et le Sprint 19 (Sécurité Enterprise) ne pourront pas être implémentés proprement. 
 + 
 +---- 
 + 
 +====== Modèle User complet ====== 
 + 
 +===== User ===== 
 + 
 +<code prisma> 
 +model User { 
 + 
 +  id                String      @id @default(uuid()) 
 + 
 +  tenantId          String 
 + 
 +  email             String      @unique 
 + 
 +  passwordHash      String 
 + 
 +  firstName         String 
 + 
 +  lastName          String 
 + 
 +  phone             String? 
 + 
 +  avatarUrl         String? 
 + 
 +  languageCode      String? 
 + 
 +  timezoneCode      String? 
 + 
 +  active            Boolean     @default(true) 
 + 
 +  emailVerified     Boolean     @default(false) 
 + 
 +  lastLoginAt       DateTime? 
 + 
 +  createdAt         DateTime    @default(now()) 
 + 
 +  updatedAt         DateTime    @updatedAt 
 + 
 +  deletedAt         DateTime? 
 + 
 +  tenant            Tenant      @relation( 
 +                                  fields:[tenantId], 
 +                                  references:[id] 
 +                                ) 
 + 
 +  roles             UserRole[] 
 + 
 +  sessions          UserSession[] 
 + 
 +  refreshTokens     RefreshToken[] 
 + 
 +  preferences       UserPreference? 
 + 
 +  loginHistory      LoginHistory[] 
 + 
 +  mfaMethods        UserMfaMethod[] 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Préférences utilisateur ====== 
 + 
 +===== UserPreference ===== 
 + 
 +<code prisma> 
 +model UserPreference { 
 + 
 +  id                String      @id @default(uuid()) 
 + 
 +  userId            String      @unique 
 + 
 +  theme             String? 
 + 
 +  language          String? 
 + 
 +  timezone          String? 
 + 
 +  notifications     Json? 
 + 
 +  createdAt         DateTime    @default(now()) 
 + 
 +  updatedAt         DateTime    @updatedAt 
 + 
 +  user              User @relation( 
 +                        fields:[userId], 
 +                        references:[id] 
 +                      ) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Gestion des sessions ====== 
 + 
 +===== UserSession ===== 
 + 
 +<code prisma> 
 +model UserSession { 
 + 
 +  id                String      @id @default(uuid()) 
 + 
 +  userId            String 
 + 
 +  ipAddress         String? 
 + 
 +  userAgent         String? 
 + 
 +  country           String? 
 + 
 +  city              String? 
 + 
 +  lastActivityAt    DateTime 
 + 
 +  expiresAt         DateTime 
 + 
 +  revokedAt         DateTime? 
 + 
 +  createdAt         DateTime    @default(now()) 
 + 
 +  user              User @relation( 
 +                        fields:[userId], 
 +                        references:[id] 
 +                      ) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Refresh Tokens ====== 
 + 
 +===== RefreshToken ===== 
 + 
 +<code prisma> 
 +model RefreshToken { 
 + 
 +  id                String      @id @default(uuid()) 
 + 
 +  userId            String 
 + 
 +  tokenHash         String 
 + 
 +  expiresAt         DateTime 
 + 
 +  revokedAt         DateTime? 
 + 
 +  createdAt         DateTime    @default(now()) 
 + 
 +  user              User @relation( 
 +                        fields:[userId], 
 +                        references:[id] 
 +                      ) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Historique des connexions ====== 
 + 
 +===== LoginHistory ===== 
 + 
 +<code prisma> 
 +model LoginHistory { 
 + 
 +  id                String      @id @default(uuid()) 
 + 
 +  userId            String 
 + 
 +  success           Boolean 
 + 
 +  ipAddress         String? 
 + 
 +  userAgent         String? 
 + 
 +  country           String? 
 + 
 +  city              String? 
 + 
 +  createdAt         DateTime @default(now()) 
 + 
 +  user              User @relation( 
 +                        fields:[userId], 
 +                        references:[id] 
 +                      ) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== MFA ====== 
 + 
 +===== UserMfaMethod ===== 
 + 
 +<code prisma> 
 +model UserMfaMethod { 
 + 
 +  id                String      @id @default(uuid()) 
 + 
 +  userId            String 
 + 
 +  methodType        String 
 + 
 +  secret            String? 
 + 
 +  enabled           Boolean     @default(true) 
 + 
 +  createdAt         DateTime    @default(now()) 
 + 
 +  user              User @relation( 
 +                        fields:[userId], 
 +                        references:[id] 
 +                      ) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== RBAC Enterprise ====== 
 + 
 +===== Role ===== 
 + 
 +<code prisma> 
 +model Role { 
 + 
 +  id                String      @id @default(uuid()) 
 + 
 +  code              String      @unique 
 + 
 +  name              String 
 + 
 +  description       String? 
 + 
 +  systemRole        Boolean     @default(false) 
 + 
 +  createdAt         DateTime    @default(now()) 
 + 
 +  updatedAt         DateTime    @updatedAt 
 + 
 +  userRoles         UserRole[] 
 + 
 +  permissions       RolePermission[] 
 +
 +</code> 
 + 
 +---- 
 + 
 +===== Permission ===== 
 + 
 +<code prisma> 
 +model Permission { 
 + 
 +  id                String      @id @default(uuid()) 
 + 
 +  code              String      @unique 
 + 
 +  name              String 
 + 
 +  description       String? 
 + 
 +  module            String 
 + 
 +  createdAt         DateTime    @default(now()) 
 + 
 +  rolePermissions   RolePermission[] 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Catalogue initial des permissions ====== 
 + 
 +===== Auth =====
  
 <code> <code>
-main+AUTH_LOGIN 
 + 
 +AUTH_REGISTER 
 + 
 +AUTH_RESET_PASSWORD 
 + 
 +AUTH_MANAGE_USERS
 </code> </code>
  
 ---- ----
  
-===== Activer =====+===== Users =====
  
 <code> <code>
-Require Pull Request+USER_READ
  
-Require Status Checks+USER_CREATE
  
-Require Review+USER_UPDATE
  
-Dismiss Stale Reviews+USER_DELETE 
 +</code> 
 + 
 +---- 
 + 
 +===== Properties ===== 
 + 
 +<code> 
 +PROPERTY_READ 
 + 
 +PROPERTY_CREATE 
 + 
 +PROPERTY_UPDATE 
 + 
 +PROPERTY_DELETE
  
-Prevent Force Push+PROPERTY_PUBLISH
 </code> </code>
  
 ---- ----
  
-====== Étape 9 — Stratégie Git ======+===== Reservations =====
  
-===== Branches permanentes =====+<code> 
 +RESERVATION_READ 
 + 
 +RESERVATION_CREATE 
 + 
 +RESERVATION_UPDATE 
 + 
 +RESERVATION_CANCEL 
 +</code> 
 + 
 +---- 
 + 
 +===== Contracts =====
  
 <code> <code>
-main+CONTRACT_READ 
 + 
 +CONTRACT_CREATE
  
-develop+CONTRACT_SIGN
 </code> </code>
  
 ---- ----
  
-===== Création =====+===== Payments =====
  
-<code bash+<code> 
-git checkout -b develop+PAYMENT_READ 
 + 
 +PAYMENT_CREATE
  
-git push -u origin develop+PAYMENT_REFUND
 </code> </code>
  
 ---- ----
  
-===== Branches temporaires =====+===== CRM =====
  
 <code> <code>
-feature/auth-module+CRM_READ
  
-feature/user-module+CRM_WRITE
  
-feature/property-module+CRM_EXPORT 
 +</code>
  
-bugfix/login+----
  
-hotfix/security+===== Administration ===== 
 + 
 +<code> 
 +ADMIN_READ 
 + 
 +ADMIN_WRITE 
 + 
 +ADMIN_AUDIT 
 + 
 +ADMIN_TENANT 
 +</code> 
 + 
 +---- 
 + 
 +====== Rôles système ====== 
 + 
 +===== SUPER_ADMIN ===== 
 + 
 +Accès complet plateforme. 
 + 
 +---- 
 + 
 +===== TENANT_ADMIN ===== 
 + 
 +Administration d'agence. 
 + 
 +---- 
 + 
 +===== AGENCY_MANAGER ===== 
 + 
 +Gestion opérationnelle. 
 + 
 +---- 
 + 
 +===== OWNER ===== 
 + 
 +Extranet propriétaire. 
 + 
 +---- 
 + 
 +===== AGENT ===== 
 + 
 +Collaborateur. 
 + 
 +---- 
 + 
 +===== CUSTOMER ===== 
 + 
 +Client final. 
 + 
 +---- 
 + 
 +====== Indexes recommandés ====== 
 + 
 +===== User ===== 
 + 
 +<code prisma> 
 +@@index([tenantId]) 
 + 
 +@@index([email]) 
 + 
 +@@index([active]) 
 +</code> 
 + 
 +---- 
 + 
 +===== LoginHistory ===== 
 + 
 +<code prisma> 
 +@@index([userId]) 
 + 
 +@@index([createdAt]) 
 +</code> 
 + 
 +---- 
 + 
 +===== UserSession ===== 
 + 
 +<code prisma> 
 +@@index([userId]) 
 + 
 +@@index([expiresAt])
 </code> </code>
  
 ---- ----
  
-====== Étape 10 — Convention de commits ======+====== Architecture du domaine Property ======
  
-===== Format =====+===== Entités =====
  
 <code> <code>
-type(scope)description+Property 
 + 
 +PropertyType 
 + 
 +PropertyStatus 
 + 
 +PropertyAddress 
 + 
 +PropertyFeature 
 + 
 +PropertyMedia 
 + 
 +PropertyAvailability 
 + 
 +PropertyRate 
 + 
 +PropertyOwner 
 +</code> 
 + 
 +---- 
 + 
 +====== Property ====== 
 + 
 +===== Table principale ===== 
 + 
 +<code prisma> 
 +model Property { 
 + 
 +  id                    String @id @default(uuid()
 + 
 +  tenantId              String 
 + 
 +  propertyTypeId        String 
 + 
 +  code                  String @unique 
 + 
 +  reference             String? 
 + 
 +  title                 String 
 + 
 +  slug                  String @unique 
 + 
 +  description           String? 
 + 
 +  shortDescription      String? 
 + 
 +  maxGuests             Int 
 + 
 +  bedrooms              Int 
 + 
 +  bathrooms             Int 
 + 
 +  area                  Decimal? @db.Decimal(10,2) 
 + 
 +  floor                 Int? 
 + 
 +  constructionYear      Int? 
 + 
 +  checkInTime           String? 
 + 
 +  checkOutTime          String? 
 + 
 +  active                Boolean @default(true) 
 + 
 +  published             Boolean @default(false) 
 + 
 +  createdAt             DateTime @default(now()) 
 + 
 +  updatedAt             DateTime @updatedAt 
 + 
 +  deletedAt             DateTime? 
 + 
 +  tenant                Tenant @relation( 
 +                            fields:[tenantId], 
 +                            references:[id] 
 +                         ) 
 + 
 +  propertyType          PropertyType @relation( 
 +                            fields:[propertyTypeId], 
 +                            references:[id] 
 +                         ) 
 + 
 +  address               PropertyAddress? 
 + 
 +  features              PropertyFeature[] 
 + 
 +  media                 PropertyMedia[] 
 + 
 +  availabilities        PropertyAvailability[] 
 + 
 +  rates                 PropertyRate[] 
 + 
 +  owners                PropertyOwner[] 
 + 
 +  reservations         Reservation[] 
 + 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== PropertyType ====== 
 + 
 +===== Référentiel ===== 
 + 
 +<code prisma> 
 +model PropertyType { 
 + 
 +  id                String @id @default(uuid()) 
 + 
 +  code              String @unique 
 + 
 +  name              String 
 + 
 +  properties        Property[] 
 +}
 </code> </code>
  
 ---- ----
  
-===== Types =====+===== Valeurs =====
  
 <code> <code>
-feat+HOUSE
  
-fix+APARTMENT
  
-refactor+VILLA
  
-perf+STUDIO
  
-docs+LOFT
  
-test+CHALET
  
-chore+COTTAGE
  
-build+MOBILE_HOME 
 +</code>
  
-ci+---- 
 + 
 +====== PropertyAddress ====== 
 + 
 +===== Adresse du bien ===== 
 + 
 +<code prisma> 
 +model PropertyAddress { 
 + 
 +  id                String @id @default(uuid()) 
 + 
 +  propertyId        String @unique 
 + 
 +  addressLine1      String 
 + 
 +  addressLine2      String? 
 + 
 +  postalCode        String 
 + 
 +  city              String 
 + 
 +  state             String? 
 + 
 +  countryCode       String 
 + 
 +  latitude          Decimal? @db.Decimal(10,7) 
 + 
 +  longitude         Decimal? @db.Decimal(10,7) 
 + 
 +  property          Property @relation( 
 +                      fields:[propertyId], 
 +                      references:[id] 
 +                    ) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== PropertyFeature ====== 
 + 
 +===== Équipements ===== 
 + 
 +<code prisma> 
 +model PropertyFeature { 
 + 
 +  id                String @id @default(uuid()) 
 + 
 +  propertyId        String 
 + 
 +  featureCode       String 
 + 
 +  featureValue      String? 
 + 
 +  property          Property @relation( 
 +                      fields:[propertyId], 
 +                      references:[id] 
 +                    ) 
 +}
 </code> </code>
  
Ligne 396: Ligne 1302:
  
 <code> <code>
-feat(auth): add login endpoint+POOL 
 + 
 +WIFI 
 + 
 +PARKING 
 + 
 +AIR_CONDITIONING
  
-feat(users): add profile page+TERRACE
  
-fix(jwt): refresh token validation+SEA_VIEW
  
-docs(api): update swagger+PET_ALLOWED
 </code> </code>
  
 ---- ----
  
-====== Étape 11 — Commitlint ======+====== PropertyMedia ======
  
-===== Installation =====+===== Médias =====
  
-<code bash+<code prisma
-npm install -D \ +model PropertyMedia { 
-@commitlint/cli \ + 
-@commitlint/config-conventional+  id                String @id @default(uuid()) 
 + 
 +  propertyId        String 
 + 
 +  fileName          String 
 + 
 +  fileUrl           String 
 + 
 +  mediaType         String 
 + 
 +  position          Int 
 + 
 +  isCover           Boolean @default(false) 
 + 
 +  createdAt         DateTime @default(now()) 
 + 
 +  property          Property @relation( 
 +                      fields:[propertyId], 
 +                      references:[id] 
 +                    ) 
 +}
 </code> </code>
  
 ---- ----
  
-===== commitlint.config.js =====+===== MediaType =====
  
-<code javascript+<code> 
-module.exports = { +IMAGE 
-  extends: [ + 
-    '@commitlint/config-conventional' +VIDEO 
-  ]+ 
 +VIRTUAL_TOUR 
 + 
 +DOCUMENT 
 +</code> 
 + 
 +---- 
 + 
 +====== PropertyAvailability ====== 
 + 
 +===== Calendrier ===== 
 + 
 +<code prisma> 
 +model PropertyAvailability 
 + 
 +  id                String @id @default(uuid()) 
 + 
 +  propertyId        String 
 + 
 +  startDate         DateTime 
 + 
 +  endDate           DateTime 
 + 
 +  status            AvailabilityStatus 
 + 
 +  property          Property @relation( 
 +                      fields:[propertyId]
 +                      references:[id] 
 +                    )
 } }
 </code> </code>
Ligne 431: Ligne 1391:
 ---- ----
  
-====== Étape 12 — Husky ======+===== Enum =====
  
-===== Installation =====+<code prisma> 
 +enum AvailabilityStatus {
  
-<code bash> +  AVAILABLE 
-npm install -D husky+ 
 +  RESERVED 
 + 
 +  BLOCKED 
 + 
 +  MAINTENANCE 
 +}
 </code> </code>
  
 ---- ----
  
-===== Initialisation =====+====== PropertyRate ======
  
-<code bash+===== Tarification ===== 
-npx husky init+ 
 +<code prisma
 +model PropertyRate { 
 + 
 +  id                String @id @default(uuid()) 
 + 
 +  propertyId        String 
 + 
 +  startDate         DateTime 
 + 
 +  endDate           DateTime 
 + 
 +  nightlyRate       Decimal @db.Decimal(10,2) 
 + 
 +  weekendRate       Decimal? @db.Decimal(10,2) 
 + 
 +  cleaningFee       Decimal? @db.Decimal(10,2) 
 + 
 +  securityDeposit   Decimal? @db.Decimal(10,2) 
 + 
 +  currencyCode      String 
 + 
 +  property          Property @relation( 
 +                      fields:[propertyId], 
 +                      references:[id] 
 +                    ) 
 +}
 </code> </code>
  
 ---- ----
  
-===== Hook pre-commit =====+====== PropertyOwner ======
  
-<code> +===== Association propriétaire ===== 
-.husky/pre-commit+ 
 +<code prisma
 +model PropertyOwner { 
 + 
 +  propertyId        String 
 + 
 +  ownerId           String 
 + 
 +  ownershipRate     Decimal @db.Decimal(5,2) 
 + 
 +  property          Property @relation( 
 +                      fields:[propertyId], 
 +                      references:[id] 
 +                    ) 
 + 
 +  owner             Owner @relation( 
 +                      fields:[ownerId], 
 +                      references:[id] 
 +                    ) 
 + 
 +  @@id([propertyId, ownerId]) 
 +}
 </code> </code>
  
-<code bash+---- 
-npm run lint+ 
 +====== Indexes ====== 
 + 
 +===== Property ===== 
 + 
 +<code prisma
 +@@index([tenantId]) 
 + 
 +@@index([propertyTypeId]) 
 + 
 +@@index([published]) 
 + 
 +@@index([active]) 
 + 
 +@@index([title])
  
-npm run test+@@index([slug])
 </code> </code>
  
 ---- ----
  
-===== Hook commit-msg =====+===== PropertyAvailability =====
  
-<code> +<code prisma
-.husky/commit-msg+@@index([propertyId]) 
 + 
 +@@index([startDate]) 
 + 
 +@@index([endDate])
 </code> </code>
  
-<code bash+---- 
-npx commitlint --edit $1+ 
 +===== PropertyRate ===== 
 + 
 +<code prisma
 +@@index([propertyId]) 
 + 
 +@@index([startDate]) 
 + 
 +@@index([endDate])
 </code> </code>
  
 ---- ----
  
-====== Étape 13 — Pull Request Template ======+====== Domaine Owner ======
  
-===== Créer =====+===== Architecture =====
  
 <code> <code>
-.github/pull_request_template.md+Owner 
 + 
 +OwnerAddress 
 + 
 +OwnerDocument 
 + 
 +OwnerBankAccount 
 + 
 +PropertyOwner
 </code> </code>
  
 ---- ----
  
-===== Contenu =====+====== Owner ======
  
-<code markdown+<code prisma
-## Description+model Owner {
  
-## Changes+  id                    String @id @default(uuid())
  
-## Screenshots+  tenantId              String
  
-## Tests+  code                  String @unique
  
-## Checklist+  companyName           String?
  
-- [ ] Tests OK+  firstName             String?
  
-- [ ] Swagger OK+  lastName              String?
  
-[ ] Migration OK+  email                 String 
 + 
 +  phone                 String? 
 + 
 +  mobile                String? 
 + 
 +  taxIdentifier         String? 
 + 
 +  vatNumber             String? 
 + 
 +  active                Boolean @default(true) 
 + 
 +  createdAt             DateTime @default(now()) 
 + 
 +  updatedAt             DateTime @updatedAt 
 + 
 +  deletedAt             DateTime? 
 + 
 +  tenant                Tenant @relation( 
 +                            fields:[tenantId]
 +                            references:[id] 
 +                         ) 
 + 
 +  address               OwnerAddress? 
 + 
 +  documents             OwnerDocument[] 
 + 
 +  bankAccounts          OwnerBankAccount[] 
 + 
 +  properties            PropertyOwner[] 
 +}
 </code> </code>
  
 ---- ----
  
-====== Étape 14 — Issue Templates ======+====== OwnerAddress ======
  
-===== Créer =====+<code prisma> 
 +model OwnerAddress {
  
-<code> +  id                    String @id @default(uuid()) 
-.github/ISSUE_TEMPLATE+ 
 +  ownerId               String @unique 
 + 
 +  addressLine1          String 
 + 
 +  addressLine2          String? 
 + 
 +  postalCode            String 
 + 
 +  city                  String 
 + 
 +  state                 String? 
 + 
 +  countryCode           String 
 + 
 +  owner                 Owner @relation( 
 +                            fields:[ownerId], 
 +                            references:[id] 
 +                         ) 
 +}
 </code> </code>
  
 ---- ----
  
-===== Bug =====+====== OwnerDocument ======
  
-<code> +<code prisma
-bug_report.yml+model OwnerDocument { 
 + 
 +  id                    String @id @default(uuid()) 
 + 
 +  ownerId               String 
 + 
 +  documentType          String 
 + 
 +  fileUrl               String 
 + 
 +  createdAt             DateTime @default(now()) 
 + 
 +  owner                 Owner @relation( 
 +                            fields:[ownerId], 
 +                            references:[id] 
 +                         ) 
 +}
 </code> </code>
  
 ---- ----
  
-===== Feature =====+===== Document Types =====
  
 <code> <code>
-feature_request.yml+IDENTITY 
 + 
 +TAX_DOCUMENT 
 + 
 +MANDATE 
 + 
 +BANK_DETAILS 
 + 
 +INSURANCE
 </code> </code>
  
 ---- ----
  
-====== Étape 15 — GitHub Labels ======+====== OwnerBankAccount ======
  
-Créer :+<code prisma> 
 +model OwnerBankAccount { 
 + 
 +  id                    String @id @default(uuid()) 
 + 
 +  ownerId               String 
 + 
 +  iban                  String 
 + 
 +  bic                   String? 
 + 
 +  accountHolder         String 
 + 
 +  active                Boolean @default(true) 
 + 
 +  owner                 Owner @relation( 
 +                            fields:[ownerId], 
 +                            references:[id] 
 +                         ) 
 +
 +</code> 
 + 
 +---- 
 + 
 +====== Domaine Reservation ====== 
 + 
 +===== Architecture =====
  
 <code> <code>
-bug+Reservation
  
-feature+ReservationGuest
  
-enhancement+ReservationStatusHistory
  
-documentation+ReservationEvent
  
-security+ReservationPricing 
 +</code>
  
-performance+----
  
-infra+====== Reservation ======
  
-backend+===== Table centrale =====
  
-frontend+<code prisma> 
 +model Reservation {
  
-api+  id                    String @id @default(uuid())
  
-database+  tenantId              String 
 + 
 +  propertyId            String 
 + 
 +  customerId            String? 
 + 
 +  reference             String @unique 
 + 
 +  status                ReservationStatus 
 + 
 +  checkInDate           DateTime 
 + 
 +  checkOutDate          DateTime 
 + 
 +  nights                Int 
 + 
 +  adults                Int 
 + 
 +  children              Int 
 + 
 +  infants               Int 
 + 
 +  totalGuests           Int 
 + 
 +  notes                 String? 
 + 
 +  source                ReservationSource 
 + 
 +  createdAt             DateTime @default(now()) 
 + 
 +  updatedAt             DateTime @updatedAt 
 + 
 +  cancelledAt           DateTime? 
 + 
 +  tenant                Tenant @relation( 
 +                            fields:[tenantId], 
 +                            references:[id] 
 +                         ) 
 + 
 +  property              Property @relation( 
 +                            fields:[propertyId], 
 +                            references:[id] 
 +                         ) 
 + 
 +  guests                ReservationGuest[] 
 + 
 +  events                ReservationEvent[] 
 + 
 +  statusHistory         ReservationStatusHistory[] 
 + 
 +  pricing               ReservationPricing? 
 +}
 </code> </code>
  
 ---- ----
  
-====== Étape 16 — GitHub Projects ======+====== ReservationStatus ======
  
-===== Colonnes =====+<code prisma> 
 +enum ReservationStatus {
  
-<code> +  DRAFT
-Backlog+
  
-Ready+  PENDING
  
-In Progress+  CONFIRMED
  
-Review+  SIGNED
  
-Testing+  PAID
  
-Done+  CHECKED_IN 
 + 
 +  COMPLETED 
 + 
 +  CANCELLED 
 +}
 </code> </code>
  
 ---- ----
  
-====== Étape 17 — GitHub Actions ======+====== ReservationSource ======
  
-===== Créer =====+<code prisma> 
 +enum ReservationSource {
  
-<code> +  WEBSITE 
-.github/workflows/ci.yml+ 
 +  BACKOFFICE 
 + 
 +  AIRBNB 
 + 
 +  BOOKING 
 + 
 +  VRBO 
 + 
 +  API 
 +}
 </code> </code>
  
 ---- ----
  
-===== Pipeline minimal =====+====== ReservationGuest ======
  
-<code yaml+<code prisma
-name: CI+model ReservationGuest {
  
-on: +  id                    String @id @default(uuid())
-  pull_request: +
-  push:+
  
-jobs:+  reservationId         String
  
-  build:+  firstName             String
  
-    runs-on: ubuntu-latest+  lastName              String
  
-    steps:+  birthDate             DateTime?
  
-      - uses: actions/checkout@v4+  email                 String?
  
-      - uses: actions/setup-node@v4+  phone                 String?
  
-      - run: npm install+  isPrimary             Boolean @default(false)
  
-      - runnpm run lint+  reservation           Reservation @relation( 
 +                            fields:[reservationId], 
 +                            references:[id] 
 +                         ) 
 +
 +</code>
  
-      run: npm run test+----
  
-      - runnpm run build+====== ReservationPricing ====== 
 + 
 +<code prisma> 
 +model ReservationPricing { 
 + 
 +  id                    String @id @default(uuid()) 
 + 
 +  reservationId         String @unique 
 + 
 +  nightlyAmount         Decimal @db.Decimal(10,2) 
 + 
 +  cleaningFee           Decimal @db.Decimal(10,2) 
 + 
 +  touristTax            Decimal @db.Decimal(10,2) 
 + 
 +  discountAmount        Decimal @db.Decimal(10,2) 
 + 
 +  totalAmount           Decimal @db.Decimal(10,2) 
 + 
 +  currencyCode          String 
 + 
 +  reservation           Reservation @relation( 
 +                            fields:[reservationId], 
 +                            references:[id] 
 +                         ) 
 +}
 </code> </code>
  
 ---- ----
  
-====== Étape 18 — Gestion des secrets ======+====== ReservationEvent ======
  
-===== GitHub =====+<code prisma> 
 +model ReservationEvent {
  
-<code> +  id                    String @id @default(uuid())
-Settings+
  
-Secrets+  reservationId         String
  
-Actions+  eventType             String 
 + 
 +  payload               Json? 
 + 
 +  createdAt             DateTime @default(now()) 
 + 
 +  reservation           Reservation @relation( 
 +                            fields:[reservationId], 
 +                            references:[id] 
 +                         ) 
 +}
 </code> </code>
  
 ---- ----
  
-===== Ajouter =====+===== Event Types =====
  
 <code> <code>
-DATABASE_URL+CREATED
  
-JWT_SECRET+CONFIRMED
  
-REDIS_URL+SIGNED
  
-MINIO_ACCESS_KEY+PAID
  
-MINIO_SECRET_KEY+CHECK_IN 
 + 
 +CHECK_OUT 
 + 
 +CANCELLED
 </code> </code>
  
 ---- ----
  
-====== Étape 19 — Gestion des releases ======+====== ReservationStatusHistory ======
  
-===== Convention =====+<code prisma> 
 +model ReservationStatusHistory {
  
-<code> +  id                    String @id @default(uuid())
-v1.0.0+
  
-v1.1.0+  reservationId         String
  
-v1.2.0+  previousStatus        ReservationStatus?
  
-v2.0.0+  newStatus             ReservationStatus 
 + 
 +  changedAt             DateTime @default(now()) 
 + 
 +  reservation           Reservation @relation( 
 +                            fields:[reservationId], 
 +                            references:[id] 
 +                         ) 
 +}
 </code> </code>
  
 ---- ----
  
-===== Créer =====+====== Relations à ajouter ======
  
-<code bash> +===== Property ===== 
-git tag v1.0.0+ 
 +Ajouter :
  
-git push origin v1.0.0+<code prisma> 
 +reservations Reservation[]
 </code> </code>
  
 ---- ----
  
-====== Étape 20 — CODEOWNERS ======+===== Tenant =====
  
-===== Créer =====+Ajouter :
  
-<code> +<code prisma
-.github/CODEOWNERS+owners Owner[] 
 + 
 +reservations Reservation[]
 </code> </code>
  
 ---- ----
  
-===== Exemple =====+====== Indexes ======
  
-<code> +===== Owner =====
-* @techlead+
  
-apps/api/@backend-team+<code prisma> 
 +@@index([tenantId])
  
-apps/web/@frontend-team+@@index([email])
  
-prisma/@backend-team+@@index([active])
 </code> </code>
  
 ---- ----
  
-====== Étape 21 — Documentation du dépôt ======+===== Reservation =====
  
-===== Créer =====+<code prisma> 
 +@@index([tenantId])
  
-<code> +@@index([propertyId])
-docs/+
  
-docs/architecture+@@index([status])
  
-docs/api+@@index([checkInDate])
  
-docs/database+@@index([checkOutDate])
  
-docs/deployment+@@index([reference])
 </code> </code>
  
 ---- ----
  
-====== Vérification finale ======+===== ReservationGuest =====
  
-Le dépôt est considéré opérationnel lorsque :+<code prisma> 
 +@@index([reservationId]) 
 +</code> 
 + 
 +---- 
 + 
 +====== Validation ====== 
 + 
 +<code bash> 
 +npx prisma format 
 + 
 +npx prisma validate 
 + 
 +npx prisma generate 
 +</code> 
 + 
 +---- 
 + 
 +====== Migration ====== 
 + 
 +<code bash> 
 +npx prisma migrate dev \ 
 +--name owners_and_reservations 
 +</code> 
 + 
 +---- 
 + 
 +====== État actuel du schéma ====== 
 + 
 +À ce stade, le noyau fonctionnel est enfin présent :
  
 <code> <code>
-✓ Git initialisé+Tenant
  
-✓ GitHub connecté+User
  
-✓ SSH fonctionnel+Role
  
-✓ Branch protection active+Permission
  
-✓ Workflows CI actifs+Owner
  
-✓ Pull Requests obligatoires+Property
  
-✓ Husky actif+Reservation 
 +</code>
  
-✓ Commitlint actif+avec :
  
-✓ Templates actifs+<code> 
 +Catalogue Immobilier 
 + 
 +Propriétaires
  
-✓ Releases configurées+Réservations
  
-✓ CODEOWNERS actif+RBAC
  
-✓ Documentation présente+Multi-tenant
 </code> </code>
  
 ---- ----
  
-====== Niveau Enterprise recommandé ======+====== Étape suivante ======
  
-Pour ce projet SaaS Enterprise, ajouter également :+===== Phase 2-E ===== 
 + 
 +Domaines financiers et contractuels :
  
 <code> <code>
-✓ Dependabot+Contract
  
-✓ CodeQL+ContractTemplate
  
-✓ Secret Scanning+ContractSignature
  
-✓ Container Scanning+Document
  
-✓ SBOM+Payment
  
-✓ SAST+Invoice
  
-✓ DAST+Refund
  
-✓ Security Policy +AccountingEntry
- +
-✓ CHANGELOG automatique+
 </code> </code>
  
-Ces éléments seront nécessaires à partir des Sprints 12 à 20 pour maintenir un niveau de qualité et de sécurité compatible avec une exploitation professionnelle à grande échelle.+Ces tables permettront d'implémenter intégralement : 
 + 
 +  * Sprint 5 — Contrats & Signature Électronique 
 +  * Sprint 6 — Paiements & Facturation 
 + 
 +et de disposer du premier flux métier complet : 
 + 
 +<code> 
 +Property 
 + 
 +↓ 
 + 
 +Reservation 
 + 
 +↓ 
 + 
 +Contract 
 + 
 +↓ 
 + 
 +Payment 
 + 
 +↓ 
 + 
 +Invoice 
 +</code>
ujusum/3-codage/1-repository/2-prisma-schema.1780800251.txt.gz · Dernière modification : 2026/06/07 04:44 de 91.170.108.99 · Actuellement bloqué par : 192.168.0.100,216.73.216.72

DokuWiki Appliance - Powered by TurnKey Linux