diff --git a/ALTAIR_PROGRESS.md b/ALTAIR_PROGRESS.md index 9b8a2a40..3da425a7 100644 --- a/ALTAIR_PROGRESS.md +++ b/ALTAIR_PROGRESS.md @@ -4,6 +4,7 @@ Ce fichier sert de **point de reprise** pour toute nouvelle conversation de dév - **Date de l'état des lieux** : 30/11/2026. - **Version en production** : **0.133.0** sur https://altair.klencio.fr (`origin/main`), déployée automatiquement par `.github/workflows/ci.yml`. L'inscription publique est ouverte depuis la v0.78 : la société d'origine du porteur s'appelle « TEST » et sert à l'administration du site (`/plateforme`). +- **Livré en v0.170** : étiquettes cuisine (`/haccp/etiquettes` : préparation maison avec composition INCO et allergènes en gras, DLC secondaire des entamés plafonnée à la DLC d'origine, plat témoin 5 jours, n° de lot automatique, PDF au format Brother 62 / 102 mm pour AirPrint, QR code vers la recherche du lot, versées à la traçabilité) et repas du personnel (`/menus/repas-personnel` : offert, au coût, prix libre, récapitulatif mensuel et avantage en nature estimé) ; migration 0125, ADR-195, K-297/298. - **Livré en v0.167** : challenges des serveurs (`/ventes/challenges`), rapports personnalisables avec public et envoi sur seuil, automatisations avec conditions, délai et validation (`/automatisations/validations`), abonnements payés repérés seuls (`/finance/abonnements`) ; migration 0123, ADR-190 à 193. - **Livré en v0.162** : registres sans papier (`/conformite/registres` : EPI, exercices incendie, contrôles remplis depuis Documents, attestations de vigilance repérées dans les achats, immobilisations et crédit-bail proposés depuis les factures), calendrier fiscal et social (`/conformite/calendrier` : TVA, DSN, IS, CFE, liasse, seuils d'effectif, durées de conservation, export .ics), contrôle qualité des plats (`/haccp/qualite`), liste d'attente avec place proposée automatiquement à l'annulation (`/reservations/attente`) ; règles à valider (K-275 à K-277), migration 0118, ADR-173 et ADR-174. - **Livré en v0.155** : pièces de l'établissement dans Documents (31 lignes à valider, dépôt par glisser-déposer, échéance lue dans le PDF, justificatif de conformité automatique ; migration 0114, ADR-166). @@ -281,7 +282,7 @@ Manques principaux : | §15.6 Sanitaire | Plans de nettoyage et de désinfection, historique | Opérationnelle en production | `/haccp/nettoyage`, `haccp-routines.test.ts` | — | Joindre les fiches techniques des produits | S | | §15.6 Sanitaire | Non-conformités et actions correctives | Opérationnelle en production | Contraintes `*_action_ck`, filtre `?nc=1`, `haccp.test.ts` ; v0.136 : registre transverse `/haccp/actions-correctives` ouvert automatiquement (sonde hors plage ou muette, relevés et nettoyage de la veille, DLC dépassée), clos avec l'action menée, repris au dossier PDF (ADR-147, K-241) | Professionnel HACCP | Faire valider les actions types | S | | §15.6 Sanitaire | Dossier HACCP en PDF pour la DDPP | Opérationnelle en production | `haccp/dossier/pdf/route.ts`, plafond de 366 jours, `haccp-dossier-route.test.ts`. Sans photos (K-063) | — | Intégrer au mode SOS | S | -| §15.6 Sanitaire | Matrice des allergènes, fiches, fournisseurs | En développement | Allergènes à travers les sous-recettes, colonne dans `/menus`. Pas de matrice plats × 14 allergènes | — | Matrice imprimable | S | +| §15.6 Sanitaire | Matrice des allergènes, fiches, fournisseurs | En développement | v0.172 : matrice plats × 14 allergènes imprimable (`/menus/allergenes`) | — | — | — | | §15.6 Sanitaire | Traçabilité produit → fournisseur, facture, lot, préparations | En développement | `trace_labels` en texte libre, `reception_controls` lié à la commande. Pas de lien facture ou fiche, pas de recherche par lot | — | Liens et page de recherche par lot | M | | §15.6 Sanitaire | Alertes : température anormale, produit expiré, contrôle non fait | Développée | Alertes HACCP et automatisations ; alerte « Dates limites » (DLC / DDM dépassée ou dans le préavis) et déclencheur `peremption` depuis v0.91 (K-155, K-156) ; v0.136 : écarts ouverts au registre des actions correctives, DLC des contrôles à réception reliées aux lots du stock | — | Notification par rôle (cuisine) | S | | §18 Prévisions | Prévision de trésorerie (7/30/90/365 jours, seuil) | Opérationnelle en production | `treasury()`, Figures « forecast », `bank.test.ts` l.81. Relevés importés | Agrégateur DSP2 | Marge d'incertitude, encaissements issus de la prévision | S | @@ -388,7 +389,7 @@ Manques principaux : | 15.6 Sanitaire | Hottes, extraction, chambres froides, déchets | En développement | Maintenance préventive ; déchets absents | — | Périodicités et contrats de déchets | S | | 15.7 DGCCRF | Carte, menus, tarifs TTC, historique des prix | En développement | `sellingPriceTtc` ; pas de carte ni d'historique des prix de vente | — | Historique et génération de la carte | M | | 15.7 DGCCRF | Affichage des prix, eau gratuite, fait maison, moyens de paiement | Non développée | Aucune occurrence | Validation DGCCRF | Règles validées, puis génération | M | -| 15.7 DGCCRF | Allergènes pour le client | En développement | Calculés, pas de sortie client | — | Matrice consultable par les clients | S | +| 15.7 DGCCRF | Allergènes pour le client | Opérationnelle | v0.172 : page client publique avec QR et filtre (`/allergenes/`) | — | — | — | | 15.7 DGCCRF | Promotions, CGV, labels, médiateur, conditions de réservation | Non développée | Rien | Validation juridique | Pièces et modèles | M | | 15.7 DGCCRF | Écarts entre prix affichés et prix de caisse | En attente d'accès API | Pas d'articles Cashpad | Cashpad | Comparer avec la carte | M | | 15.8 Licences | Licences, autorisations, terrasse, SACEM | En développement | Catégorie « licence » (rappel à 60 jours), tests ; pas de sous-types | Validation | Sous-types obligatoires selon l'activité | M | @@ -500,8 +501,8 @@ Manques principaux : | §14 Mail | Plusieurs comptes Gmail et Outlook | En attente d'accès API | v0.160 : plusieurs boîtes Gmail en lecture par OAuth (par établissement ou organisation), `mail_accounts`, testées ; Outlook non commencé | Validation Google (K-270), application Microsoft Entra | Outlook par Microsoft Graph | M | | §14 Mail | Boîte de réception centralisée | En attente d'accès API | v0.160 : `/boite-mail`, toutes les boîtes, tri par règles (facture, devis, attestation, réservation, commande), lecture toutes les 30 min, notifications ; `mailbox.test.ts` | Validation Google (K-270) | Répondre depuis ALTAIR (envoi par la boîte reliée) | M | | §14 Mail | Envois programmés | En développement | Pas de `send_at` | — | Champ « envoyer le » | S | -| §14 Mail | Réponses automatiques | Non développée | Accusés de réception seulement | Lecture des e-mails | Règles validées | M | -| §14 Mail | Modèles et signatures d'e-mail | En développement | Textes fixes (`mail/messages.ts`) | — | Modèles modifiables | S | +| §14 Mail | Réponses automatiques | Développée | v0.169 : modèles par catégorie et mot-clé, brouillons préparés après chaque lecture, envoi seulement sur clic (`/boite-mail/reponses`, MAIL-REPLY-001 à 003, `mail-replies.test.ts`, ADR-194, K-296) | Validation Google (K-270) pour la lecture réelle | Envoi dans le fil Gmail (gmail.send) | S | +| §14 Mail | Modèles et signatures d'e-mail | En développement | Textes fixes (`mail/messages.ts`) ; v0.169 : modèles de réponse modifiables (`mail_reply_templates`) | — | Modèles pour les autres e-mails | S | | §14 Mail | E-mails métier (devis, groupes, relances clients) | En développement | Devis et accusés ; pas de relance client par e-mail | Lecture des e-mails | Relance depuis Commercial | M | | §14 Mail | Relances fournisseurs et négociations | En développement | `mailto` prérempli seulement | — | Envoi par la boîte connectée | M | | 15.14 Coffre | Recherche dans les documents | En développement | Intitulé, organisme et référence seulement ; non testé | OCR | Plein texte PostgreSQL | M | diff --git a/CHANGELOG.md b/CHANGELOG.md index 11237613..2f9dd235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,45 @@ # Journal des modifications +## [0.172.0] — 01/12/2026 — Hygiène : rappels de produits, allergènes, nuisibles, dossier scellé, relevés hors ligne +### Ajouté +- **Veille RappelConso** (`/haccp/rappels`, `src/lib/haccp/recalls.ts`, `src/lib/services/product-recalls.ts`) : fiches de rappel alimentaires lues par le planificateur (API publique data.economie.gouv.fr, au plus toutes les 20 h, 3 h après une erreur, 90 jours au premier passage) et croisées avec les étiquettes de traçabilité (120 jours), les lots en stock et les codes-barres du catalogue. Trois niveaux : « concerné » (GTIN + lot, ou GTIN sans lot au rappel), « probablement concerné » (GTIN ou lot seul), « à vérifier » (même marque et un mot commun, étiquette sans code). Action corrective HACCP (source `rappel_produit`, une par rappel et par établissement) et notification « Hygiène ». Page : rappels qui vous concernent avec clôture, rappels récents, recherche, état de la veille, bouton « Comparer maintenant ». +- **Matrice des allergènes** (`/menus/allergenes`, `src/lib/services/allergen-matrix.ts`) : 14 allergènes plat par plat (contient / traces), impression paysage, alerte sur les ingrédients sans allergène déclaré. **Page client publique** `/allergenes/` avec QR code (activer, désactiver, nouvelle adresse ; droit `recipes.manage`, audité) et filtre « Je ne mange pas » : Convient / Traces possibles / Contient. +- **Nuisibles** (`/haccp/nuisibles`, `src/lib/services/pest-control.ts`) : contrat du prestataire (n° Certibiocide, contact, dates, passages par an, plan des pièges JPEG/PNG/WebP/PDF jusqu'à 5 Mo ; un seul contrat actif, le précédent archivé), registre des passages (contrat ou curatif, activité, nuisibles, constat, actions, recommandations, produits). **Lien de signature du technicien** `/nuisibles/` (7 jours, empreinte seule en base, une seule utilisation, renouvelable) : il complète son constat et signe à l'écran. Activité constatée → action corrective (`nuisibles`) et notification ; passage en retard de plus de 15 jours ou contrat échu → action corrective une fois par mois (planificateur). +- **Dossier HACCP scellé** (`src/lib/services/haccp-seal.ts`) : chaque dossier PDF porte un numéro et un QR code de vérification ; ALTAIR garde l'empreinte SHA-256 du fichier remis. Page publique `/verifier/` : l'inspecteur dépose le PDF, l'empreinte est calculée dans son navigateur (le fichier n'est pas envoyé) et comparée. Dernières éditions listées sur la page Dossier. Le dossier inclut désormais les passages nuisibles et signale les relevés saisis hors ligne. +- **Relevés de température hors ligne** (`src/lib/haccp/offline-queue.ts`, tournée `/haccp/releves`) : sans réseau, la tournée est gardée sur l'appareil avec l'heure réelle du relevé et envoyée dès le retour du réseau ; identifiant par relevé (`client_ref`) : jamais enregistré deux fois. Serveur : heure de l'appareil acceptée sur 72 h au plus, jamais dans le futur ; relevé marqué « saisi hors ligne » avec l'heure de réception. +### Technique +- Migration 0127 (`hygiene_rappels_nuisibles`) : tables `product_recalls` (globale, sans organisation), `pest_control_contracts`, `pest_control_visits`, `haccp_sealed_exports`, `allergen_pages` (RLS activée), colonnes `temperature_readings.client_ref` (unique par organisation) et `entered_offline` ; sources d'action corrective `rappel_produit` et `nuisibles`. Bloc PDF `seal` (QR + texte). Registre des intégrations : RappelConso (appel réel le 01/12/2026). +### Tests +- Unitaires `recalls`, `offline-queue`, `haccp-dossier-route` ; intégration `product-recalls`, `allergen-matrix`, `pest-control`, `haccp-offline`, `haccp-trace` (dossier scellé, retouche détectée). + +## [0.171.0] — 01/12/2026 — Coût des formules à choix, commandes du jour, annulation de réservation par le client +### Ajouté +- **Formules à choix** (`/commercial/menus`, FIN-MENU-001, `src/lib/set-menus/costing.ts`) : étapes (entrée, plat, dessert…), plusieurs plats au choix par étape, supplément TTC par plat. Coût matière par personne du choix le moins cher au plus cher, moyenne pondérée par les portions vendues des 90 derniers jours (sinon parts égales), marge brute HT et food cost de la combinaison la moins et la plus rentable (supplément HT compris), plat « le moins rentable » signalé. Aperçu en direct dans le formulaire, détail par plat sur la fiche du menu, fourchette dans la liste. Menus d'avant : chaque fiche liée devient une étape. Une fiche sans coût rend la fourchette « Donnée manquante ». +- **Commandes du jour** (`/achats/commandes/du-jour`, FIN-PURCH-010, `src/lib/purchasing/order-day.ts`, `src/lib/services/order-planning.ts`) : jours de livraison sur la fiche fournisseur ; aujourd'hui est le dernier jour pour une livraison quand la commande de demain arriverait plus tard. Quantités = consommation prévue (consommation théorique des 28 derniers jours ÷ CA de la fenêtre × CA moyen du même jour de la semaine, jours fermés à zéro) jusqu'à la livraison suivante + stock minimum − stock − déjà commandé, arrondies au colis ; sinon stock cible. Montant estimé, alerte « sous le minimum de commande », « Préparer le bon » crée un brouillon (jamais envoyé). Rappel du matin (à partir de 7 h, une fois par jour et par établissement) dans le nouveau sujet de notification « Commandes du jour » (cloche, e-mail, téléphone). +- **Annulation par le client** (`/ma-reservation/`, `src/lib/services/reservation-self-service.ts`) : lien personnel (64 caractères aléatoires) dans les e-mails de confirmation, d'accusé de réception et de rappel ; le client voit sa réservation et l'annule jusqu'au délai réglé (2 h avant par défaut, Réservations › Horaires) ; tables libérées, équipe prévenue (« Réservation annulée par le client »), place proposée à la liste d'attente, e-mail de confirmation ; audit sans auteur, limite de 10 annulations par heure et par connexion. Lien visible sur la fiche de réservation. +### Technique +- Migration 0126 (`formules_commandes_annulation`) : `set_menus.courses`, `suppliers.delivery_days`, `reservations.manage_token` (unique), `reservation_settings.self_cancel_enabled / self_cancel_minutes`, table `supplier_order_reminders` (RLS). Planificateur : rappel des commandes du jour. +### Tests +- Unitaires `order-day`, `formula-costing`, `self-cancel` ; intégration `order-planning`, `reservation-self-cancel`, `set-menus` (formule à choix). + +## [0.170.0] — 01/12/2026 — Étiquettes cuisine et repas du personnel +### Ajouté +- **Étiquettes cuisine** (`/haccp/etiquettes`, HACCP-LABEL-001 à 004, `src/lib/haccp/kitchen-labels.ts`, `src/lib/haccp/label-pdf.ts`, `src/lib/services/kitchen-labels.ts`) : préparation maison (DLC = fabrication + J+n de la fiche, composition INCO dans l'ordre décroissant des quantités, sous-recettes détaillées, allergènes en gras, consigne de conservation), produit entamé (DLC secondaire plafonnée à la DLC d'origine, lot fournisseur), plat témoin (5 jours, service midi / soir). N° de lot interne automatique `L-AAMMJJ-NN` par établissement et par jour (verrou transactionnel). PDF au format exact du rouleau (62 × 29, 62 × 100, 102 × 152 mm), une page par exemplaire, QR code vers la recherche du lot, ouvert dans le navigateur pour AirPrint. Réimpression, réimpression des étiquettes du jour, annulation avec motif (`haccp.manage`). Production et entame créent l'étiquette de traçabilité (`trace_labels`) : rappel des DLC des entamés et recherche de lot sans ressaisie. Tuile « Étiquettes » sur la tablette HACCP, bouton « Étiquette » sur la fiche technique. +- **Durées de conservation** (`/haccp/etiquettes/conservation`) : J+n et consigne par fiche, J+n après ouverture par produit, ou mémorisées depuis l'impression (`haccp.manage`). Rien n'est inventé : sans durée, elle est demandée à l'impression. +- **Repas du personnel** (`/menus/repas-personnel`, TEAM-MEAL-001 à 003, `src/lib/services/staff-meals.ts`) : saisie depuis la fiche du plat pour un ou plusieurs salariés (ceux au planning en un clic) ou un bénéficiaire hors équipe ; offert, au coût de revient (coût matière par portion au dernier prix d'achat) ou à prix libre ; valeur du repas des paramètres de masse salariale figée à la saisie. Récapitulatif mensuel par bénéficiaire : repas, coût matière, payé, avantage en nature estimé (valeur du repas − participation, jamais négatif), comparaison avec les repas cochés sur les shifts validés (base de l'export de paie, inchangée), plats les plus servis. Droits `stock.manage` (saisie, annulation) et `team.view` (récapitulatif) ; audité. +### Technique +- Migration 0125 (`etiquettes_repas_personnel`) : `recipes.shelf_life_days / storage_note`, `purchase_items.opened_shelf_life_days`, tables `kitchen_labels` et `staff_meals` (annulation seule, suppression interdite, RLS). Suppression d'établissement : tables ajoutées au résumé. ADR-195. +### Tests +- Intégration `etiquettes-repas` (DLC, INCO, lot, plafonnement, traçabilité, PDF au format, annulation, isolation ; repas offert / au coût / prix libre, avantage en nature, annulation, isolation). + +## [0.169.0] — 01/12/2026 — Réponses automatiques aux e-mails (brouillons à valider) +### Ajouté +- **Réponses à relire** (`/boite-mail/reponses`, MAIL-REPLY-001 à 003, `src/lib/mail/replies.ts`, `src/lib/services/mail-replies.ts`) : modèles par catégorie d'e-mail (réservation, facture, devis, attestation, commande, autre) avec mot-clé facultatif, 4 modèles proposés ; après chaque lecture d'une boîte, brouillon préparé pour les e-mails des 7 derniers jours qui correspondent (champs {prenom}, {expediteur}, {objet}, {etablissement}, {signature}) ; jamais pour une adresse automatique, une liste de diffusion, la boîte elle-même, ni deux fois dans une conversation. Notification « réponse prête à relire » (sujet Boîte mail). Envoi seulement sur clic « Envoyer » (droit `mail.manage`), après correction éventuelle, par la boîte d'envoi d'ALTAIR ; écarter possible ; audité ; jamais d'envoi en démonstration. +### Technique +- Migration 0124 (`reponses_mail`) : tables `mail_reply_templates`, `mail_reply_drafts` (un brouillon par e-mail), RLS activée. +### Tests +- Unitaire `mail-replies` ; intégration `mail-replies` (modèles, droits, isolation, adresses automatiques, conversation, envoi unique, démonstration). + ## [0.168.0] — 01/12/2026 — Menu de gauche plus étroit ### Modifié - Menu latéral sur ordinateur : 208 px au lieu de 248 px (`src/app/(app)/layout.tsx`, grille `208px / minmax(0,1fr)`), pour laisser plus de place au contenu sur un portable. diff --git a/DECISIONS.md b/DECISIONS.md index 704a4938..3880dc5b 100644 --- a/DECISIONS.md +++ b/DECISIONS.md @@ -2,11 +2,16 @@ | N° | Date | Décision | Raison | Réversible | |---|---|---|---|---| +| ADR-196 | 01/12/2026 | Commandes du jour (v0.171) : prévision de consommation proportionnelle au CA moyen du même jour de la semaine (28 jours) et non une prévision par plat ; produits rattachés au fournisseur par leur « fournisseur habituel » ; bon préparé en brouillon, jamais envoyé | Une seule règle explicable, robuste avec peu d'historique, sans IA ni Cashpad ; la décision d'achat reste humaine | Oui | +| ADR-197 | 01/12/2026 | Formules à choix (v0.171) : étapes stockées en JSON sur `set_menus.courses`, `recipe_ids` déduit des étapes (compatibilité) ; fourchette et marges calculées sur les combinaisons extrêmes, moyenne pondérée par les ventes réelles | Pas de nouvelle table ; les menus existants restent valides ; la pire marge est ce qui compte pour fixer le prix | Oui | +| ADR-198 | 01/12/2026 | Annulation par le client (v0.171) : jeton aléatoire de 64 caractères par réservation (défaut SQL), page publique sans compte, annulation directe en base avec audit sans auteur (pas de contexte d'un membre de l'équipe) | Aucun compte client à créer ; l'audit ne doit pas attribuer l'annulation à un salarié | Oui : désactivable par établissement | +| ADR-194 | 01/12/2026 | Réponses automatiques aux e-mails (v0.169) : brouillons préparés par modèles et règles fixes (sans IA), envoyés seulement sur clic d'une personne, par la boîte d'envoi d'ALTAIR (SMTP) car Gmail est relié en lecture seule | Pas de nouvelle autorisation Google (gmail.send) à faire valider ; aucun envoi sans accord humain (règle du porteur) | Oui : désactiver les modèles | | ADR-187 | 01/12/2026 | Prévisions corrigées du calendrier (v0.166) : jours fériés calculés et vacances scolaires recopiées dans le code (pas d'appel à data.education.gouv.fr, refusé par le proxy) ; effet des fériés et des vacances mesuré sur les ventes de l'établissement, appliqué comme un rapport à l'effet des jours de référence ; événements saisis avec un effet facultatif (table `forecast_events`) | Aucune dépendance réseau ni clé, explicable en une phrase, sans valeur inventée : sans historique suffisant, rien n'est corrigé et c'est dit ; l'organisation peut toujours ajouter une période | Oui : retirer la correction (la prévision de base reste calculée à part) | | ADR-188 | 01/12/2026 | Planning proposé (v0.166) : calcul déterministe à partir des shifts habituels des 8 dernières semaines, sans optimiseur ni IA ; ajout en brouillon seulement, jamais de publication ni de modification d'un shift existant ; proposition recalculée au moment de l'ajout | Le restaurateur reconnaît ses horaires, la décision reste humaine (droit du travail) et une proposition périmée ne peut pas créer de chevauchement | Oui : supprimer les shifts ajoutés (notés « Proposé par ALTAIR ») | | ADR-190 | 01/12/2026 | Challenges serveurs (v0.167) : calculés à la volée depuis les ventes et les heures de `/ventes/serveurs`, figés en JSON à la clôture (planificateur, droits du créateur) ; pas de table de scores | Un seul calcul pour le direct et la clôture ; les records restent lisibles même si les ventes sont réimportées | Oui | | ADR-191 | 01/12/2026 | Rapports personnalisés (v0.167) : filtre appliqué au rapport complet déjà établi avec les droits du créateur, liste fermée par public ; condition d'envoi évaluée avant le filtre, période marquée traitée sans envoi | Aucune donnée ajoutée par la personnalisation ; un public restreint ne peut jamais recevoir une donnée confidentielle ; pas de renvoi en boucle | Oui | | ADR-192 | 01/12/2026 | Automatisations avancées (v0.167) : conditions et délai évalués à chaque passe (15 min) ; validation par une personne désignée qui voit avec ses propres droits, puis recalcul pour chaque destinataire ; pas de validation sur les règles « brouillon » | Pas d'élévation de droits ; une situation réglée entre-temps n'est envoyée à personne | Oui | +| ADR-195 | 01/12/2026 | Étiquettes cuisine et repas du personnel (v0.170, migration 0125). Étiquettes : enregistrement immuable (annulation seule) avec n° de lot interne `L-AAMMJJ-NN` attribué sous verrou consultatif par établissement et jour ; PDF pdf-lib au format exact du rouleau Brother (pas de pilote ni d'impression directe : AirPrint ou impression système, aucune dépendance) ; composition INCO figée dans l'étiquette (jsonb) pour rester exacte si la fiche change ; production et entame écrivent aussi `trace_labels` (une seule source pour le rappel des DLC et la recherche de lot). Durées de conservation saisies par l'équipe, jamais proposées par ALTAIR ; DLC secondaire plafonnée à la DLC d'origine ; plat témoin fixé à 5 jours. Repas du personnel : une ligne par bénéficiaire, coût matière et valeur du repas figés à la saisie ; l'export de paie reste fondé sur les repas des shifts validés (pas de double compte), le récapitulatif signale les écarts. | | ADR-193 | 01/12/2026 | Abonnements (v0.167) : repérés par régularité et stabilité des paiements, sans liste de fournisseurs « abonnement » ni saisie | Fonctionne pour tout fournisseur (logiciel, location, assurance) avec les factures Pennylane déjà importées | Oui | | ADR-189 | 01/12/2026 | Simulations stratégiques (v0.166) : calculs de gestion sur la moyenne des 3 derniers mois complets, sans clé d'IA, chaque valeur en Figure ; capacité d'investissement fondée sur le seul résultat prévu du nouveau site | Le porteur ne veut pas d'IA payante ; base récente et prudente (un 2e site doit se rembourser seul) | Oui | | ADR-180 | 01/12/2026 | Isolation des restaurants par **Row Level Security** (v0.165, migration 0121, K-003) : rôle `altair_tenant` (ni propriétaire ni superutilisateur) pris par `SET ROLE` sur la connexion **seulement** quand une organisation est liée (session vérifiée dans `currentSession`, ou `withTenant`) ; `app.org_id` posé sur la connexion ; politiques `tenant_isolation` `USING` + `WITH CHECK` sur toutes les tables à `organization_id` sauf `memberships`, `sessions`, `audit_log`, `account_invites`. Liaison par la mémoire de requête de React (`cache`) **et** `AsyncLocalStorage.enterWith` (actions serveur) ; état mémorisé par connexion du pool, remis au rôle propriétaire à chaque prise sans organisation. Traitements de plateforme dans `withoutTenant`. | L'application se connecte en superutilisateur (image Postgres) : une politique sur ce rôle n'aurait aucun effet ; changer d'identifiants en production était plus risqué qu'un `SET ROLE`. Lier dans `currentSession` couvre toutes les pages et actions sans toucher 400 fichiers ; sans liaison, rien ne change (échec ouvert = comportement d'avant). | Oui : `ALTAIR_RLS=off` | @@ -195,3 +200,10 @@ | ADR-113 | 30/11/2026 | CI accélérée : tests Vitest répartis en 4 morceaux parallèles (`tests (n/4)`, une base PostgreSQL chacun), typage + audit des dépendances de production + build dans `checks` (cache `.next/cache`), job `verify` conservé comme synthèse (vert seulement si tout l'est) ; remise à zéro de la base de test par TRUNCATE + recopie des lignes posées par les migrations (schéma `_test_baseline`), migrations rejouées seulement quand leur empreinte change | 162 fichiers × 1,3 s de migrations = 3,5 min perdues à chaque passage ; les fils fusionnent en course. Mesuré en local : 235 s → 147 s sans découpage. Le nom `verify` reste celui que les fils et le déploiement attendent | | ADR-129 | 30/11/2026 | Compteurs de congés (v0.120, migration 0088) **calculés à l'affichage**, jamais stockés : contrats + absences du planning (où arrivent aussi les demandes acceptées) + heures validées ou pointées ; seuls les réglages par établissement (unité, heures sup en repos, désactivé par défaut) et les reprises motivées sont en base. Un mois est crédité quand il est terminé ; le reliquat est reporté (signalé) plutôt que perdu ; le planning seul ne crédite jamais de repos | Spec §8 et demande du 30/11 : soldes à jour sans saisie ; un compteur stocké divergerait dès qu'une absence passée est corrigée ; les règles restent « à valider par un professionnel » | Oui | | ADR-165 | 01/12/2026 | Tablettes de l'établissement (v0.154, migration 0113) : appairage par code à usage unique (empreinte SHA-256, 15 min) qui dépose un jeton longue durée dans un cookie `HttpOnly` ; la tablette tient lieu de session **seulement sur ses pages** (`/tablette`, `/haccp` avec salarié identifié). Borne : droits du créateur réduits à `clock.kiosk` ; tablette HACCP : droits du compte du salarié identifié par son code PIN, réduits à l'HACCP, 10 min glissantes. Les pages HACCP existantes sont réutilisées telles quelles (pas d'écran HACCP dupliqué) ; `recorded_by` reste un compte, donc un salarié sans accès ne peut pas s'identifier. Complète ADR-065 (la borne n'a plus besoin d'un compte Cuisine ou gérant ouvert) | Demande du porteur du 01/12 : deux tablettes au restaurant, sans compte gérant ouvert, et la même chose pour chaque restaurant inscrit ; traçabilité HACCP nominative | Oui : retirer les tablettes ; la borne dans un compte connecté reste disponible | + +## ADR-199 — Hygiène : veille RappelConso, nuisibles, dossier scellé, relevés hors ligne (v0.172, 01/12/2026) +- **Rappels** : fiches stockées une seule fois pour toutes les organisations (`product_recalls`, sans RLS, aucune donnée de restaurant) ; le résultat par restaurant passe par une action corrective dédupliquée (`rappel::<établissement>`), pas de table de correspondances. Trois niveaux de certitude pour éviter les fausses alertes ; le niveau est écrit dans le titre de l'action. +- **Nuisibles** : le technicien signe sur un lien de 7 jours (empreinte SHA-256 seule en base, usage unique), même modèle que la signature des documents RH ; aucun compte prestataire. +- **Dossier scellé** : on scelle l'empreinte SHA-256 du fichier final (pas un horodatage qualifié ni une signature PDF) ; la vérification se fait dans le navigateur de l'inspecteur, le fichier n'est jamais envoyé. Simple, gratuit, et suffit à prouver qu'un PDF n'a pas été retouché. +- **Hors ligne** : file en localStorage plutôt qu'un service worker avec cache de pages (CSP à nonce, sessions) ; idempotence par `client_ref` unique par organisation ; heure de l'appareil bornée à 72 h et marquée « saisi hors ligne ». + diff --git a/FINANCIAL_RULES.md b/FINANCIAL_RULES.md index 2e58e7ad..edeacac2 100644 --- a/FINANCIAL_RULES.md +++ b/FINANCIAL_RULES.md @@ -338,6 +338,21 @@ Estimations de gestion : aucune de ces valeurs n'est un résultat comptable (Pen - Propositions d'avoir : erreur de quantité = F − R (si positive et hors tolérance) au prix facturé ; manquant = max(0, C − max(R, F)) au prix commandé. - Alerte `reception` (gravité « attention », droit « purchases.view ») : commandes reçues depuis 30 jours ayant au moins une ligne hors tolérance et **aucune demande d'avoir ouverte, envoyée ou acceptée** liée à la commande. +### FIN-PURCH-010 — commandes du jour : qui commander et combien (v0.171) +- Livraison obtenue par une commande passée le jour J avant l'heure limite : premier jour ≥ J + délai (1 jour si non renseigné) dont le jour de la semaine est un jour de livraison du fournisseur (tous les jours si aucun n'est coché). +- **À commander aujourd'hui** si la livraison obtenue en commandant aujourd'hui est antérieure à celle obtenue en commandant demain. Heure limite passée : la livraison est manquée (« heure limite passée »), le prochain jour de commande est indiqué. +- Jours couverts : d'aujourd'hui à la livraison suivante (exclue), 21 jours au plus. +- Consommation prévue d'un produit = consommation théorique des 28 derniers jours (FIN-STOCK-004) ÷ CA HT de la fenêtre × Σ CA attendu des jours couverts ; CA attendu d'un jour = moyenne des jours de même nom de la fenêtre ayant eu des ventes (0 si aucun) ; jour fermé (exception « fermé toute la journée ») = 0. Pas de CA dans la fenêtre : pas de prévision. +- Quantité = consommation prévue + stock minimum − stock (K-118) − quantités des commandes envoyées ou confirmées ; sans prévision : stock cible − stock − en commande ; la plus grande des deux l'emporte ; arrondie au colis supérieur (`packsFor`). Stock inconnu : compté 0 et signalé « à vérifier ». ≤ 0 : rien à commander. +- Montant estimé = colis × contenance × dernier prix connu (sinon prix catalogue) ; « Donnée manquante » si un prix manque ; alerte si sous le minimum de commande du fournisseur. Estimation de gestion : le bon préparé reste un brouillon à relire, jamais envoyé. + +### FIN-MENU-001 — coût d'une formule à choix (v0.171) +- Une personne prend un plat par étape. Coût d'un plat = coût d'une portion de sa fiche (dernier prix d'achat, FIN-STOCK). Fourchette = Σ du plat le moins cher / le plus cher de chaque étape, arrondie au centime. +- Moyenne = Σ par étape du coût × part des portions vendues de chaque plat sur 90 jours (correspondances des ventes) ; sans vente reliée dans l'étape, moyenne simple. +- Prix HT = lignes repas du menu (TVA 5,5 ou 10 %) ; supplément HT = supplément TTC ÷ (1 + taux de la première ligne repas, 10 % par défaut), arrondi au centime. +- Marge d'une combinaison = prix HT + Σ suppléments HT − Σ coûts. Pire combinaison : à chaque étape, le plat qui minimise (supplément HT − coût) ; meilleure : celui qui le maximise. Food cost = coût ÷ (prix HT + suppléments HT) × 100, 1 décimale. +- Un coût de fiche manquant : fourchette, moyenne et marges « Donnée manquante » (jamais 0). + ### FIN-STOCK-008 — transfert de stock entre établissements - Deux établissements différents de la même organisation, **tous deux** dans le périmètre de la personne (création et annulation), droit « stock.manage » ; date au plus tard aujourd'hui ; produits non archivés, une ligne par produit ; quantité convertie dans l'unité de stock (4 décimales). - Stock de départ lu à la date du transfert (FIN-STOCK-002) : refus si le stock est inconnu ou inférieur à la quantité, sauf confirmation explicite « dépasser le stock connu ». diff --git a/INTEGRATION_REGISTRY.md b/INTEGRATION_REGISTRY.md index 79099f4c..cdbd90d1 100644 --- a/INTEGRATION_REGISTRY.md +++ b/INTEGRATION_REGISTRY.md @@ -43,6 +43,7 @@ Légende vérification : **V** vérifiée par un appel réel · **D** documenté | Météo-France (données climatologiques quotidiennes) | 3 | 2 | Jeu de données data.gouv.fr « Données climatologiques de base - quotidiennes » (CSV compressés par département, quotidien pour les deux dernières années), Licence Ouverte 2.0 ; page lue le 01/12/2026 | D | Aucune | — | **Lecture automatique quotidienne (v0.143)**, station Paris-Montsouris ; jamais appelé depuis le développement (proxy), à confirmer en production (K-251). Open-Meteo écarté (non commercial uniquement) | | INSEE BDM (occupation des hôtels à Paris) | 3 | 2 | Service web SDMX `https://api.insee.fr/series/BDM/V1/data/SERIES_BDM/{idbank}`, accès ouvert, 30 appels/min/IP (fiche data.gouv.fr lue le 01/12/2026) ; série 010599005 | D | Aucune | — | **Lecture automatique quotidienne (v0.143)** ; aucun appel réel, chemin et fréquence à confirmer en production (K-251) | | Calendrier scolaire (zones A, B, C) et jours fériés | 3 | 5 | Jeu de données « Calendrier scolaire » de data.education.gouv.fr (Opendatasoft, sans clé) ; jours fériés calculés (Code du travail L3133-1) | D | Aucune | Événements saisis dans Prévisions | **Table intégrée (v0.166)** : périodes 2024-2025 à 2026-2027 recopiées des arrêtés ; API jamais appelée (proxy, 01/12/2026), à recouper avant chaque rentrée (K-289) | +| RappelConso (rappels de produits alimentaires) | 2 | 5 | API Opendatasoft Explore v2.1 de data.economie.gouv.fr, jeu `rappelconso-v2-gtin-espaces`, Licence Ouverte, sans clé ; filtre `categorie_produit="alimentation"` | D, structure relevée sur un appel réel le 01/12/2026 (navigateur ; jamais appelée depuis la production ; des champs et du champ `identification_produits` relevée) | Aucune | Recherche manuelle dans HACCP › Rappels produits | **Lecture automatique v0.172** (au plus toutes les 20 h, 3 h après une erreur), croisement avec traçabilité, stock et codes-barres du catalogue ; premier passage en production à surveiller | ## Référencement : catalogue des sites (v0.153, 01/12/2026) Vérifié sur le web le 01/12/2026 ; source et date par site dans `src/lib/seo/directories.ts` (`source`, `checkedOn`, `api`). **Aucun appel** : aucune API d'annuaire n'est utilisée pour écrire une fiche. Constat : Apple Business Connect, TheFork, OpenTable, Zenchef, Uber Eats, Deliveroo, Just Eat = API réservée aux partenaires ; Tripadvisor Content API et Foursquare Places = lecture seule ; Yelp Fusion = payant ; Bing Places = import depuis Google dans son interface, sans API publique. Google (Business Profile) et Meta restent les seules synchronisations prévues (voir plus bas). État des sites calculé à partir des données ALTAIR (liens, avis, bouton Réserver, connexions). diff --git a/KNOWN_ISSUES.md b/KNOWN_ISSUES.md index bf2a1f9a..1f66b6d2 100644 --- a/KNOWN_ISSUES.md +++ b/KNOWN_ISSUES.md @@ -2,6 +2,16 @@ | Id | Gravité | Description | Contournement / plan | |---|---|---|---| +| K-302 | Faible | RappelConso : API jamais appelée depuis la production (appel réel vérifié depuis un navigateur le 01/12/2026) ; un produit sans code-barres ni lot n'est relevé que par la marque et un mot commun (« à vérifier »), un produit acheté sans étiquette photographiée ni lot en stock ne peut pas être croisé | Surveiller l'état de la veille dans HACCP › Rappels produits après le premier passage ; photographier les étiquettes à la réception | +| K-303 | Info | Nuisibles : la fréquence des passages est celle du contrat saisi (aucune fréquence réglementaire chiffrée) ; le technicien signe sur un lien sans compte, identité non vérifiée (nom saisi, adresse IP journalisée) | Suffisant pour le registre ; signature qualifiée si un contrôle l'exige | +| K-304 | Info | Relevés hors ligne : la page de tournée doit être ouverte avant la coupure (pas de mise en cache hors ligne des pages) ; un relevé gardé plus de 72 h sur l'appareil est refusé à l'envoi | Ouvrir la tournée avant de descendre en chambre froide ; mise en cache par le service worker plus tard | +| K-305 | Info | Dossier scellé : la vérification compare le fichier exact ; un PDF réimprimé ou ré-enregistré par un autre logiciel ne correspond plus, même sans modification du contenu | Toujours remettre le fichier téléchargé tel quel | +| K-299 | Info | Commandes du jour : la prévision suit le CA moyen du même jour de la semaine (pas les réservations ni les événements du calendrier) ; un produit sans « fournisseur habituel » n'apparaît chez aucun fournisseur | Renseigner le fournisseur habituel des produits ; prévision par les réservations si le porteur le demande | +| K-300 | Info | Formules à choix : la moyenne pondérée lit les ventes reliées aux fiches (correspondances) ; un plat vendu seulement dans la formule sans ligne de caisse propre n'est pas compté | Reliez les lignes de caisse des formules aux fiches ; Cashpad en direct donnera le détail des choix | +| K-301 | Faible | Annulation par le client : le lien n'apparaît dans les e-mails que si l'adresse publique du site est connue (APP_URL ou ALTAIR_DOMAIN) ; les réservations des plateformes (TheFork…) suivent la règle de la plateforme, sans lien ALTAIR | Variable déjà réglée en production | +| K-297 | Info | Étiquettes cuisine : impression par PDF (AirPrint ou impression système), pas d'envoi direct à l'imprimante Brother (b-PAC / SDK non utilisés). Ordre INCO : liquides comptés à densité 1, ingrédients à la pièce ou à la portion placés après les autres. Le plat témoin n'est pas versé à la traçabilité. | Imprimer en « taille réelle » sur ordinateur ; vérifier l'ordre d'une fiche avec ingrédients à la pièce. | +| K-298 | Info | Repas du personnel : pas de sortie de stock théorique (le plat peut déjà passer en offert dans la caisse) ; l'avantage en nature est une estimation (valeur du repas − participation) à valider par le gestionnaire de paie, l'export de paie reste fondé sur les repas cochés sur les shifts. | Corriger les écarts signalés dans la colonne « Sur les shifts ». | +| K-296 | Faible | Réponses aux e-mails : envoyées depuis la boîte d'envoi d'ALTAIR, pas depuis la boîte Gmail reliée (lecture seule) ; la réponse n'apparaît pas dans le fil Gmail et n'a pas d'en-tête « In-Reply-To » | Envoi par la boîte reliée quand le scope gmail.send sera validé par Google (fin de projet) | | K-292 | Info | Challenges : seules les ventes importées avec la colonne serveur (format v2) comptent ; un serveur au prénom ambigu apparaît sous son nom de caisse et sans heures (CA par heure : Donnée manquante) | Relier le nom dans Ventes › Serveurs ; Cashpad en direct quand l'accès existera | | K-293 | Info | Rapports personnalisés : la condition d'envoi ne porte que sur les indicateurs chiffrés du rapport de gestion (pas de condition sur la trésorerie, les devis, ni sur les rapports de fermeture et de groupe) | Étendre aux autres rapports si le porteur le demande | | K-294 | Faible | Automatisations : délai mesuré au passage du planificateur (15 minutes près) ; une situation validée n'est pas envoyée par e-mail (cloche et centre de notifications seulement) | Suffisant pour l'usage ; e-mail récapitulatif si demandé | diff --git a/ROADMAP.md b/ROADMAP.md index 7261d3b4..bdb8b9d6 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -7,14 +7,16 @@ | 2 | Moteur financier, Cashpad, Pennylane, imports, rapprochements | **Commencée** — moteur + import CSV + résultat estimé faits ; banque et trésorerie (relevés CSV/OFX, rapprochement, prévision) v0.27.0 ; Pennylane en lecture seule v0.28.0 (à confirmer avec un jeton réel) ; centre des connexions avec fiche par service, synchronisation automatique et déconnexion avec effacement (v0.101) ; ventes détaillées (produits, jours × heures, services, serveurs, tables, tickets) et import automatique des exports de caisse par profil de colonnes (v0.102) ; bénéfice avant et après impôt par heure, jour, semaine et mois avec comparaisons N-1 (v0.138) ; catégories Pennylane (v0.139) ; objectifs du budget depuis l'historique avec un % choisi (v0.140) ; bénéfice par plat vendu (v0.141) ; explications en langage simple et pré-bilan de l'exercice (v0.142) ; météo et occupation hôtelière de Paris (v0.143) | | 3 | Achats, fournisseurs, stocks, fiches techniques | **Partielle** — achats et fournisseurs (v0.5.0), stocks et fiches techniques (v0.6.0), produits et pertes (v0.7.0), commandes et réceptions (v0.8.0), demandes d'avoir (v0.9.0), écrans téléphone et installation sur l'écran d'accueil (v0.10.0), recettes complètes (v0.11.0), valorisation CUMP/FIFO, mercuriales et alertes (v0.12.0) livrés ; stock théorique, écart théorique / réel, rotation, surstock et menu engineering livrés (documentation v0.84) ; fiches versionnées, code article, base du stock compté ou théorique et dates limites DLC / DDM avec alerte (v0.91) ; transfert refusé avant un inventaire validé et bons de commande au prix des offres fournisseur (v0.99) ; clôture automatique des lots par la perte « péremption » et l'inventaire, contrôle fournisseur au détail près : bon de livraison photographié et lu, facture Pennylane comparée ligne à ligne (v0.103) | | 4 | RH, planning, pointeuse | **Commencée** — recrutement, intégration, formations, entretiens et compétences (v0.161) ; fiches salariés, contrats et avenants, registre du personnel (v0.13.0), planning avec alertes HCR (v0.14.0), heures réelles et budget vs réel (v0.15.0), contrats, avenants, attestations et certificats en PDF (v0.16.0), espace salarié, demandes d'absence et messagerie (v0.17.0), documents générés depuis les modèles du porteur : contrats par poste, extras, attestations de travail, avenants, avertissements, période d'essai, acompte (v0.18.0), e-mails depuis Gmail et signature électronique des documents (v0.19.0) : lot 4 terminé ; pointeuse sur borne avec code PIN et hors ligne (v0.34.0) ; documents RH sans papier : signatures tracées employeur et salarié, solde de tout compte, relevé d'heures mensuel, relances automatiques, dossier salarié numérique (v0.129) ; compteurs de congés payés et repos compensateur calculés seuls (v0.120) ; application salarié : pointage par téléphone avec zone GPS, report automatique des heures pointées, échanges de shift (v0.121) ; planning rapide (glisser-déposer, shifts prédéfinis, couleurs, salle / cuisine, PDF, dépublier) en v0.115 ; DPAE en un clic : préparée depuis la fiche sans ressaisie, rangée dans le dossier, accusé classé automatiquement (v0.137, envoi direct à l'URSSAF en attente d'habilitation) | -| 5 | HACCP, tâches, maintenance | **Livrée** — relevés de température, contrôles à réception et tableau de bord HACCP sur téléphone (v0.20.0), plan de nettoyage, check-lists et huiles de friture (v0.21.0), traçabilité avec photo, températures produit et dossier HACCP en PDF (v0.22.0), tâches planifiées, maintenance et compte Cuisine (v0.23.0) ; cycle complet d'une panne : responsables prévenus, devis lu et validé, facture Pennylane rattachée automatiquement, coûts par mois, équipement et réparateur (v0.158) ; service du jour sans papier (v0.127 : « Mon service » attribué depuis le planning, photos de preuve, comptage de caisse, cahier de liaison, registre des incidents) ; clôture de caisse par serveur et « Total clôture caisse » automatiques, check-lists d'ouverture et de fermeture retirées (v0.150) | +| 5 | HACCP, tâches, maintenance | **Livrée** — relevés de température, contrôles à réception et tableau de bord HACCP sur téléphone (v0.20.0), plan de nettoyage, check-lists et huiles de friture (v0.21.0), traçabilité avec photo, températures produit et dossier HACCP en PDF (v0.22.0), tâches planifiées, maintenance et compte Cuisine (v0.23.0) ; cycle complet d'une panne : responsables prévenus, devis lu et validé, facture Pennylane rattachée automatiquement, coûts par mois, équipement et réparateur (v0.158) ; service du jour sans papier (v0.127 : « Mon service » attribué depuis le planning, photos de preuve, comptage de caisse, cahier de liaison, registre des incidents) ; clôture de caisse par serveur et « Total clôture caisse » automatiques, check-lists d'ouverture et de fermeture retirées (v0.150) ; veille RappelConso, matrice des allergènes avec page client, nuisibles signés par le technicien, dossier HACCP scellé et relevés hors ligne (v0.172) | | 6 | Gmail, documents, devis, commercial, automatisations | **Livrée** — envoi Gmail (v0.19.0), ALTAIR Mail : boîtes Gmail reliées par OAuth, boîte de réception commune, factures et attestations reçues lues, rapprochées et classées (v0.160, lecture en attente de la validation Google), devis avec accord en ligne (v0.29.0), documents et échéances (v0.30.0), commercial (v0.36.0), automatisations (v0.38.0), formulaire public de demande (v0.60.0) | | 7 | Réservations, plan de salle, CRM, téléphonie | **Lot 6 terminé** — plan de salle modifiable (v0.24.0), réservations avec agenda, créneaux, horaires, exceptions, provenance et e-mails (v0.25.0), service en direct sur le plan et fiches clients avec consentements et RGPD (v0.26.0) ; acomptes, réservation en ligne, plateformes et téléphonie plus tard | | 8 | Marketing, studio IA, réseaux sociaux, réputation | **Commencée** — campagnes e-mail (v0.32.0), réputation (v0.40.0, thèmes des avis v0.46.0, règles de réponse par note, alertes 1 ★ / transmission 2 ★, comparatif et courbe mensuelle en v0.90 ; synchronisation des avis Google par le compte Google relié et publication automatique des réponses par note, désactivée par défaut, en attente de l'accès Google en v0.132 ; actualités Google programmées, préparées par l'IA ou par modèle, validées ou publiées automatiquement en v0.133), Studio de visuels sans service payant (v0.79.0), Réseaux sociaux : calendrier, publication planifiée et automatique Instagram et Facebook (v0.124.0, en attente d'accès Meta) | -| 9 | Intelligence centrale, prévisions, audit | **Commencée** — recommandations sans clé (v0.98), prévisions (v0.97) corrigées des jours fériés, vacances scolaires et événements, planning proposé depuis les prévisions et simulations stratégiques (v0.166) ; challenges serveurs, rapports personnalisables avec envoi sur seuil, automatisations avec conditions, délais et validation, suivi des abonnements (v0.167) | +| 9 | Intelligence centrale, prévisions, audit | **Commencée** — recommandations sans clé (v0.98), prévisions (v0.97) corrigées des jours fériés, vacances scolaires et événements, planning proposé depuis les prévisions et simulations stratégiques (v0.166) ; challenges serveurs, rapports personnalisables avec envoi sur seuil, automatisations avec conditions, délais et validation, suivi des abonnements (v0.167) ; réponses aux e-mails préparées et envoyées après validation (v0.169) | | 10 | Consolidation groupe, investissements, commercialisation | **Commencée** — flux entre sociétés liées et éliminations indicatives (v0.161) ; simulations d'investissement (v0.37.0), tableau de bord groupe avec résumé hebdomadaire en aperçu (v0.119.0), bouton « Démonstration » tout relié pour présenter ALTAIR (v0.157) | | 11 | Applications mobiles, partenaires, international | À faire | +> 01/12/2026, v0.170 : étiquettes cuisine (préparation INCO, DLC secondaire, plat témoin, lot automatique, PDF Brother 62 / 102 mm) et repas du personnel depuis la fiche avec avantage en nature estimé. + > 01/12/2026, v0.164 : P1 rentabilité (pertes de préparation, note des fournisseurs, demandes de prix multi-fournisseurs, commandes groupées, commissions et redevances) et P4 marketing (médiathèque, photo du plat, meilleurs horaires, idées de contenu, anti-répétition) livrés. ## Vue par priorités P0 à P5 (29/11/2026) @@ -37,6 +39,8 @@ HACCP automatique (v0.136, 30/11/2026) : sondes de température prêtes à branc Registres et administration (v0.162, 01/12/2026) : registres EPI, incendie, contrôles (depuis Documents) et vigilance (depuis les achats), immobilisations proposées depuis les factures, calendrier fiscal et social avec export agenda, contrôle qualité des plats, liste d'attente des réservations. Restent en P2 : recrutement, entretiens, compétences, flux entre sociétés du groupe et tableaux de bord par fonction (autre fil), validation professionnelle des règles. +Comparaison Onrush (v0.171, 01/12/2026) : coût des formules entrée-plat-dessert à choix et suppléments, commandes du jour (qui commander, combien, au colis, rappel du matin), annulation de réservation par le client depuis un lien. Suite possible : prévision des commandes par les réservations. + ## Prochaines étapes recommandées (ordre) 0. ✓ v0.154 (01/12/2026) : tablettes de l'établissement (borne de pointage et tablette HACCP sans compte ouvert, guide d'installation). ✓ v0.163 : tablettes verrouillées sur leur usage, accueil HACCP en tuiles avec compteurs et onglets, code choisi par le salarié en option, accès salarié cumulables et ouverture en groupe. Ensuite : relevés HACCP hors ligne sur la tablette. 1. ✓ En ligne sur https://altair.klencio.fr (28/11/2026), déploiement automatique à chaque push sur `main`. Données fictives uniquement tant que K-001/K-002/K-004 ne sont pas levés. diff --git a/TASKS.md b/TASKS.md index cb39e24e..0d8bd2ae 100644 --- a/TASKS.md +++ b/TASKS.md @@ -1,5 +1,32 @@ # Tâches +## Terminé (01/12/2026, v0.169 « Réponses aux e-mails préparées pour vous ») +- [x] Réponses automatiques aux e-mails : modèles, brouillons à relire, envoi sur clic (ADR-194) +- [ ] Envoi dans le fil Gmail quand le scope gmail.send sera validé (K-296) + +## Terminé (01/12/2026, v0.170 « Étiquettes cuisine et repas du personnel ») +- [x] Étiquettes préparation (INCO, allergènes en gras), produit entamé (DLC secondaire), plat témoin ; lot automatique ; PDF Brother 62 / 102 mm, AirPrint +- [x] Durées de conservation par fiche et par produit ; étiquettes versées à la traçabilité +- [x] Repas du personnel depuis la fiche (offert, au coût, prix libre), récapitulatif mensuel et avantage en nature estimé +- [ ] Éventuel : impression directe sans boîte de dialogue (application Brother, b-PAC) si le porteur le souhaite +- [ ] Éventuel : export des repas du personnel vers la paie à la place des repas cochés sur les shifts (décision du porteur) + +## Terminé (01/12/2026, v0.171 « Coût des formules, commandes du jour, annulation par le client ») +- [x] Formules à choix : étapes, plats au choix, suppléments, fourchette de coût, moyenne pondérée par les ventes, marges et food cost des cas extrêmes +- [x] Commandes du jour : jours de livraison, heure limite, quantités prévues au colis, bon préparé en un clic, rappel du matin +- [x] Annulation de réservation par le client depuis le lien des e-mails, délai réglable, liste d'attente prévenue +- [ ] Prévision des commandes par les réservations et les événements du calendrier (K-299) +- [ ] Porteur : renseigner les jours de livraison de chaque fournisseur et le fournisseur habituel des produits + +## Terminé (01/12/2026, v0.172 « Hygiène : ce qu'Onrush avait en plus ») +- [x] Veille RappelConso croisée avec traçabilité, stock et catalogue, action corrective et notification +- [x] Matrice des allergènes imprimable, page client publique avec QR et filtre +- [x] Nuisibles : contrat, n° Certibiocide, plan des pièges, passages signés par le technicien sur un lien, rappels de retard +- [x] Dossier HACCP scellé (QR, empreinte, page /verifier) +- [x] Relevés de température hors ligne +- [ ] Surveiller le premier passage de la veille RappelConso en production (K-302) +- [ ] Éventuel : mise en cache hors ligne de la tournée par le service worker (K-304) + ## Terminé (01/12/2026, v0.160 « ALTAIR Mail ») - [x] Boîtes Gmail reliées par OAuth (plusieurs boîtes, par établissement ou organisation), lecture toutes les 30 minutes - [x] Boîte de réception centralisée triée, factures, devis et attestations lus, rapprochés (Pennylane, fournisseurs, pannes), vérifiés, classés dans Documents ou rattachés à une panne, notifications diff --git a/drizzle/0124_reponses_mail.sql b/drizzle/0124_reponses_mail.sql new file mode 100644 index 00000000..43c8e780 --- /dev/null +++ b/drizzle/0124_reponses_mail.sql @@ -0,0 +1,44 @@ +CREATE TABLE "mail_reply_drafts" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "organization_id" uuid NOT NULL, + "account_id" uuid NOT NULL, + "message_id" uuid NOT NULL, + "template_id" uuid, + "to_email" text NOT NULL, + "subject" text NOT NULL, + "body" text NOT NULL, + "status" text DEFAULT 'a_valider' NOT NULL, + "decided_by" uuid, + "decided_at" timestamp with time zone, + "outbox_id" uuid, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "mail_reply_drafts_status_ck" CHECK ("mail_reply_drafts"."status" IN ('a_valider', 'envoye', 'ecarte')) +); +--> statement-breakpoint +CREATE TABLE "mail_reply_templates" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "organization_id" uuid NOT NULL, + "name" text NOT NULL, + "category" text NOT NULL, + "keyword" text, + "subject" text NOT NULL, + "body" text NOT NULL, + "active" boolean DEFAULT true NOT NULL, + "created_by" uuid NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone, + CONSTRAINT "mail_reply_templates_category_ck" CHECK ("mail_reply_templates"."category" IN ('facture', 'devis', 'attestation', 'reservation', 'commande', 'autre')) +); +--> statement-breakpoint +ALTER TABLE "mail_reply_drafts" ADD CONSTRAINT "mail_reply_drafts_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mail_reply_drafts" ADD CONSTRAINT "mail_reply_drafts_account_id_mail_accounts_id_fk" FOREIGN KEY ("account_id") REFERENCES "public"."mail_accounts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mail_reply_drafts" ADD CONSTRAINT "mail_reply_drafts_message_id_mail_messages_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."mail_messages"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mail_reply_drafts" ADD CONSTRAINT "mail_reply_drafts_template_id_mail_reply_templates_id_fk" FOREIGN KEY ("template_id") REFERENCES "public"."mail_reply_templates"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mail_reply_drafts" ADD CONSTRAINT "mail_reply_drafts_decided_by_users_id_fk" FOREIGN KEY ("decided_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mail_reply_templates" ADD CONSTRAINT "mail_reply_templates_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mail_reply_templates" ADD CONSTRAINT "mail_reply_templates_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "mail_reply_drafts_message_uq" ON "mail_reply_drafts" USING btree ("message_id");--> statement-breakpoint +CREATE INDEX "mail_reply_drafts_org_idx" ON "mail_reply_drafts" USING btree ("organization_id","status","created_at");--> statement-breakpoint +CREATE INDEX "mail_reply_templates_org_idx" ON "mail_reply_templates" USING btree ("organization_id");--> statement-breakpoint +-- Isolation RLS (ADR-180) : nouvelles tables avec organization_id. +SELECT altair_enable_tenant_rls(); diff --git a/drizzle/0125_etiquettes_repas_personnel.sql b/drizzle/0125_etiquettes_repas_personnel.sql new file mode 100644 index 00000000..286293df --- /dev/null +++ b/drizzle/0125_etiquettes_repas_personnel.sql @@ -0,0 +1,99 @@ +CREATE TABLE "kitchen_labels" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "organization_id" uuid NOT NULL, + "establishment_id" uuid NOT NULL, + "kind" text NOT NULL, + "recipe_id" uuid, + "item_id" uuid, + "product_label" text NOT NULL, + "lot_number" text NOT NULL, + "supplier_lot" text, + "produced_at" timestamp with time zone NOT NULL, + "dlc" date NOT NULL, + "original_dlc" date, + "shelf_life_days" smallint NOT NULL, + "service" text, + "quantity" text, + "allergens" text[] DEFAULT '{}'::text[] NOT NULL, + "allergen_traces" text[] DEFAULT '{}'::text[] NOT NULL, + "ingredients" jsonb DEFAULT '[]'::jsonb NOT NULL, + "storage_note" text, + "format" text NOT NULL, + "copies" smallint DEFAULT 1 NOT NULL, + "trace_label_id" uuid, + "printed_by" uuid NOT NULL, + "cancelled_at" timestamp with time zone, + "cancelled_by" uuid, + "cancel_reason" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "kitchen_labels_kind_ck" CHECK ("kitchen_labels"."kind" IN ('production', 'ouverture', 'temoin')), + CONSTRAINT "kitchen_labels_format_ck" CHECK ("kitchen_labels"."format" IN ('62x29', '62x100', '102x152')), + CONSTRAINT "kitchen_labels_copies_ck" CHECK ("kitchen_labels"."copies" BETWEEN 1 AND 50 AND "kitchen_labels"."shelf_life_days" BETWEEN 0 AND 90), + CONSTRAINT "kitchen_labels_service_ck" CHECK ("kitchen_labels"."service" IS NULL OR "kitchen_labels"."service" IN ('midi', 'soir')) +); +--> statement-breakpoint +CREATE TABLE "staff_meals" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "organization_id" uuid NOT NULL, + "establishment_id" uuid NOT NULL, + "meal_date" date NOT NULL, + "service" text, + "employee_id" uuid, + "beneficiary_name" text, + "recipe_id" uuid, + "dish_label" text NOT NULL, + "portions" numeric(10, 2) DEFAULT '1' NOT NULL, + "pricing" text NOT NULL, + "unit_cost" numeric(19, 6), + "total_cost" numeric(19, 4), + "amount_paid" numeric(19, 4) DEFAULT '0' NOT NULL, + "meal_value" numeric(19, 4), + "comment" text, + "created_by" uuid NOT NULL, + "cancelled_at" timestamp with time zone, + "cancelled_by" uuid, + "cancel_reason" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "staff_meals_pricing_ck" CHECK ("staff_meals"."pricing" IN ('offert', 'cout', 'prix_libre')), + CONSTRAINT "staff_meals_beneficiary_ck" CHECK (("staff_meals"."employee_id" IS NULL) <> ("staff_meals"."beneficiary_name" IS NULL)), + CONSTRAINT "staff_meals_amounts_ck" CHECK ("staff_meals"."portions" > 0 AND "staff_meals"."portions" <= 20 AND "staff_meals"."amount_paid" >= 0 AND ("staff_meals"."pricing" <> 'offert' OR "staff_meals"."amount_paid" = 0)), + CONSTRAINT "staff_meals_service_ck" CHECK ("staff_meals"."service" IS NULL OR "staff_meals"."service" IN ('midi', 'soir')) +); +--> statement-breakpoint +ALTER TABLE "purchase_items" ADD COLUMN "opened_shelf_life_days" smallint;--> statement-breakpoint +ALTER TABLE "recipes" ADD COLUMN "shelf_life_days" smallint;--> statement-breakpoint +ALTER TABLE "recipes" ADD COLUMN "storage_note" text;--> statement-breakpoint +ALTER TABLE "kitchen_labels" ADD CONSTRAINT "kitchen_labels_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "kitchen_labels" ADD CONSTRAINT "kitchen_labels_establishment_id_establishments_id_fk" FOREIGN KEY ("establishment_id") REFERENCES "public"."establishments"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "kitchen_labels" ADD CONSTRAINT "kitchen_labels_recipe_id_recipes_id_fk" FOREIGN KEY ("recipe_id") REFERENCES "public"."recipes"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "kitchen_labels" ADD CONSTRAINT "kitchen_labels_item_id_purchase_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."purchase_items"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "kitchen_labels" ADD CONSTRAINT "kitchen_labels_trace_label_id_trace_labels_id_fk" FOREIGN KEY ("trace_label_id") REFERENCES "public"."trace_labels"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "kitchen_labels" ADD CONSTRAINT "kitchen_labels_printed_by_users_id_fk" FOREIGN KEY ("printed_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "kitchen_labels" ADD CONSTRAINT "kitchen_labels_cancelled_by_users_id_fk" FOREIGN KEY ("cancelled_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_meals" ADD CONSTRAINT "staff_meals_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_meals" ADD CONSTRAINT "staff_meals_establishment_id_establishments_id_fk" FOREIGN KEY ("establishment_id") REFERENCES "public"."establishments"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_meals" ADD CONSTRAINT "staff_meals_employee_id_employees_id_fk" FOREIGN KEY ("employee_id") REFERENCES "public"."employees"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_meals" ADD CONSTRAINT "staff_meals_recipe_id_recipes_id_fk" FOREIGN KEY ("recipe_id") REFERENCES "public"."recipes"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_meals" ADD CONSTRAINT "staff_meals_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "staff_meals" ADD CONSTRAINT "staff_meals_cancelled_by_users_id_fk" FOREIGN KEY ("cancelled_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "kitchen_labels_est_idx" ON "kitchen_labels" USING btree ("organization_id","establishment_id","produced_at");--> statement-breakpoint +CREATE UNIQUE INDEX "kitchen_labels_lot_uq" ON "kitchen_labels" USING btree ("establishment_id","lot_number");--> statement-breakpoint +CREATE INDEX "staff_meals_est_idx" ON "staff_meals" USING btree ("organization_id","establishment_id","meal_date");--> statement-breakpoint +CREATE INDEX "staff_meals_emp_idx" ON "staff_meals" USING btree ("employee_id","meal_date");--> statement-breakpoint +ALTER TABLE "purchase_items" ADD CONSTRAINT "purchase_items_opened_life_ck" CHECK ("purchase_items"."opened_shelf_life_days" IS NULL OR "purchase_items"."opened_shelf_life_days" BETWEEN 1 AND 60);--> statement-breakpoint +ALTER TABLE "recipes" ADD CONSTRAINT "recipes_shelf_life_ck" CHECK ("recipes"."shelf_life_days" IS NULL OR "recipes"."shelf_life_days" BETWEEN 1 AND 90);--> statement-breakpoint +-- Étiquettes cuisine et repas du personnel : jamais modifiés ni supprimés, seule l'annulation avec motif est possible. +CREATE TRIGGER kitchen_labels_cancel_only BEFORE UPDATE ON kitchen_labels + FOR EACH ROW EXECUTE FUNCTION altair_haccp_cancel_only(); +--> statement-breakpoint +CREATE TRIGGER kitchen_labels_no_delete BEFORE DELETE ON kitchen_labels + FOR EACH ROW EXECUTE FUNCTION altair_forbid_mutation(); +--> statement-breakpoint +CREATE TRIGGER staff_meals_cancel_only BEFORE UPDATE ON staff_meals + FOR EACH ROW EXECUTE FUNCTION altair_haccp_cancel_only(); +--> statement-breakpoint +CREATE TRIGGER staff_meals_no_delete BEFORE DELETE ON staff_meals + FOR EACH ROW EXECUTE FUNCTION altair_forbid_mutation(); +--> statement-breakpoint +-- Isolation RLS (ADR-180) : nouvelles tables avec organization_id. +SELECT altair_enable_tenant_rls(); diff --git a/drizzle/0126_formules_commandes_annulation.sql b/drizzle/0126_formules_commandes_annulation.sql new file mode 100644 index 00000000..f808e150 --- /dev/null +++ b/drizzle/0126_formules_commandes_annulation.sql @@ -0,0 +1,22 @@ +CREATE TABLE "supplier_order_reminders" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "organization_id" uuid NOT NULL, + "establishment_id" uuid NOT NULL, + "day" date NOT NULL, + "suppliers" integer NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "reservation_settings" ADD COLUMN "self_cancel_enabled" boolean DEFAULT true NOT NULL;--> statement-breakpoint +ALTER TABLE "reservation_settings" ADD COLUMN "self_cancel_minutes" integer DEFAULT 120 NOT NULL;--> statement-breakpoint +ALTER TABLE "reservations" ADD COLUMN "manage_token" text DEFAULT replace(gen_random_uuid()::text, '-', '') || replace(gen_random_uuid()::text, '-', '') NOT NULL;--> statement-breakpoint +ALTER TABLE "set_menus" ADD COLUMN "courses" jsonb DEFAULT '[]'::jsonb NOT NULL;--> statement-breakpoint +ALTER TABLE "suppliers" ADD COLUMN "delivery_days" integer[] DEFAULT '{}'::integer[] NOT NULL;--> statement-breakpoint +ALTER TABLE "supplier_order_reminders" ADD CONSTRAINT "supplier_order_reminders_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "supplier_order_reminders" ADD CONSTRAINT "supplier_order_reminders_establishment_id_establishments_id_fk" FOREIGN KEY ("establishment_id") REFERENCES "public"."establishments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "supplier_order_reminders_uq" ON "supplier_order_reminders" USING btree ("establishment_id","day");--> statement-breakpoint +CREATE UNIQUE INDEX "reservations_manage_token_uq" ON "reservations" USING btree ("manage_token");--> statement-breakpoint +ALTER TABLE "reservation_settings" ADD CONSTRAINT "reservation_settings_self_cancel_ck" CHECK ("reservation_settings"."self_cancel_minutes" BETWEEN 0 AND 10080);--> statement-breakpoint +ALTER TABLE "suppliers" ADD CONSTRAINT "suppliers_delivery_days_ck" CHECK ("suppliers"."delivery_days" <@ ARRAY[1,2,3,4,5,6,7]); +-- Isolation RLS (ADR-180) : nouvelles tables avec organization_id. +SELECT altair_enable_tenant_rls(); diff --git a/drizzle/0127_hygiene_rappels_nuisibles.sql b/drizzle/0127_hygiene_rappels_nuisibles.sql new file mode 100644 index 00000000..e28b4b41 --- /dev/null +++ b/drizzle/0127_hygiene_rappels_nuisibles.sql @@ -0,0 +1,132 @@ +CREATE TABLE "allergen_pages" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "organization_id" uuid NOT NULL, + "establishment_id" uuid NOT NULL, + "token" text NOT NULL, + "enabled" boolean DEFAULT true NOT NULL, + "created_by" uuid NOT NULL, + "updated_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "haccp_sealed_exports" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "organization_id" uuid NOT NULL, + "establishment_id" uuid NOT NULL, + "kind" text DEFAULT 'dossier' NOT NULL, + "period_from" date NOT NULL, + "period_to" date NOT NULL, + "verify_token" text NOT NULL, + "sha256" text, + "bytes" integer, + "created_by" uuid NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "haccp_sealed_exports_kind_ck" CHECK ("haccp_sealed_exports"."kind" IN ('dossier')) +); +--> statement-breakpoint +CREATE TABLE "pest_control_contracts" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "organization_id" uuid NOT NULL, + "establishment_id" uuid NOT NULL, + "provider_name" text NOT NULL, + "certibiocide_number" text, + "contact_phone" text, + "contact_email" text, + "starts_on" date, + "ends_on" date, + "visits_per_year" integer, + "trap_plan" "bytea", + "trap_plan_mime" text, + "trap_plan_size" integer, + "notes" text, + "archived_at" timestamp with time zone, + "created_by" uuid NOT NULL, + "updated_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "pest_control_contracts_visits_ck" CHECK ("pest_control_contracts"."visits_per_year" IS NULL OR ("pest_control_contracts"."visits_per_year" BETWEEN 1 AND 52)), + CONSTRAINT "pest_control_contracts_plan_ck" CHECK ("pest_control_contracts"."trap_plan_size" IS NULL OR "pest_control_contracts"."trap_plan_size" <= 5242880) +); +--> statement-breakpoint +CREATE TABLE "pest_control_visits" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "organization_id" uuid NOT NULL, + "establishment_id" uuid NOT NULL, + "contract_id" uuid, + "visit_on" date NOT NULL, + "kind" text DEFAULT 'contrat' NOT NULL, + "technician_name" text, + "activity" text, + "pests" text[] DEFAULT '{}'::text[] NOT NULL, + "findings" text, + "actions" text, + "recommendations" text, + "products" text, + "sign_token_hash" text, + "sign_token_expires_at" timestamp with time zone, + "signed_at" timestamp with time zone, + "signer_name" text, + "signature" "bytea", + "corrective_action_id" uuid, + "recorded_by" uuid NOT NULL, + "cancelled_at" timestamp with time zone, + "cancelled_by" uuid, + "cancel_reason" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "pest_control_visits_kind_ck" CHECK ("pest_control_visits"."kind" IN ('contrat', 'curatif')), + CONSTRAINT "pest_control_visits_activity_ck" CHECK ("pest_control_visits"."activity" IS NULL OR "pest_control_visits"."activity" IN ('aucune', 'faible', 'forte')), + CONSTRAINT "pest_control_visits_signed_ck" CHECK (("pest_control_visits"."signed_at" IS NULL) = ("pest_control_visits"."signature" IS NULL)) +); +--> statement-breakpoint +CREATE TABLE "product_recalls" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "source_id" integer NOT NULL, + "fiche_number" text, + "version" integer, + "published_at" timestamp with time zone NOT NULL, + "label" text NOT NULL, + "brand" text, + "subcategory" text, + "references" text, + "gtins" text[] DEFAULT '{}'::text[] NOT NULL, + "lots" text[] DEFAULT '{}'::text[] NOT NULL, + "reason" text, + "risks" text, + "consumer_actions" text, + "sale_area" text, + "distributors" text, + "fiche_url" text, + "image_url" text, + "ends_on" date, + "fetched_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "haccp_corrective_actions" DROP CONSTRAINT "haccp_corrective_actions_source_ck";--> statement-breakpoint +ALTER TABLE "temperature_readings" ADD COLUMN "client_ref" uuid;--> statement-breakpoint +ALTER TABLE "temperature_readings" ADD COLUMN "entered_offline" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "allergen_pages" ADD CONSTRAINT "allergen_pages_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "allergen_pages" ADD CONSTRAINT "allergen_pages_establishment_id_establishments_id_fk" FOREIGN KEY ("establishment_id") REFERENCES "public"."establishments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "allergen_pages" ADD CONSTRAINT "allergen_pages_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "haccp_sealed_exports" ADD CONSTRAINT "haccp_sealed_exports_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "haccp_sealed_exports" ADD CONSTRAINT "haccp_sealed_exports_establishment_id_establishments_id_fk" FOREIGN KEY ("establishment_id") REFERENCES "public"."establishments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "haccp_sealed_exports" ADD CONSTRAINT "haccp_sealed_exports_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "pest_control_contracts" ADD CONSTRAINT "pest_control_contracts_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "pest_control_contracts" ADD CONSTRAINT "pest_control_contracts_establishment_id_establishments_id_fk" FOREIGN KEY ("establishment_id") REFERENCES "public"."establishments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "pest_control_contracts" ADD CONSTRAINT "pest_control_contracts_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "pest_control_visits" ADD CONSTRAINT "pest_control_visits_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "pest_control_visits" ADD CONSTRAINT "pest_control_visits_establishment_id_establishments_id_fk" FOREIGN KEY ("establishment_id") REFERENCES "public"."establishments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "pest_control_visits" ADD CONSTRAINT "pest_control_visits_contract_id_pest_control_contracts_id_fk" FOREIGN KEY ("contract_id") REFERENCES "public"."pest_control_contracts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "pest_control_visits" ADD CONSTRAINT "pest_control_visits_corrective_action_id_haccp_corrective_actions_id_fk" FOREIGN KEY ("corrective_action_id") REFERENCES "public"."haccp_corrective_actions"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "pest_control_visits" ADD CONSTRAINT "pest_control_visits_recorded_by_users_id_fk" FOREIGN KEY ("recorded_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "pest_control_visits" ADD CONSTRAINT "pest_control_visits_cancelled_by_users_id_fk" FOREIGN KEY ("cancelled_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "allergen_pages_token_uq" ON "allergen_pages" USING btree ("token");--> statement-breakpoint +CREATE UNIQUE INDEX "allergen_pages_est_uq" ON "allergen_pages" USING btree ("establishment_id");--> statement-breakpoint +CREATE UNIQUE INDEX "haccp_sealed_exports_token_uq" ON "haccp_sealed_exports" USING btree ("verify_token");--> statement-breakpoint +CREATE INDEX "haccp_sealed_exports_est_idx" ON "haccp_sealed_exports" USING btree ("organization_id","establishment_id","created_at");--> statement-breakpoint +CREATE INDEX "pest_control_contracts_est_idx" ON "pest_control_contracts" USING btree ("organization_id","establishment_id");--> statement-breakpoint +CREATE INDEX "pest_control_visits_est_idx" ON "pest_control_visits" USING btree ("organization_id","establishment_id","visit_on");--> statement-breakpoint +CREATE UNIQUE INDEX "pest_control_visits_token_uq" ON "pest_control_visits" USING btree ("sign_token_hash") WHERE "pest_control_visits"."sign_token_hash" IS NOT NULL;--> statement-breakpoint +CREATE UNIQUE INDEX "product_recalls_source_uq" ON "product_recalls" USING btree ("source_id");--> statement-breakpoint +CREATE INDEX "product_recalls_published_idx" ON "product_recalls" USING btree ("published_at");--> statement-breakpoint +CREATE UNIQUE INDEX "temperature_readings_client_ref_uq" ON "temperature_readings" USING btree ("organization_id","client_ref") WHERE "temperature_readings"."client_ref" IS NOT NULL;--> statement-breakpoint +ALTER TABLE "haccp_corrective_actions" ADD CONSTRAINT "haccp_corrective_actions_source_ck" CHECK ("haccp_corrective_actions"."source" IN ('sonde_hors_plage', 'sonde_muette', 'releves_manquants', 'nettoyage_manquant', 'date_limite', 'manuel', 'rappel_produit', 'nuisibles'));--> statement-breakpoint +SELECT altair_enable_tenant_rls(); diff --git a/drizzle/meta/0124_snapshot.json b/drizzle/meta/0124_snapshot.json new file mode 100644 index 00000000..6fea866c --- /dev/null +++ b/drizzle/meta/0124_snapshot.json @@ -0,0 +1,40065 @@ +{ + "id": "ad83bcf3-8333-41a4-960b-baee3b9282a9", + "prevId": "e130d134-a6ac-492d-a32c-1897ecd5191d", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.absence_requests": { + "name": "absence_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "part": { + "name": "part", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'journee'" + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "absence_requests_emp_idx": { + "name": "absence_requests_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "absence_requests_organization_id_organizations_id_fk": { + "name": "absence_requests_organization_id_organizations_id_fk", + "tableFrom": "absence_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "absence_requests_employee_id_employees_id_fk": { + "name": "absence_requests_employee_id_employees_id_fk", + "tableFrom": "absence_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "absence_requests_decided_by_users_id_fk": { + "name": "absence_requests_decided_by_users_id_fk", + "tableFrom": "absence_requests", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "absence_requests_created_by_users_id_fk": { + "name": "absence_requests_created_by_users_id_fk", + "tableFrom": "absence_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "absence_requests_status_ck": { + "name": "absence_requests_status_ck", + "value": "\"absence_requests\".\"status\" IN ('en_attente', 'acceptee', 'refusee', 'annulee')" + }, + "absence_requests_dates_ck": { + "name": "absence_requests_dates_ck", + "value": "\"absence_requests\".\"end_date\" >= \"absence_requests\".\"start_date\"" + } + }, + "isRLSEnabled": false + }, + "public.account_invites": { + "name": "account_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'invite'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "account_invites_token_uq": { + "name": "account_invites_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "account_invites_user_idx": { + "name": "account_invites_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_invites_organization_id_organizations_id_fk": { + "name": "account_invites_organization_id_organizations_id_fk", + "tableFrom": "account_invites", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_invites_user_id_users_id_fk": { + "name": "account_invites_user_id_users_id_fk", + "tableFrom": "account_invites", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_invites_created_by_users_id_fk": { + "name": "account_invites_created_by_users_id_fk", + "tableFrom": "account_invites", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "account_invites_purpose_ck": { + "name": "account_invites_purpose_ck", + "value": "\"account_invites\".\"purpose\" IN ('invite', 'reset', 'verify')" + } + }, + "isRLSEnabled": false + }, + "public.ai_actions": { + "name": "ai_actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "source_href": { + "name": "source_href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "discard_reason": { + "name": "discard_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_actions_org_idx": { + "name": "ai_actions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_actions_pending_uq": { + "name": "ai_actions_pending_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_actions\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_actions_organization_id_organizations_id_fk": { + "name": "ai_actions_organization_id_organizations_id_fk", + "tableFrom": "ai_actions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_actions_created_by_users_id_fk": { + "name": "ai_actions_created_by_users_id_fk", + "tableFrom": "ai_actions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "ai_actions_decided_by_users_id_fk": { + "name": "ai_actions_decided_by_users_id_fk", + "tableFrom": "ai_actions", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_actions_kind_ck": { + "name": "ai_actions_kind_ck", + "value": "\"ai_actions\".\"kind\" IN ('negotiation_email', 'price_change')" + }, + "ai_actions_status_ck": { + "name": "ai_actions_status_ck", + "value": "\"ai_actions\".\"status\" IN ('pending', 'sent', 'applied', 'done_manual', 'discarded')" + }, + "ai_actions_decided_ck": { + "name": "ai_actions_decided_ck", + "value": "\"ai_actions\".\"status\" = 'pending' OR \"ai_actions\".\"decided_at\" IS NOT NULL" + }, + "ai_actions_discarded_ck": { + "name": "ai_actions_discarded_ck", + "value": "\"ai_actions\".\"status\" <> 'discarded' OR \"ai_actions\".\"discard_reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.ai_conversations": { + "name": "ai_conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_conversations_user_idx": { + "name": "ai_conversations_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_conversations_organization_id_organizations_id_fk": { + "name": "ai_conversations_organization_id_organizations_id_fk", + "tableFrom": "ai_conversations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_conversations_user_id_users_id_fk": { + "name": "ai_conversations_user_id_users_id_fk", + "tableFrom": "ai_conversations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_messages": { + "name": "ai_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tools": { + "name": "tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_messages_conv_idx": { + "name": "ai_messages_conv_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_messages_org_idx": { + "name": "ai_messages_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_messages_organization_id_organizations_id_fk": { + "name": "ai_messages_organization_id_organizations_id_fk", + "tableFrom": "ai_messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_messages_conversation_id_ai_conversations_id_fk": { + "name": "ai_messages_conversation_id_ai_conversations_id_fk", + "tableFrom": "ai_messages", + "tableTo": "ai_conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_messages_role_ck": { + "name": "ai_messages_role_ck", + "value": "\"ai_messages\".\"role\" IN ('user', 'assistant')" + } + }, + "isRLSEnabled": false + }, + "public.ai_reco_dismissals": { + "name": "ai_reco_dismissals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reco_id": { + "name": "reco_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "until": { + "name": "until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "dismissed_by": { + "name": "dismissed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_reco_dismissals_uq": { + "name": "ai_reco_dismissals_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reco_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_reco_dismissals_organization_id_organizations_id_fk": { + "name": "ai_reco_dismissals_organization_id_organizations_id_fk", + "tableFrom": "ai_reco_dismissals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_reco_dismissals_dismissed_by_users_id_fk": { + "name": "ai_reco_dismissals_dismissed_by_users_id_fk", + "tableFrom": "ai_reco_dismissals", + "tableTo": "users", + "columnsFrom": [ + "dismissed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_reco_dismissals_reason_ck": { + "name": "ai_reco_dismissals_reason_ck", + "value": "length(trim(\"ai_reco_dismissals\".\"reason\")) >= 3" + } + }, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "before": { + "name": "before", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "after": { + "name": "after", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_org_idx": { + "name": "audit_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_log_organization_id_organizations_id_fk": { + "name": "audit_log_organization_id_organizations_id_fk", + "tableFrom": "audit_log", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "audit_log_user_id_users_id_fk": { + "name": "audit_log_user_id_users_id_fk", + "tableFrom": "audit_log", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_throttle": { + "name": "auth_throttle", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_throttle_ip_idx": { + "name": "auth_throttle_ip_idx", + "columns": [ + { + "expression": "ip", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "approver_id": { + "name": "approver_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "delivered": { + "name": "delivered", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_approvals_once_uq": { + "name": "automation_approvals_once_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_approvals_org_idx": { + "name": "automation_approvals_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_approvals_organization_id_organizations_id_fk": { + "name": "automation_approvals_organization_id_organizations_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_approvals_rule_id_automation_rules_id_fk": { + "name": "automation_approvals_rule_id_automation_rules_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_approvals_approver_id_users_id_fk": { + "name": "automation_approvals_approver_id_users_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "users", + "columnsFrom": [ + "approver_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "automation_approvals_decided_by_users_id_fk": { + "name": "automation_approvals_decided_by_users_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_approvals_status_ck": { + "name": "automation_approvals_status_ck", + "value": "\"automation_approvals\".\"status\" IN ('pending', 'approved', 'rejected')" + }, + "automation_approvals_reason_ck": { + "name": "automation_approvals_reason_ck", + "value": "\"automation_approvals\".\"status\" <> 'rejected' OR \"automation_approvals\".\"reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.automation_drafts": { + "name": "automation_drafts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rule_name": { + "name": "rule_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "source_href": { + "name": "source_href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prepared_for": { + "name": "prepared_for", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "discard_reason": { + "name": "discard_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_entity_type": { + "name": "result_entity_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_entity_id": { + "name": "result_entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_drafts_org_idx": { + "name": "automation_drafts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_drafts_est_idx": { + "name": "automation_drafts_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_drafts_organization_id_organizations_id_fk": { + "name": "automation_drafts_organization_id_organizations_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_drafts_establishment_id_establishments_id_fk": { + "name": "automation_drafts_establishment_id_establishments_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_drafts_rule_id_automation_rules_id_fk": { + "name": "automation_drafts_rule_id_automation_rules_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "automation_drafts_prepared_for_users_id_fk": { + "name": "automation_drafts_prepared_for_users_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "users", + "columnsFrom": [ + "prepared_for" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "automation_drafts_decided_by_users_id_fk": { + "name": "automation_drafts_decided_by_users_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_drafts_kind_ck": { + "name": "automation_drafts_kind_ck", + "value": "\"automation_drafts\".\"kind\" IN ('purchase_order', 'credit_request', 'maintenance_request')" + }, + "automation_drafts_status_ck": { + "name": "automation_drafts_status_ck", + "value": "\"automation_drafts\".\"status\" IN ('pending', 'validated', 'discarded', 'expired')" + }, + "automation_drafts_validated_ck": { + "name": "automation_drafts_validated_ck", + "value": "\"automation_drafts\".\"status\" <> 'validated' OR (\"automation_drafts\".\"decided_by\" IS NOT NULL AND \"automation_drafts\".\"result_entity_type\" IS NOT NULL)" + }, + "automation_drafts_discarded_ck": { + "name": "automation_drafts_discarded_ck", + "value": "\"automation_drafts\".\"status\" <> 'discarded' OR \"automation_drafts\".\"discard_reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.automation_occurrences": { + "name": "automation_occurrences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "occurrence_key": { + "name": "occurrence_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "draft_id": { + "name": "draft_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_occurrences_uq": { + "name": "automation_occurrences_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_occurrences_org_key_idx": { + "name": "automation_occurrences_org_key_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_occurrences_organization_id_organizations_id_fk": { + "name": "automation_occurrences_organization_id_organizations_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_occurrences_rule_id_automation_rules_id_fk": { + "name": "automation_occurrences_rule_id_automation_rules_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_occurrences_draft_id_automation_drafts_id_fk": { + "name": "automation_occurrences_draft_id_automation_drafts_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "automation_drafts", + "columnsFrom": [ + "draft_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_pending": { + "name": "automation_pending", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_pending_org_idx": { + "name": "automation_pending_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_pending_organization_id_organizations_id_fk": { + "name": "automation_pending_organization_id_organizations_id_fk", + "tableFrom": "automation_pending", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_pending_rule_id_automation_rules_id_fk": { + "name": "automation_pending_rule_id_automation_rules_id_fk", + "tableFrom": "automation_pending", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_pending_user_id_users_id_fk": { + "name": "automation_pending_user_id_users_id_fk", + "tableFrom": "automation_pending", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "automation_pending_rule_id_user_id_item_key_pk": { + "name": "automation_pending_rule_id_user_id_item_key_pk", + "columns": [ + "rule_id", + "user_id", + "item_key" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_rules": { + "name": "automation_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "min_severity": { + "name": "min_severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'warning'" + }, + "recipient_ids": { + "name": "recipient_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "by_email": { + "name": "by_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'notify'" + }, + "params": { + "name": "params", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conditions": { + "name": "conditions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "delay_minutes": { + "name": "delay_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "approver_id": { + "name": "approver_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_triggered_at": { + "name": "last_triggered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_rules_org_idx": { + "name": "automation_rules_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_rules_organization_id_organizations_id_fk": { + "name": "automation_rules_organization_id_organizations_id_fk", + "tableFrom": "automation_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_rules_establishment_id_establishments_id_fk": { + "name": "automation_rules_establishment_id_establishments_id_fk", + "tableFrom": "automation_rules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_rules_approver_id_users_id_fk": { + "name": "automation_rules_approver_id_users_id_fk", + "tableFrom": "automation_rules", + "tableTo": "users", + "columnsFrom": [ + "approver_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "automation_rules_created_by_users_id_fk": { + "name": "automation_rules_created_by_users_id_fk", + "tableFrom": "automation_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_rules_severity_ck": { + "name": "automation_rules_severity_ck", + "value": "\"automation_rules\".\"min_severity\" IN ('warning', 'danger')" + }, + "automation_rules_action_ck": { + "name": "automation_rules_action_ck", + "value": "\"automation_rules\".\"action\" IN ('notify', 'draft_purchase_order', 'draft_credit_request', 'draft_maintenance_request')" + }, + "automation_rules_delay_ck": { + "name": "automation_rules_delay_ck", + "value": "\"automation_rules\".\"delay_minutes\" >= 0 AND \"automation_rules\".\"delay_minutes\" <= 10080" + } + }, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emailed": { + "name": "emailed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_runs_once_uq": { + "name": "automation_runs_once_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_runs_org_idx": { + "name": "automation_runs_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_runs_organization_id_organizations_id_fk": { + "name": "automation_runs_organization_id_organizations_id_fk", + "tableFrom": "automation_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_runs_rule_id_automation_rules_id_fk": { + "name": "automation_runs_rule_id_automation_rules_id_fk", + "tableFrom": "automation_runs", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_runs_user_id_users_id_fk": { + "name": "automation_runs_user_id_users_id_fk", + "tableFrom": "automation_runs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_settings": { + "name": "automation_settings", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "paused": { + "name": "paused", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_by": { + "name": "paused_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "paused_at": { + "name": "paused_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "automation_settings_organization_id_organizations_id_fk": { + "name": "automation_settings_organization_id_organizations_id_fk", + "tableFrom": "automation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_settings_paused_by_users_id_fk": { + "name": "automation_settings_paused_by_users_id_fk", + "tableFrom": "automation_settings", + "tableTo": "users", + "columnsFrom": [ + "paused_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bank_accounts": { + "name": "bank_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bank_name": { + "name": "bank_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban_last4": { + "name": "iban_last4", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "opening_balance": { + "name": "opening_balance", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "opening_date": { + "name": "opening_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "alert_threshold": { + "name": "alert_threshold", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_accounts_org_idx": { + "name": "bank_accounts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_accounts_organization_id_organizations_id_fk": { + "name": "bank_accounts_organization_id_organizations_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_accounts_establishment_id_establishments_id_fk": { + "name": "bank_accounts_establishment_id_establishments_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_accounts_created_by_users_id_fk": { + "name": "bank_accounts_created_by_users_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_accounts_iban_ck": { + "name": "bank_accounts_iban_ck", + "value": "\"bank_accounts\".\"iban_last4\" IS NULL OR \"bank_accounts\".\"iban_last4\" ~ '^[0-9A-Z]{4}$'" + } + }, + "isRLSEnabled": false + }, + "public.bank_imports": { + "name": "bank_imports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_sha256": { + "name": "file_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rows_total": { + "name": "rows_total", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "rows_inserted": { + "name": "rows_inserted", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "period_from": { + "name": "period_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "period_to": { + "name": "period_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_imports_account_idx": { + "name": "bank_imports_account_idx", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_imports_organization_id_organizations_id_fk": { + "name": "bank_imports_organization_id_organizations_id_fk", + "tableFrom": "bank_imports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_imports_account_id_bank_accounts_id_fk": { + "name": "bank_imports_account_id_bank_accounts_id_fk", + "tableFrom": "bank_imports", + "tableTo": "bank_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_imports_created_by_users_id_fk": { + "name": "bank_imports_created_by_users_id_fk", + "tableFrom": "bank_imports", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bank_rules": { + "name": "bank_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'any'" + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_rules_uq": { + "name": "bank_rules_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"keyword\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "direction", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_rules_organization_id_organizations_id_fk": { + "name": "bank_rules_organization_id_organizations_id_fk", + "tableFrom": "bank_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_rules_created_by_users_id_fk": { + "name": "bank_rules_created_by_users_id_fk", + "tableFrom": "bank_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_rules_direction_ck": { + "name": "bank_rules_direction_ck", + "value": "\"bank_rules\".\"direction\" IN ('in', 'out', 'any')" + } + }, + "isRLSEnabled": false + }, + "public.bank_transactions": { + "name": "bank_transactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "import_id": { + "name": "import_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "booking_date": { + "name": "booking_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "value_date": { + "name": "value_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "balance_after": { + "name": "balance_after", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category_source": { + "name": "category_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_tx_row_uq": { + "name": "bank_tx_row_uq", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "bank_tx_invoice_uq": { + "name": "bank_tx_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"bank_transactions\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "bank_tx_period_idx": { + "name": "bank_tx_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "booking_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_transactions_organization_id_organizations_id_fk": { + "name": "bank_transactions_organization_id_organizations_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_transactions_establishment_id_establishments_id_fk": { + "name": "bank_transactions_establishment_id_establishments_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_account_id_bank_accounts_id_fk": { + "name": "bank_transactions_account_id_bank_accounts_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "bank_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_import_id_bank_imports_id_fk": { + "name": "bank_transactions_import_id_bank_imports_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "bank_imports", + "columnsFrom": [ + "import_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "bank_transactions_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_tx_amount_ck": { + "name": "bank_tx_amount_ck", + "value": "\"bank_transactions\".\"amount\" <> 0" + } + }, + "isRLSEnabled": false + }, + "public.booking_button_clicks": { + "name": "booking_button_clicks", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "placement": { + "name": "placement", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "clicks": { + "name": "clicks", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "booking_button_clicks_establishment_id_establishments_id_fk": { + "name": "booking_button_clicks_establishment_id_establishments_id_fk", + "tableFrom": "booking_button_clicks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_button_clicks_organization_id_organizations_id_fk": { + "name": "booking_button_clicks_organization_id_organizations_id_fk", + "tableFrom": "booking_button_clicks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "booking_button_clicks_establishment_id_day_placement_target_pk": { + "name": "booking_button_clicks_establishment_id_day_placement_target_pk", + "columns": [ + "establishment_id", + "day", + "placement", + "target" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "booking_button_clicks_placement_ck": { + "name": "booking_button_clicks_placement_ck", + "value": "\"booking_button_clicks\".\"placement\" IN ('instagram', 'google', 'site')" + }, + "booking_button_clicks_target_ck": { + "name": "booking_button_clicks_target_ck", + "value": "\"booking_button_clicks\".\"target\" IN ('altair', 'thefork', 'opentable', 'zenchef')" + } + }, + "isRLSEnabled": false + }, + "public.booking_channels": { + "name": "booking_channels", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "instagram_target": { + "name": "instagram_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "google_target": { + "name": "google_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "site_target": { + "name": "site_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "thefork_url": { + "name": "thefork_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "opentable_url": { + "name": "opentable_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "zenchef_url": { + "name": "zenchef_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "booking_channels_establishment_id_establishments_id_fk": { + "name": "booking_channels_establishment_id_establishments_id_fk", + "tableFrom": "booking_channels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_channels_organization_id_organizations_id_fk": { + "name": "booking_channels_organization_id_organizations_id_fk", + "tableFrom": "booking_channels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_channels_updated_by_users_id_fk": { + "name": "booking_channels_updated_by_users_id_fk", + "tableFrom": "booking_channels", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "booking_channels_targets_ck": { + "name": "booking_channels_targets_ck", + "value": "\"booking_channels\".\"instagram_target\" IN ('altair', 'thefork', 'opentable', 'zenchef') AND \"booking_channels\".\"google_target\" IN ('altair', 'thefork', 'opentable', 'zenchef') AND \"booking_channels\".\"site_target\" IN ('altair', 'thefork', 'opentable', 'zenchef')" + }, + "booking_channels_urls_ck": { + "name": "booking_channels_urls_ck", + "value": "(\"booking_channels\".\"thefork_url\" IS NULL OR \"booking_channels\".\"thefork_url\" LIKE 'https://%') AND (\"booking_channels\".\"opentable_url\" IS NULL OR \"booking_channels\".\"opentable_url\" LIKE 'https://%') AND (\"booking_channels\".\"zenchef_url\" IS NULL OR \"booking_channels\".\"zenchef_url\" LIKE 'https://%')" + } + }, + "isRLSEnabled": false + }, + "public.business_document_versions": { + "name": "business_document_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version_no": { + "name": "version_no", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "replaced_by": { + "name": "replaced_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "replaced_at": { + "name": "replaced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "business_document_versions_uq": { + "name": "business_document_versions_uq", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version_no", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_document_versions_sha_idx": { + "name": "business_document_versions_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "business_document_versions_organization_id_organizations_id_fk": { + "name": "business_document_versions_organization_id_organizations_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "business_document_versions_document_id_business_documents_id_fk": { + "name": "business_document_versions_document_id_business_documents_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "business_document_versions_replaced_by_users_id_fk": { + "name": "business_document_versions_replaced_by_users_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "users", + "columnsFrom": [ + "replaced_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "business_document_versions_size_ck": { + "name": "business_document_versions_size_ck", + "value": "\"business_document_versions\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.business_documents": { + "name": "business_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "party": { + "name": "party", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference": { + "name": "reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "issued_on": { + "name": "issued_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "expires_on": { + "name": "expires_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reminder_days": { + "name": "reminder_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "annual_cost": { + "name": "annual_cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_version": { + "name": "file_version", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notice_on": { + "name": "notice_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "sensitivity": { + "name": "sensitivity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'normal'" + }, + "duplicate_of_id": { + "name": "duplicate_of_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "replaced_by_id": { + "name": "replaced_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "checklist_code": { + "name": "checklist_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "business_documents_org_idx": { + "name": "business_documents_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_documents_checklist_uq": { + "name": "business_documents_checklist_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checklist_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"business_documents\".\"checklist_code\" IS NOT NULL AND \"business_documents\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_documents_sha_idx": { + "name": "business_documents_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "business_documents_organization_id_organizations_id_fk": { + "name": "business_documents_organization_id_organizations_id_fk", + "tableFrom": "business_documents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "business_documents_establishment_id_establishments_id_fk": { + "name": "business_documents_establishment_id_establishments_id_fk", + "tableFrom": "business_documents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "business_documents_duplicate_of_id_business_documents_id_fk": { + "name": "business_documents_duplicate_of_id_business_documents_id_fk", + "tableFrom": "business_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "duplicate_of_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "business_documents_replaced_by_id_business_documents_id_fk": { + "name": "business_documents_replaced_by_id_business_documents_id_fk", + "tableFrom": "business_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "replaced_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "business_documents_created_by_users_id_fk": { + "name": "business_documents_created_by_users_id_fk", + "tableFrom": "business_documents", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "business_documents_size_ck": { + "name": "business_documents_size_ck", + "value": "\"business_documents\".\"size\" IS NULL OR \"business_documents\".\"size\" <= 5242880" + }, + "business_documents_reminder_ck": { + "name": "business_documents_reminder_ck", + "value": "\"business_documents\".\"reminder_days\" BETWEEN 0 AND 365" + }, + "business_documents_sensitivity_ck": { + "name": "business_documents_sensitivity_ck", + "value": "\"business_documents\".\"sensitivity\" IN ('normal', 'confidentiel', 'restreint')" + }, + "business_documents_notice_ck": { + "name": "business_documents_notice_ck", + "value": "\"business_documents\".\"notice_on\" IS NULL OR \"business_documents\".\"expires_on\" IS NULL OR \"business_documents\".\"notice_on\" <= \"business_documents\".\"expires_on\"" + } + }, + "isRLSEnabled": false + }, + "public.campaign_recipients": { + "name": "campaign_recipients", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "campaign_id": { + "name": "campaign_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unsubscribe_token_hash": { + "name": "unsubscribe_token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unsubscribed_at": { + "name": "unsubscribed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "campaign_recipients_token_uq": { + "name": "campaign_recipients_token_uq", + "columns": [ + { + "expression": "unsubscribe_token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "campaign_recipients_campaign_customer_uq": { + "name": "campaign_recipients_campaign_customer_uq", + "columns": [ + { + "expression": "campaign_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "campaign_recipients_customer_idx": { + "name": "campaign_recipients_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "campaign_recipients_organization_id_organizations_id_fk": { + "name": "campaign_recipients_organization_id_organizations_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "campaign_recipients_campaign_id_marketing_campaigns_id_fk": { + "name": "campaign_recipients_campaign_id_marketing_campaigns_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "marketing_campaigns", + "columnsFrom": [ + "campaign_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "campaign_recipients_customer_id_customers_id_fk": { + "name": "campaign_recipients_customer_id_customers_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidates": { + "name": "candidates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "job_opening_id": { + "name": "job_opening_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'nouveau'" + }, + "stage_changed_at": { + "name": "stage_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "interview_at": { + "name": "interview_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "rating": { + "name": "rating", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refusal_reason": { + "name": "refusal_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_contact_at": { + "name": "last_contact_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidates_org_idx": { + "name": "candidates_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stage", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidates_opening_idx": { + "name": "candidates_opening_idx", + "columns": [ + { + "expression": "job_opening_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidates_organization_id_organizations_id_fk": { + "name": "candidates_organization_id_organizations_id_fk", + "tableFrom": "candidates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidates_establishment_id_establishments_id_fk": { + "name": "candidates_establishment_id_establishments_id_fk", + "tableFrom": "candidates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidates_job_opening_id_job_openings_id_fk": { + "name": "candidates_job_opening_id_job_openings_id_fk", + "tableFrom": "candidates", + "tableTo": "job_openings", + "columnsFrom": [ + "job_opening_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidates_employee_id_employees_id_fk": { + "name": "candidates_employee_id_employees_id_fk", + "tableFrom": "candidates", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidates_created_by_users_id_fk": { + "name": "candidates_created_by_users_id_fk", + "tableFrom": "candidates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "candidates_stage_ck": { + "name": "candidates_stage_ck", + "value": "\"candidates\".\"stage\" IN ('nouveau', 'preselection', 'entretien', 'essai', 'offre', 'embauche', 'refuse', 'desiste')" + }, + "candidates_rating_ck": { + "name": "candidates_rating_ck", + "value": "\"candidates\".\"rating\" IS NULL OR \"candidates\".\"rating\" BETWEEN 1 AND 5" + } + }, + "isRLSEnabled": false + }, + "public.cash_counts": { + "name": "cash_counts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "denominations": { + "name": "denominations", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "counted_total": { + "name": "counted_total", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "counted_by": { + "name": "counted_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counted_at": { + "name": "counted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_counts_est_idx": { + "name": "cash_counts_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_counts_organization_id_organizations_id_fk": { + "name": "cash_counts_organization_id_organizations_id_fk", + "tableFrom": "cash_counts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_counts_establishment_id_establishments_id_fk": { + "name": "cash_counts_establishment_id_establishments_id_fk", + "tableFrom": "cash_counts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_counts_counted_by_users_id_fk": { + "name": "cash_counts_counted_by_users_id_fk", + "tableFrom": "cash_counts", + "tableTo": "users", + "columnsFrom": [ + "counted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cash_counts_cancelled_by_users_id_fk": { + "name": "cash_counts_cancelled_by_users_id_fk", + "tableFrom": "cash_counts", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_counts_kind_ck": { + "name": "cash_counts_kind_ck", + "value": "\"cash_counts\".\"kind\" IN ('fermeture', 'ouverture')" + }, + "cash_counts_amounts_ck": { + "name": "cash_counts_amounts_ck", + "value": "\"cash_counts\".\"counted_total\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.cash_plan_items": { + "name": "cash_plan_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "recurrence": { + "name": "recurrence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'once'" + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_plan_org_idx": { + "name": "cash_plan_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_plan_items_organization_id_organizations_id_fk": { + "name": "cash_plan_items_organization_id_organizations_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_plan_items_establishment_id_establishments_id_fk": { + "name": "cash_plan_items_establishment_id_establishments_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_plan_items_created_by_users_id_fk": { + "name": "cash_plan_items_created_by_users_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_plan_recurrence_ck": { + "name": "cash_plan_recurrence_ck", + "value": "\"cash_plan_items\".\"recurrence\" IN ('once', 'weekly', 'monthly', 'quarterly')" + }, + "cash_plan_amount_ck": { + "name": "cash_plan_amount_ck", + "value": "\"cash_plan_items\".\"amount\" <> 0" + }, + "cash_plan_end_ck": { + "name": "cash_plan_end_ck", + "value": "\"cash_plan_items\".\"end_date\" IS NULL OR \"cash_plan_items\".\"end_date\" >= \"cash_plan_items\".\"start_date\"" + } + }, + "isRLSEnabled": false + }, + "public.cash_withdrawals": { + "name": "cash_withdrawals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recorded_at": { + "name": "recorded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_withdrawals_est_idx": { + "name": "cash_withdrawals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_withdrawals_organization_id_organizations_id_fk": { + "name": "cash_withdrawals_organization_id_organizations_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_withdrawals_establishment_id_establishments_id_fk": { + "name": "cash_withdrawals_establishment_id_establishments_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_withdrawals_recorded_by_users_id_fk": { + "name": "cash_withdrawals_recorded_by_users_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cash_withdrawals_cancelled_by_users_id_fk": { + "name": "cash_withdrawals_cancelled_by_users_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_withdrawals_kind_ck": { + "name": "cash_withdrawals_kind_ck", + "value": "\"cash_withdrawals\".\"kind\" IN ('fournisseur', 'banque', 'pourboires', 'avance', 'autre')" + }, + "cash_withdrawals_amount_ck": { + "name": "cash_withdrawals_amount_ck", + "value": "\"cash_withdrawals\".\"amount\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.catalog_price_changes": { + "name": "catalog_price_changes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "old_price_ht": { + "name": "old_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "new_price_ht": { + "name": "new_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "catalog_price_changes_org_idx": { + "name": "catalog_price_changes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "catalog_price_changes_organization_id_organizations_id_fk": { + "name": "catalog_price_changes_organization_id_organizations_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "catalog_price_changes_item_id_purchase_items_id_fk": { + "name": "catalog_price_changes_item_id_purchase_items_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "catalog_price_changes_supplier_id_suppliers_id_fk": { + "name": "catalog_price_changes_supplier_id_suppliers_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "catalog_price_changes_created_by_users_id_fk": { + "name": "catalog_price_changes_created_by_users_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "catalog_price_changes_source_ck": { + "name": "catalog_price_changes_source_ck", + "value": "\"catalog_price_changes\".\"source\" IN ('import', 'manual')" + }, + "catalog_price_changes_price_ck": { + "name": "catalog_price_changes_price_ck", + "value": "\"catalog_price_changes\".\"new_price_ht\" >= 0 AND (\"catalog_price_changes\".\"old_price_ht\" IS NULL OR \"catalog_price_changes\".\"old_price_ht\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.checklist_run_photos": { + "name": "checklist_run_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_index": { + "name": "item_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_run_photos_uq": { + "name": "checklist_run_photos_uq", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_run_photos_organization_id_organizations_id_fk": { + "name": "checklist_run_photos_organization_id_organizations_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_run_photos_establishment_id_establishments_id_fk": { + "name": "checklist_run_photos_establishment_id_establishments_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_run_photos_run_id_checklist_runs_id_fk": { + "name": "checklist_run_photos_run_id_checklist_runs_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "checklist_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checklist_runs": { + "name": "checklist_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "answers": { + "name": "answers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "yes_count": { + "name": "yes_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "no_count": { + "name": "no_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "na_count": { + "name": "na_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moment": { + "name": "moment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_count": { + "name": "photo_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_runs_est_idx": { + "name": "checklist_runs_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_runs_organization_id_organizations_id_fk": { + "name": "checklist_runs_organization_id_organizations_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_runs_establishment_id_establishments_id_fk": { + "name": "checklist_runs_establishment_id_establishments_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_runs_template_id_checklist_templates_id_fk": { + "name": "checklist_runs_template_id_checklist_templates_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "checklist_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_runs_recorded_by_users_id_fk": { + "name": "checklist_runs_recorded_by_users_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checklist_runs_cancelled_by_users_id_fk": { + "name": "checklist_runs_cancelled_by_users_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checklist_templates": { + "name": "checklist_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "items": { + "name": "items", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "due_by": { + "name": "due_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moment": { + "name": "moment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_items": { + "name": "photo_items", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_templates_est_idx": { + "name": "checklist_templates_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_templates_organization_id_organizations_id_fk": { + "name": "checklist_templates_organization_id_organizations_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_templates_establishment_id_establishments_id_fk": { + "name": "checklist_templates_establishment_id_establishments_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_templates_created_by_users_id_fk": { + "name": "checklist_templates_created_by_users_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "checklist_templates_moment_ck": { + "name": "checklist_templates_moment_ck", + "value": "\"checklist_templates\".\"moment\" IS NULL OR \"checklist_templates\".\"moment\" IN ('ouverture', 'service', 'fermeture')" + } + }, + "isRLSEnabled": false + }, + "public.cleaning_records": { + "name": "cleaning_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_records_est_idx": { + "name": "cleaning_records_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cleaning_records_task_idx": { + "name": "cleaning_records_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_records_organization_id_organizations_id_fk": { + "name": "cleaning_records_organization_id_organizations_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_records_establishment_id_establishments_id_fk": { + "name": "cleaning_records_establishment_id_establishments_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cleaning_records_task_id_cleaning_tasks_id_fk": { + "name": "cleaning_records_task_id_cleaning_tasks_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "cleaning_tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cleaning_records_recorded_by_users_id_fk": { + "name": "cleaning_records_recorded_by_users_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cleaning_records_cancelled_by_users_id_fk": { + "name": "cleaning_records_cancelled_by_users_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cleaning_tasks": { + "name": "cleaning_tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "due_by": { + "name": "due_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_tasks_zone_idx": { + "name": "cleaning_tasks_zone_idx", + "columns": [ + { + "expression": "zone_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_tasks_organization_id_organizations_id_fk": { + "name": "cleaning_tasks_organization_id_organizations_id_fk", + "tableFrom": "cleaning_tasks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_tasks_zone_id_cleaning_zones_id_fk": { + "name": "cleaning_tasks_zone_id_cleaning_zones_id_fk", + "tableFrom": "cleaning_tasks", + "tableTo": "cleaning_zones", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cleaning_tasks_freq_ck": { + "name": "cleaning_tasks_freq_ck", + "value": "\"cleaning_tasks\".\"frequency\" IN ('service', 'jour', 'semaine', 'mois')" + } + }, + "isRLSEnabled": false + }, + "public.cleaning_zones": { + "name": "cleaning_zones", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_zones_est_idx": { + "name": "cleaning_zones_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_zones_organization_id_organizations_id_fk": { + "name": "cleaning_zones_organization_id_organizations_id_fk", + "tableFrom": "cleaning_zones", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_zones_establishment_id_establishments_id_fk": { + "name": "cleaning_zones_establishment_id_establishments_id_fk", + "tableFrom": "cleaning_zones", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.clock_event_photos": { + "name": "clock_event_photos", + "schema": "", + "columns": { + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "clock_event_photos_org_idx": { + "name": "clock_event_photos_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "clock_event_photos_event_id_clock_events_id_fk": { + "name": "clock_event_photos_event_id_clock_events_id_fk", + "tableFrom": "clock_event_photos", + "tableTo": "clock_events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_event_photos_organization_id_organizations_id_fk": { + "name": "clock_event_photos_organization_id_organizations_id_fk", + "tableFrom": "clock_event_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "clock_event_photos_size_ck": { + "name": "clock_event_photos_size_ck", + "value": "octet_length(\"clock_event_photos\".\"data\") <= 307200" + } + }, + "isRLSEnabled": false + }, + "public.clock_events": { + "name": "clock_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ok'" + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geo_distance_m": { + "name": "geo_distance_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "geo_accuracy_m": { + "name": "geo_accuracy_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "clock_events_est_day_idx": { + "name": "clock_events_est_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "clock_events_emp_day_idx": { + "name": "clock_events_emp_day_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "clock_events_organization_id_organizations_id_fk": { + "name": "clock_events_organization_id_organizations_id_fk", + "tableFrom": "clock_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_establishment_id_establishments_id_fk": { + "name": "clock_events_establishment_id_establishments_id_fk", + "tableFrom": "clock_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_employee_id_employees_id_fk": { + "name": "clock_events_employee_id_employees_id_fk", + "tableFrom": "clock_events", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_created_by_users_id_fk": { + "name": "clock_events_created_by_users_id_fk", + "tableFrom": "clock_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "clock_events_reviewed_by_users_id_fk": { + "name": "clock_events_reviewed_by_users_id_fk", + "tableFrom": "clock_events", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "clock_events_kind_ck": { + "name": "clock_events_kind_ck", + "value": "\"clock_events\".\"kind\" IN ('in', 'break_start', 'break_end', 'out')" + }, + "clock_events_source_ck": { + "name": "clock_events_source_ck", + "value": "\"clock_events\".\"source\" IN ('borne', 'manuel', 'hors_ligne', 'qr', 'telephone')" + }, + "clock_events_status_ck": { + "name": "clock_events_status_ck", + "value": "\"clock_events\".\"status\" IN ('ok', 'a_valider', 'annule')" + } + }, + "isRLSEnabled": false + }, + "public.clock_pins": { + "name": "clock_pins", + "schema": "", + "columns": { + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pin_hash": { + "name": "pin_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "failed_attempts": { + "name": "failed_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "clock_pins_employee_id_employees_id_fk": { + "name": "clock_pins_employee_id_employees_id_fk", + "tableFrom": "clock_pins", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_pins_organization_id_organizations_id_fk": { + "name": "clock_pins_organization_id_organizations_id_fk", + "tableFrom": "clock_pins", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_pins_updated_by_users_id_fk": { + "name": "clock_pins_updated_by_users_id_fk", + "tableFrom": "clock_pins", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.clock_qr_settings": { + "name": "clock_qr_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone_enabled": { + "name": "phone_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "geo_lat": { + "name": "geo_lat", + "type": "numeric(9, 6)", + "primaryKey": false, + "notNull": false + }, + "geo_lng": { + "name": "geo_lng", + "type": "numeric(9, 6)", + "primaryKey": false, + "notNull": false + }, + "geo_radius_m": { + "name": "geo_radius_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "auto_apply": { + "name": "auto_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_apply_by": { + "name": "auto_apply_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "auto_applied_day": { + "name": "auto_applied_day", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "pin_by_employee": { + "name": "pin_by_employee", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "clock_qr_settings_establishment_id_establishments_id_fk": { + "name": "clock_qr_settings_establishment_id_establishments_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_qr_settings_organization_id_organizations_id_fk": { + "name": "clock_qr_settings_organization_id_organizations_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_qr_settings_auto_apply_by_users_id_fk": { + "name": "clock_qr_settings_auto_apply_by_users_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "users", + "columnsFrom": [ + "auto_apply_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "clock_qr_settings_updated_by_users_id_fk": { + "name": "clock_qr_settings_updated_by_users_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.companies": { + "name": "companies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "legal_name": { + "name": "legal_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "legal_form": { + "name": "legal_form", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siren": { + "name": "siren", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_number": { + "name": "vat_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_holding": { + "name": "is_holding", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hr_settings": { + "name": "hr_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "calendar_settings": { + "name": "calendar_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tax_settings": { + "name": "tax_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "companies_org_idx": { + "name": "companies_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "companies_organization_id_organizations_id_fk": { + "name": "companies_organization_id_organizations_id_fk", + "tableFrom": "companies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "companies_siren_ck": { + "name": "companies_siren_ck", + "value": "\"companies\".\"siren\" IS NULL OR \"companies\".\"siren\" ~ '^[0-9]{9}$'" + } + }, + "isRLSEnabled": false + }, + "public.company_holdings": { + "name": "company_holdings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "parent_company_id": { + "name": "parent_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "child_company_id": { + "name": "child_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "ownership_pct": { + "name": "ownership_pct", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": true + }, + "since": { + "name": "since", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "holdings_pair_uq": { + "name": "holdings_pair_uq", + "columns": [ + { + "expression": "parent_company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "child_company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "company_holdings_organization_id_organizations_id_fk": { + "name": "company_holdings_organization_id_organizations_id_fk", + "tableFrom": "company_holdings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "company_holdings_parent_company_id_companies_id_fk": { + "name": "company_holdings_parent_company_id_companies_id_fk", + "tableFrom": "company_holdings", + "tableTo": "companies", + "columnsFrom": [ + "parent_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "company_holdings_child_company_id_companies_id_fk": { + "name": "company_holdings_child_company_id_companies_id_fk", + "tableFrom": "company_holdings", + "tableTo": "companies", + "columnsFrom": [ + "child_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "holdings_pct_ck": { + "name": "holdings_pct_ck", + "value": "\"company_holdings\".\"ownership_pct\" > 0 AND \"company_holdings\".\"ownership_pct\" <= 100" + }, + "holdings_self_ck": { + "name": "holdings_self_ck", + "value": "\"company_holdings\".\"parent_company_id\" <> \"company_holdings\".\"child_company_id\"" + } + }, + "isRLSEnabled": false + }, + "public.compliance_items": { + "name": "compliance_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "obligation_id": { + "name": "obligation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "verified_by": { + "name": "verified_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "compliance_items_uq": { + "name": "compliance_items_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "obligation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "compliance_items_document_idx": { + "name": "compliance_items_document_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "compliance_items_organization_id_organizations_id_fk": { + "name": "compliance_items_organization_id_organizations_id_fk", + "tableFrom": "compliance_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "compliance_items_establishment_id_establishments_id_fk": { + "name": "compliance_items_establishment_id_establishments_id_fk", + "tableFrom": "compliance_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "compliance_items_obligation_id_regulatory_obligations_id_fk": { + "name": "compliance_items_obligation_id_regulatory_obligations_id_fk", + "tableFrom": "compliance_items", + "tableTo": "regulatory_obligations", + "columnsFrom": [ + "obligation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "compliance_items_document_id_business_documents_id_fk": { + "name": "compliance_items_document_id_business_documents_id_fk", + "tableFrom": "compliance_items", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "compliance_items_verified_by_users_id_fk": { + "name": "compliance_items_verified_by_users_id_fk", + "tableFrom": "compliance_items", + "tableTo": "users", + "columnsFrom": [ + "verified_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "compliance_items_status_ck": { + "name": "compliance_items_status_ck", + "value": "\"compliance_items\".\"status\" IN ('verifie', 'non_applicable_declare', 'en_cours')" + }, + "compliance_items_in_progress_ck": { + "name": "compliance_items_in_progress_ck", + "value": "\"compliance_items\".\"status\" <> 'en_cours' OR \"compliance_items\".\"note\" IS NOT NULL" + }, + "compliance_items_proof_ck": { + "name": "compliance_items_proof_ck", + "value": "(\"compliance_items\".\"status\" <> 'verifie' OR \"compliance_items\".\"document_id\" IS NOT NULL) AND (\"compliance_items\".\"status\" <> 'non_applicable_declare' OR \"compliance_items\".\"reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.context_observations": { + "name": "context_observations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "series": { + "name": "series", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "numeric(12, 3)", + "primaryKey": false, + "notNull": false + }, + "extra": { + "name": "extra", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "context_observations_uq": { + "name": "context_observations_uq", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "series", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "context_observations_source_ck": { + "name": "context_observations_source_ck", + "value": "\"context_observations\".\"source\" IN ('meteo_france', 'insee')" + } + }, + "isRLSEnabled": false + }, + "public.context_sources": { + "name": "context_sources", + "schema": "", + "columns": { + "source": { + "name": "source", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "last_attempt_at": { + "name": "last_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rows": { + "name": "rows", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_members": { + "name": "conversation_members", + "schema": "", + "columns": { + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_read_at": { + "name": "last_read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "notified_at": { + "name": "notified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversation_members_user_idx": { + "name": "conversation_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversation_members_conversation_id_conversations_id_fk": { + "name": "conversation_members_conversation_id_conversations_id_fk", + "tableFrom": "conversation_members", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversation_members_user_id_users_id_fk": { + "name": "conversation_members_user_id_users_id_fk", + "tableFrom": "conversation_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversation_members_conversation_id_user_id_pk": { + "name": "conversation_members_conversation_id_user_id_pk", + "columns": [ + "conversation_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_group": { + "name": "is_group", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversations_org_idx": { + "name": "conversations_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversations_organization_id_organizations_id_fk": { + "name": "conversations_organization_id_organizations_id_fk", + "tableFrom": "conversations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversations_created_by_users_id_fk": { + "name": "conversations_created_by_users_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credit_request_lines": { + "name": "credit_request_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_request_lines_req_idx": { + "name": "credit_request_lines_req_idx", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_request_lines_organization_id_organizations_id_fk": { + "name": "credit_request_lines_organization_id_organizations_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_lines_request_id_credit_requests_id_fk": { + "name": "credit_request_lines_request_id_credit_requests_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "credit_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_lines_item_id_purchase_items_id_fk": { + "name": "credit_request_lines_item_id_purchase_items_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_request_lines_amount_ck": { + "name": "credit_request_lines_amount_ck", + "value": "\"credit_request_lines\".\"quantity\" > 0 AND \"credit_request_lines\".\"unit_price_ht\" > 0 AND \"credit_request_lines\".\"amount_ht\" > 0" + }, + "credit_request_lines_reason_ck": { + "name": "credit_request_lines_reason_ck", + "value": "\"credit_request_lines\".\"reason\" IN ('manquant', 'abime', 'non_conforme', 'erreur_prix', 'erreur_quantite', 'dlc_courte', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.credit_request_photos": { + "name": "credit_request_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_request_photos_req_idx": { + "name": "credit_request_photos_req_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_request_photos_organization_id_organizations_id_fk": { + "name": "credit_request_photos_organization_id_organizations_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_photos_request_id_credit_requests_id_fk": { + "name": "credit_request_photos_request_id_credit_requests_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "credit_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_photos_created_by_users_id_fk": { + "name": "credit_request_photos_created_by_users_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_request_photos_size_ck": { + "name": "credit_request_photos_size_ck", + "value": "\"credit_request_photos\".\"size\" <= 5242880" + }, + "credit_request_photos_mime_ck": { + "name": "credit_request_photos_mime_ck", + "value": "\"credit_request_photos\".\"mime\" IN ('image/jpeg', 'image/png', 'image/webp')" + } + }, + "isRLSEnabled": false + }, + "public.credit_requests": { + "name": "credit_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "request_date": { + "name": "request_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "credited_ht": { + "name": "credited_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "close_reason": { + "name": "close_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_requests_est_idx": { + "name": "credit_requests_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_requests_number_uq": { + "name": "credit_requests_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_requests_organization_id_organizations_id_fk": { + "name": "credit_requests_organization_id_organizations_id_fk", + "tableFrom": "credit_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_requests_establishment_id_establishments_id_fk": { + "name": "credit_requests_establishment_id_establishments_id_fk", + "tableFrom": "credit_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_supplier_id_suppliers_id_fk": { + "name": "credit_requests_supplier_id_suppliers_id_fk", + "tableFrom": "credit_requests", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_purchase_order_id_purchase_orders_id_fk": { + "name": "credit_requests_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "credit_requests", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_invoice_id_purchase_invoices_id_fk": { + "name": "credit_requests_invoice_id_purchase_invoices_id_fk", + "tableFrom": "credit_requests", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_closed_by_users_id_fk": { + "name": "credit_requests_closed_by_users_id_fk", + "tableFrom": "credit_requests", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "credit_requests_created_by_users_id_fk": { + "name": "credit_requests_created_by_users_id_fk", + "tableFrom": "credit_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_requests_status_ck": { + "name": "credit_requests_status_ck", + "value": "\"credit_requests\".\"status\" IN ('open', 'sent', 'accepted', 'refused', 'cancelled')" + }, + "credit_requests_total_ck": { + "name": "credit_requests_total_ck", + "value": "\"credit_requests\".\"total_ht\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.customers": { + "name": "customers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergies": { + "name": "allergies", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preferences": { + "name": "preferences", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birthday": { + "name": "birthday", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "vip": { + "name": "vip", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "consent_email": { + "name": "consent_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "consent_sms": { + "name": "consent_sms", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "consent_at": { + "name": "consent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consent_source": { + "name": "consent_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "anonymized_at": { + "name": "anonymized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "customers_org_idx": { + "name": "customers_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "customers_phone_idx": { + "name": "customers_phone_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "phone", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "customers_email_idx": { + "name": "customers_email_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "customers_organization_id_organizations_id_fk": { + "name": "customers_organization_id_organizations_id_fk", + "tableFrom": "customers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.dashboard_layouts": { + "name": "dashboard_layouts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blocks": { + "name": "blocks", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "dashboard_layouts_user_id_users_id_fk": { + "name": "dashboard_layouts_user_id_users_id_fk", + "tableFrom": "dashboard_layouts", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dashboard_layouts_organization_id_organizations_id_fk": { + "name": "dashboard_layouts_organization_id_organizations_id_fk", + "tableFrom": "dashboard_layouts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "dashboard_layouts_user_id_organization_id_pk": { + "name": "dashboard_layouts_user_id_organization_id_pk", + "columns": [ + "user_id", + "organization_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.delivery_note_scans": { + "name": "delivery_note_scans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "delivery_note_scans_order_idx": { + "name": "delivery_note_scans_order_idx", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "delivery_note_scans_org_idx": { + "name": "delivery_note_scans_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "delivery_note_scans_organization_id_organizations_id_fk": { + "name": "delivery_note_scans_organization_id_organizations_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_establishment_id_establishments_id_fk": { + "name": "delivery_note_scans_establishment_id_establishments_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_order_id_purchase_orders_id_fk": { + "name": "delivery_note_scans_order_id_purchase_orders_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "purchase_orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_created_by_users_id_fk": { + "name": "delivery_note_scans_created_by_users_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "delivery_note_scans_status_ck": { + "name": "delivery_note_scans_status_ck", + "value": "\"delivery_note_scans\".\"status\" IN ('lu', 'echec')" + }, + "delivery_note_scans_size_ck": { + "name": "delivery_note_scans_size_ck", + "value": "\"delivery_note_scans\".\"size\" > 0 AND \"delivery_note_scans\".\"size\" <= 10485760" + } + }, + "isRLSEnabled": false + }, + "public.dish_quality_checks": { + "name": "dish_quality_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "checked_by": { + "name": "checked_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "weight_g": { + "name": "weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "target_weight_g": { + "name": "target_weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tolerance_pct": { + "name": "tolerance_pct", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "plating_ok": { + "name": "plating_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "temperature_ok": { + "name": "temperature_ok", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "dish_quality_checks_est_idx": { + "name": "dish_quality_checks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "dish_quality_checks_recipe_idx": { + "name": "dish_quality_checks_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "dish_quality_checks_organization_id_organizations_id_fk": { + "name": "dish_quality_checks_organization_id_organizations_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_establishment_id_establishments_id_fk": { + "name": "dish_quality_checks_establishment_id_establishments_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_recipe_id_recipes_id_fk": { + "name": "dish_quality_checks_recipe_id_recipes_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_checked_by_users_id_fk": { + "name": "dish_quality_checks_checked_by_users_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "users", + "columnsFrom": [ + "checked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "dish_quality_checks_weight_ck": { + "name": "dish_quality_checks_weight_ck", + "value": "(\"dish_quality_checks\".\"weight_g\" IS NULL OR \"dish_quality_checks\".\"weight_g\" BETWEEN 1 AND 20000) AND (\"dish_quality_checks\".\"target_weight_g\" IS NULL OR \"dish_quality_checks\".\"target_weight_g\" BETWEEN 1 AND 20000)" + } + }, + "isRLSEnabled": false + }, + "public.duerp_risks": { + "name": "duerp_risks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "unit_id": { + "name": "unit_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "hazard": { + "name": "hazard", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "situation": { + "name": "situation", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "existing_measures": { + "name": "existing_measures", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gravity": { + "name": "gravity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "probability": { + "name": "probability", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "planned_action": { + "name": "planned_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action_owner": { + "name": "action_owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action_due": { + "name": "action_due", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "action_status": { + "name": "action_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_template": { + "name": "from_template", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_risks_unit_idx": { + "name": "duerp_risks_unit_idx", + "columns": [ + { + "expression": "unit_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_risks_est_idx": { + "name": "duerp_risks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_risks_organization_id_organizations_id_fk": { + "name": "duerp_risks_organization_id_organizations_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_risks_establishment_id_establishments_id_fk": { + "name": "duerp_risks_establishment_id_establishments_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_risks_unit_id_duerp_units_id_fk": { + "name": "duerp_risks_unit_id_duerp_units_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "duerp_units", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "duerp_risks_scale_ck": { + "name": "duerp_risks_scale_ck", + "value": "(\"duerp_risks\".\"gravity\" IS NULL OR \"duerp_risks\".\"gravity\" BETWEEN 1 AND 4) AND (\"duerp_risks\".\"probability\" IS NULL OR \"duerp_risks\".\"probability\" BETWEEN 1 AND 4)" + }, + "duerp_risks_action_ck": { + "name": "duerp_risks_action_ck", + "value": "\"duerp_risks\".\"action_status\" IS NULL OR (\"duerp_risks\".\"action_status\" IN ('a_faire', 'en_cours', 'faite') AND \"duerp_risks\".\"planned_action\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.duerp_units": { + "name": "duerp_units", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headcount": { + "name": "headcount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_units_est_idx": { + "name": "duerp_units_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_units_name_uq": { + "name": "duerp_units_name_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"duerp_units\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_units_organization_id_organizations_id_fk": { + "name": "duerp_units_organization_id_organizations_id_fk", + "tableFrom": "duerp_units", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_units_establishment_id_establishments_id_fk": { + "name": "duerp_units_establishment_id_establishments_id_fk", + "tableFrom": "duerp_units", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "duerp_units_headcount_ck": { + "name": "duerp_units_headcount_ck", + "value": "\"duerp_units\".\"headcount\" IS NULL OR \"duerp_units\".\"headcount\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.duerp_versions": { + "name": "duerp_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version_no": { + "name": "version_no", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "snapshot": { + "name": "snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "published_by_name": { + "name": "published_by_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_versions_no_uq": { + "name": "duerp_versions_no_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version_no", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_versions_org_idx": { + "name": "duerp_versions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_versions_organization_id_organizations_id_fk": { + "name": "duerp_versions_organization_id_organizations_id_fk", + "tableFrom": "duerp_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_versions_establishment_id_establishments_id_fk": { + "name": "duerp_versions_establishment_id_establishments_id_fk", + "tableFrom": "duerp_versions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_attachments": { + "name": "email_attachments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'application/pdf'" + }, + "content": { + "name": "content", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_attachments_org_idx": { + "name": "email_attachments_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_attachments_organization_id_organizations_id_fk": { + "name": "email_attachments_organization_id_organizations_id_fk", + "tableFrom": "email_attachments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "email_attachments_mime_ck": { + "name": "email_attachments_mime_ck", + "value": "\"email_attachments\".\"mime\" = 'application/pdf'" + }, + "email_attachments_size_ck": { + "name": "email_attachments_size_ck", + "value": "\"email_attachments\".\"size\" >= 0 AND \"email_attachments\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.email_outbox": { + "name": "email_outbox", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "signature_request_id": { + "name": "signature_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "attachment_id": { + "name": "attachment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "list_unsubscribe": { + "name": "list_unsubscribe", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_outbox_pending_idx": { + "name": "email_outbox_pending_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_outbox_organization_id_organizations_id_fk": { + "name": "email_outbox_organization_id_organizations_id_fk", + "tableFrom": "email_outbox", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "email_outbox_attachment_id_email_attachments_id_fk": { + "name": "email_outbox_attachment_id_email_attachments_id_fk", + "tableFrom": "email_outbox", + "tableTo": "email_attachments", + "columnsFrom": [ + "attachment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "email_outbox_status_ck": { + "name": "email_outbox_status_ck", + "value": "\"email_outbox\".\"status\" IN ('en_attente', 'envoye', 'echec')" + } + }, + "isRLSEnabled": false + }, + "public.employee_contracts": { + "name": "employee_contracts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "amends_id": { + "name": "amends_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "trial_end_date": { + "name": "trial_end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "step": { + "name": "step", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'employe'" + }, + "weekly_hours": { + "name": "weekly_hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "hourly_rate_gross": { + "name": "hourly_rate_gross", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": false + }, + "monthly_gross": { + "name": "monthly_gross", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "cdd_reason": { + "name": "cdd_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "replaced_person": { + "name": "replaced_person", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "meal_benefit": { + "name": "meal_benefit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "end_reason": { + "name": "end_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hire_time": { + "name": "hire_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_status": { + "name": "dpae_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_declared_on": { + "name": "dpae_declared_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "dpae_reference": { + "name": "dpae_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_note": { + "name": "dpae_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_contracts_emp_idx": { + "name": "employee_contracts_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "start_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_contracts_organization_id_organizations_id_fk": { + "name": "employee_contracts_organization_id_organizations_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_contracts_employee_id_employees_id_fk": { + "name": "employee_contracts_employee_id_employees_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_contracts_amends_id_employee_contracts_id_fk": { + "name": "employee_contracts_amends_id_employee_contracts_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "employee_contracts", + "columnsFrom": [ + "amends_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "employee_contracts_created_by_users_id_fk": { + "name": "employee_contracts_created_by_users_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_contracts_dpae_ck": { + "name": "employee_contracts_dpae_ck", + "value": "(\"employee_contracts\".\"dpae_status\" IS NULL OR \"employee_contracts\".\"dpae_status\" IN ('enregistree', 'non_concernee_declaree')) AND (\"employee_contracts\".\"dpae_status\" IS DISTINCT FROM 'enregistree' OR \"employee_contracts\".\"dpae_declared_on\" IS NOT NULL) AND (\"employee_contracts\".\"dpae_status\" IS DISTINCT FROM 'non_concernee_declaree' OR \"employee_contracts\".\"dpae_note\" IS NOT NULL)" + }, + "employee_contracts_kind_ck": { + "name": "employee_contracts_kind_ck", + "value": "\"employee_contracts\".\"kind\" IN ('cdi', 'cdd', 'extra', 'saisonnier', 'apprentissage', 'professionnalisation', 'stage', 'dirigeant')" + }, + "employee_contracts_dates_ck": { + "name": "employee_contracts_dates_ck", + "value": "\"employee_contracts\".\"end_date\" IS NULL OR \"employee_contracts\".\"end_date\" >= \"employee_contracts\".\"start_date\"" + }, + "employee_contracts_category_ck": { + "name": "employee_contracts_category_ck", + "value": "\"employee_contracts\".\"category\" IN ('employe', 'agent_maitrise', 'cadre')" + }, + "employee_contracts_hours_ck": { + "name": "employee_contracts_hours_ck", + "value": "\"employee_contracts\".\"weekly_hours\" IS NULL OR (\"employee_contracts\".\"weekly_hours\" > 0 AND \"employee_contracts\".\"weekly_hours\" <= 48)" + }, + "employee_contracts_rate_ck": { + "name": "employee_contracts_rate_ck", + "value": "(\"employee_contracts\".\"hourly_rate_gross\" IS NULL OR \"employee_contracts\".\"hourly_rate_gross\" >= 0) AND (\"employee_contracts\".\"monthly_gross\" IS NULL OR \"employee_contracts\".\"monthly_gross\" >= 0)" + }, + "employee_contracts_hire_time_ck": { + "name": "employee_contracts_hire_time_ck", + "value": "\"employee_contracts\".\"hire_time\" IS NULL OR \"employee_contracts\".\"hire_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "employee_contracts_meal_ck": { + "name": "employee_contracts_meal_ck", + "value": "\"employee_contracts\".\"meal_benefit\" IS NULL OR \"employee_contracts\".\"meal_benefit\" IN ('nature', 'indemnite', 'aucun')" + } + }, + "isRLSEnabled": false + }, + "public.employee_files": { + "name": "employee_files", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duplicate_of_id": { + "name": "duplicate_of_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "visible_to_employee": { + "name": "visible_to_employee", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_files_emp_idx": { + "name": "employee_files_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "employee_files_sha_idx": { + "name": "employee_files_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_files_organization_id_organizations_id_fk": { + "name": "employee_files_organization_id_organizations_id_fk", + "tableFrom": "employee_files", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_files_employee_id_employees_id_fk": { + "name": "employee_files_employee_id_employees_id_fk", + "tableFrom": "employee_files", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_files_duplicate_of_id_employee_files_id_fk": { + "name": "employee_files_duplicate_of_id_employee_files_id_fk", + "tableFrom": "employee_files", + "tableTo": "employee_files", + "columnsFrom": [ + "duplicate_of_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_files_uploaded_by_users_id_fk": { + "name": "employee_files_uploaded_by_users_id_fk", + "tableFrom": "employee_files", + "tableTo": "users", + "columnsFrom": [ + "uploaded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_files_size_ck": { + "name": "employee_files_size_ck", + "value": "\"employee_files\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.employee_reviews": { + "name": "employee_reviews", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'prevu'" + }, + "scheduled_on": { + "name": "scheduled_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "done_on": { + "name": "done_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reviewer_id": { + "name": "reviewer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "objectives": { + "name": "objectives", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "training_wishes": { + "name": "training_wishes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_comment": { + "name": "employee_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_reviews_emp_idx": { + "name": "employee_reviews_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_reviews_organization_id_organizations_id_fk": { + "name": "employee_reviews_organization_id_organizations_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_reviews_employee_id_employees_id_fk": { + "name": "employee_reviews_employee_id_employees_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_reviews_reviewer_id_users_id_fk": { + "name": "employee_reviews_reviewer_id_users_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "users", + "columnsFrom": [ + "reviewer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_reviews_file_id_employee_files_id_fk": { + "name": "employee_reviews_file_id_employee_files_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_reviews_created_by_users_id_fk": { + "name": "employee_reviews_created_by_users_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_reviews_kind_ck": { + "name": "employee_reviews_kind_ck", + "value": "\"employee_reviews\".\"kind\" IN ('annuel', 'professionnel', 'etat_des_lieux', 'fin_essai')" + }, + "employee_reviews_status_ck": { + "name": "employee_reviews_status_ck", + "value": "\"employee_reviews\".\"status\" IN ('prevu', 'realise', 'annule')" + }, + "employee_reviews_done_ck": { + "name": "employee_reviews_done_ck", + "value": "\"employee_reviews\".\"status\" <> 'realise' OR \"employee_reviews\".\"done_on\" IS NOT NULL" + }, + "employee_reviews_planned_ck": { + "name": "employee_reviews_planned_ck", + "value": "\"employee_reviews\".\"status\" <> 'prevu' OR \"employee_reviews\".\"scheduled_on\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.employee_skills": { + "name": "employee_skills", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "skill_id": { + "name": "skill_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "assessed_on": { + "name": "assessed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "assessed_by": { + "name": "assessed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "employee_skills_organization_id_organizations_id_fk": { + "name": "employee_skills_organization_id_organizations_id_fk", + "tableFrom": "employee_skills", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_employee_id_employees_id_fk": { + "name": "employee_skills_employee_id_employees_id_fk", + "tableFrom": "employee_skills", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_skill_id_skills_id_fk": { + "name": "employee_skills_skill_id_skills_id_fk", + "tableFrom": "employee_skills", + "tableTo": "skills", + "columnsFrom": [ + "skill_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_assessed_by_users_id_fk": { + "name": "employee_skills_assessed_by_users_id_fk", + "tableFrom": "employee_skills", + "tableTo": "users", + "columnsFrom": [ + "assessed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "employee_skills_employee_id_skill_id_pk": { + "name": "employee_skills_employee_id_skill_id_pk", + "columns": [ + "employee_id", + "skill_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_skills_level_ck": { + "name": "employee_skills_level_ck", + "value": "\"employee_skills\".\"level\" BETWEEN 0 AND 4" + } + }, + "isRLSEnabled": false + }, + "public.employee_trainings": { + "name": "employee_trainings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'realisee'" + }, + "planned_on": { + "name": "planned_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "done_on": { + "name": "done_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "hours": { + "name": "hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "funded_by": { + "name": "funded_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_trainings_emp_idx": { + "name": "employee_trainings_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_trainings_organization_id_organizations_id_fk": { + "name": "employee_trainings_organization_id_organizations_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_trainings_employee_id_employees_id_fk": { + "name": "employee_trainings_employee_id_employees_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_trainings_file_id_employee_files_id_fk": { + "name": "employee_trainings_file_id_employee_files_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_trainings_created_by_users_id_fk": { + "name": "employee_trainings_created_by_users_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_trainings_status_ck": { + "name": "employee_trainings_status_ck", + "value": "\"employee_trainings\".\"status\" IN ('prevue', 'realisee', 'annulee')" + }, + "employee_trainings_done_ck": { + "name": "employee_trainings_done_ck", + "value": "\"employee_trainings\".\"status\" <> 'realisee' OR \"employee_trainings\".\"done_on\" IS NOT NULL" + }, + "employee_trainings_valid_ck": { + "name": "employee_trainings_valid_ck", + "value": "\"employee_trainings\".\"valid_until\" IS NULL OR \"employee_trainings\".\"done_on\" IS NULL OR \"employee_trainings\".\"valid_until\" >= \"employee_trainings\".\"done_on\"" + }, + "employee_trainings_amounts_ck": { + "name": "employee_trainings_amounts_ck", + "value": "(\"employee_trainings\".\"hours\" IS NULL OR \"employee_trainings\".\"hours\" > 0) AND (\"employee_trainings\".\"cost\" IS NULL OR \"employee_trainings\".\"cost\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.employees": { + "name": "employees", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "registry_number": { + "name": "registry_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "birth_name": { + "name": "birth_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "birth_date": { + "name": "birth_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "birth_place": { + "name": "birth_place", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "nationality": { + "name": "nationality", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birth_country": { + "name": "birth_country", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birth_department": { + "name": "birth_department", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family_situation": { + "name": "family_situation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_type": { + "name": "work_permit_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_number": { + "name": "work_permit_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_expiry": { + "name": "work_permit_expiry", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "social_security_enc": { + "name": "social_security_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban_enc": { + "name": "iban_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bic": { + "name": "bic", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "account_holder": { + "name": "account_holder", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emergency_contact": { + "name": "emergency_contact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emergency_phone": { + "name": "emergency_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disability": { + "name": "disability", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "medical_visit_date": { + "name": "medical_visit_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "medical_visit_next_due": { + "name": "medical_visit_next_due", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reinforced_medical": { + "name": "reinforced_medical", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "planning_hidden": { + "name": "planning_hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employees_org_idx": { + "name": "employees_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "employees_registry_uq": { + "name": "employees_registry_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "registry_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employees_organization_id_organizations_id_fk": { + "name": "employees_organization_id_organizations_id_fk", + "tableFrom": "employees", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employees_establishment_id_establishments_id_fk": { + "name": "employees_establishment_id_establishments_id_fk", + "tableFrom": "employees", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "employees_user_id_users_id_fk": { + "name": "employees_user_id_users_id_fk", + "tableFrom": "employees", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employees_gender_ck": { + "name": "employees_gender_ck", + "value": "\"employees\".\"gender\" IS NULL OR \"employees\".\"gender\" IN ('F', 'M', 'X')" + }, + "employees_birth_department_ck": { + "name": "employees_birth_department_ck", + "value": "\"employees\".\"birth_department\" IS NULL OR \"employees\".\"birth_department\" ~ '^([0-9]{2}|2[AB]|9[78][0-9])$'" + } + }, + "isRLSEnabled": false + }, + "public.employer_signatures": { + "name": "employer_signatures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "png": { + "name": "png", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "signer_name": { + "name": "signer_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employer_signatures_company_uq": { + "name": "employer_signatures_company_uq", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employer_signatures_organization_id_organizations_id_fk": { + "name": "employer_signatures_organization_id_organizations_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employer_signatures_company_id_companies_id_fk": { + "name": "employer_signatures_company_id_companies_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employer_signatures_updated_by_users_id_fk": { + "name": "employer_signatures_updated_by_users_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employer_signatures_size_ck": { + "name": "employer_signatures_size_ck", + "value": "octet_length(\"employer_signatures\".\"png\") <= 102400" + } + }, + "isRLSEnabled": false + }, + "public.equipment": { + "name": "equipment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "temp_tracked": { + "name": "temp_tracked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "temp_min": { + "name": "temp_min", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "readings_per_day": { + "name": "readings_per_day", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "serial_number": { + "name": "serial_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installed_on": { + "name": "installed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "warranty_until": { + "name": "warranty_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "service_partner": { + "name": "service_partner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_phone": { + "name": "service_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_every_months": { + "name": "service_every_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "purchase_price_ht": { + "name": "purchase_price_ht", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "equipment_est_idx": { + "name": "equipment_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "equipment_organization_id_organizations_id_fk": { + "name": "equipment_organization_id_organizations_id_fk", + "tableFrom": "equipment", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "equipment_establishment_id_establishments_id_fk": { + "name": "equipment_establishment_id_establishments_id_fk", + "tableFrom": "equipment", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "equipment_created_by_users_id_fk": { + "name": "equipment_created_by_users_id_fk", + "tableFrom": "equipment", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "equipment_range_ck": { + "name": "equipment_range_ck", + "value": "\"equipment\".\"temp_min\" IS NULL OR \"equipment\".\"temp_max\" IS NULL OR \"equipment\".\"temp_min\" <= \"equipment\".\"temp_max\"" + }, + "equipment_rpd_ck": { + "name": "equipment_rpd_ck", + "value": "\"equipment\".\"readings_per_day\" BETWEEN 1 AND 4" + }, + "equipment_price_ck": { + "name": "equipment_price_ck", + "value": "\"equipment\".\"purchase_price_ht\" IS NULL OR \"equipment\".\"purchase_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.establishment_fee_rules": { + "name": "establishment_fee_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rate_pct": { + "name": "rate_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "basis": { + "name": "basis", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ttc'" + }, + "match_channel": { + "name": "match_channel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "match_payment": { + "name": "match_payment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fixed_monthly_ht": { + "name": "fixed_monthly_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "valid_from": { + "name": "valid_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "valid_to": { + "name": "valid_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishment_fee_rules_est_idx": { + "name": "establishment_fee_rules_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishment_fee_rules_organization_id_organizations_id_fk": { + "name": "establishment_fee_rules_organization_id_organizations_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_fee_rules_establishment_id_establishments_id_fk": { + "name": "establishment_fee_rules_establishment_id_establishments_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_fee_rules_created_by_users_id_fk": { + "name": "establishment_fee_rules_created_by_users_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "establishment_fee_rules_kind_ck": { + "name": "establishment_fee_rules_kind_ck", + "value": "\"establishment_fee_rules\".\"kind\" IN ('plateforme', 'franchise')" + }, + "establishment_fee_rules_basis_ck": { + "name": "establishment_fee_rules_basis_ck", + "value": "\"establishment_fee_rules\".\"basis\" IN ('ttc', 'ht')" + }, + "establishment_fee_rules_rate_ck": { + "name": "establishment_fee_rules_rate_ck", + "value": "\"establishment_fee_rules\".\"rate_pct\" >= 0 AND \"establishment_fee_rules\".\"rate_pct\" < 100" + }, + "establishment_fee_rules_fixed_ck": { + "name": "establishment_fee_rules_fixed_ck", + "value": "\"establishment_fee_rules\".\"fixed_monthly_ht\" IS NULL OR \"establishment_fee_rules\".\"fixed_monthly_ht\" >= 0" + }, + "establishment_fee_rules_channel_ck": { + "name": "establishment_fee_rules_channel_ck", + "value": "\"establishment_fee_rules\".\"match_channel\" IS NULL OR \"establishment_fee_rules\".\"match_channel\" IN ('sur_place', 'emporter', 'livraison', 'click_collect', 'autre')" + }, + "establishment_fee_rules_dates_ck": { + "name": "establishment_fee_rules_dates_ck", + "value": "\"establishment_fee_rules\".\"valid_to\" IS NULL OR \"establishment_fee_rules\".\"valid_to\" >= \"establishment_fee_rules\".\"valid_from\"" + }, + "establishment_fee_rules_label_ck": { + "name": "establishment_fee_rules_label_ck", + "value": "char_length(\"establishment_fee_rules\".\"label\") BETWEEN 1 AND 80" + } + }, + "isRLSEnabled": false + }, + "public.establishment_regulatory_profiles": { + "name": "establishment_regulatory_profiles", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "on_site": { + "name": "on_site", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "takeaway": { + "name": "takeaway", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "delivery": { + "name": "delivery", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "seating_capacity": { + "name": "seating_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "erp_category": { + "name": "erp_category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erp_type": { + "name": "erp_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headcount_declared": { + "name": "headcount_declared", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "alcohol_licence": { + "name": "alcohol_licence", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "terrace": { + "name": "terrace", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "music": { + "name": "music", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "cameras": { + "name": "cameras", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "fryer": { + "name": "fryer", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "minors_employed": { + "name": "minors_employed", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "foreign_workers": { + "name": "foreign_workers", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "franchise": { + "name": "franchise", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishment_regulatory_profiles_org_idx": { + "name": "establishment_regulatory_profiles_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishment_regulatory_profiles_establishment_id_establishments_id_fk": { + "name": "establishment_regulatory_profiles_establishment_id_establishments_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_regulatory_profiles_organization_id_organizations_id_fk": { + "name": "establishment_regulatory_profiles_organization_id_organizations_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_regulatory_profiles_updated_by_users_id_fk": { + "name": "establishment_regulatory_profiles_updated_by_users_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "establishment_regulatory_profiles_erp_ck": { + "name": "establishment_regulatory_profiles_erp_ck", + "value": "\"establishment_regulatory_profiles\".\"erp_category\" IS NULL OR \"establishment_regulatory_profiles\".\"erp_category\" IN ('1', '2', '3', '4', '5')" + }, + "establishment_regulatory_profiles_licence_ck": { + "name": "establishment_regulatory_profiles_licence_ck", + "value": "\"establishment_regulatory_profiles\".\"alcohol_licence\" IS NULL OR \"establishment_regulatory_profiles\".\"alcohol_licence\" IN ('aucune', 'petite_licence_restaurant', 'licence_restaurant', 'licence_3', 'licence_4', 'petite_licence_emporter', 'licence_emporter', 'inconnue')" + }, + "establishment_regulatory_profiles_counts_ck": { + "name": "establishment_regulatory_profiles_counts_ck", + "value": "(\"establishment_regulatory_profiles\".\"seating_capacity\" IS NULL OR \"establishment_regulatory_profiles\".\"seating_capacity\" >= 0) AND (\"establishment_regulatory_profiles\".\"headcount_declared\" IS NULL OR \"establishment_regulatory_profiles\".\"headcount_declared\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.establishments": { + "name": "establishments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'restaurant'" + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ape_code": { + "name": "ape_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idcc": { + "name": "idcc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "country": { + "name": "country", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'FR'" + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Europe/Paris'" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'EUR'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishments_org_idx": { + "name": "establishments_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishments_organization_id_organizations_id_fk": { + "name": "establishments_organization_id_organizations_id_fk", + "tableFrom": "establishments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishments_company_id_companies_id_fk": { + "name": "establishments_company_id_companies_id_fk", + "tableFrom": "establishments", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.expense_entries": { + "name": "expense_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier": { + "name": "supplier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "period_start": { + "name": "period_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_end": { + "name": "period_end", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "recurrence": { + "name": "recurrence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "recurrence_until": { + "name": "recurrence_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deleted_by": { + "name": "deleted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "deletion_reason": { + "name": "deletion_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "double_count_decision": { + "name": "double_count_decision", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "double_count_decided_by": { + "name": "double_count_decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "double_count_decided_at": { + "name": "double_count_decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "expenses_period_idx": { + "name": "expenses_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_start", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_end", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "expense_entries_organization_id_organizations_id_fk": { + "name": "expense_entries_organization_id_organizations_id_fk", + "tableFrom": "expense_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "expense_entries_establishment_id_establishments_id_fk": { + "name": "expense_entries_establishment_id_establishments_id_fk", + "tableFrom": "expense_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "expense_entries_created_by_users_id_fk": { + "name": "expense_entries_created_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "expense_entries_deleted_by_users_id_fk": { + "name": "expense_entries_deleted_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "deleted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "expense_entries_double_count_decided_by_users_id_fk": { + "name": "expense_entries_double_count_decided_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "double_count_decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "expenses_period_ck": { + "name": "expenses_period_ck", + "value": "\"expense_entries\".\"period_start\" <= \"expense_entries\".\"period_end\"" + }, + "expenses_recurrence_ck": { + "name": "expenses_recurrence_ck", + "value": "\"expense_entries\".\"recurrence\" IN ('none', 'monthly', 'quarterly', 'yearly')" + }, + "expenses_recurrence_until_ck": { + "name": "expenses_recurrence_until_ck", + "value": "\"expense_entries\".\"recurrence_until\" IS NULL OR (\"expense_entries\".\"recurrence\" <> 'none' AND \"expense_entries\".\"recurrence_until\" >= \"expense_entries\".\"period_start\")" + }, + "expenses_ttc_consistency_ck": { + "name": "expenses_ttc_consistency_ck", + "value": "\"expense_entries\".\"amount_ttc\" = \"expense_entries\".\"amount_ht\" + \"expense_entries\".\"vat_amount\"" + }, + "expense_double_count_ck": { + "name": "expense_double_count_ck", + "value": "\"expense_entries\".\"double_count_decision\" IS NULL OR \"expense_entries\".\"double_count_decision\" IN ('keep', 'exclude')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_ambassadors": { + "name": "feedback_ambassadors", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "appointed_by": { + "name": "appointed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_ambassadors_organization_id_organizations_id_fk": { + "name": "feedback_ambassadors_organization_id_organizations_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_ambassadors_user_id_users_id_fk": { + "name": "feedback_ambassadors_user_id_users_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_ambassadors_appointed_by_users_id_fk": { + "name": "feedback_ambassadors_appointed_by_users_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "users", + "columnsFrom": [ + "appointed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_ambassadors_organization_id_user_id_pk": { + "name": "feedback_ambassadors_organization_id_user_id_pk", + "columns": [ + "organization_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback_comments": { + "name": "feedback_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'commentaire'" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_status": { + "name": "from_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "to_status": { + "name": "to_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_comments_item_idx": { + "name": "feedback_comments_item_idx", + "columns": [ + { + "expression": "feedback_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_comments_organization_id_organizations_id_fk": { + "name": "feedback_comments_organization_id_organizations_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_comments_feedback_id_feedback_items_id_fk": { + "name": "feedback_comments_feedback_id_feedback_items_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "feedback_items", + "columnsFrom": [ + "feedback_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_comments_user_id_users_id_fk": { + "name": "feedback_comments_user_id_users_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_comments_kind_ck": { + "name": "feedback_comments_kind_ck", + "value": "\"feedback_comments\".\"kind\" IN ('commentaire', 'reponse', 'statut', 'fusion')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_items": { + "name": "feedback_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "page_path": { + "name": "page_path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_role": { + "name": "author_role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "screenshot": { + "name": "screenshot", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "screenshot_mime": { + "name": "screenshot_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'recue'" + }, + "status_note": { + "name": "status_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "release_version": { + "name": "release_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "merged_into_id": { + "name": "merged_into_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "first_response_at": { + "name": "first_response_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delivered_at": { + "name": "delivered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_items_number_uq": { + "name": "feedback_items_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "feedback_items_org_idx": { + "name": "feedback_items_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_items_organization_id_organizations_id_fk": { + "name": "feedback_items_organization_id_organizations_id_fk", + "tableFrom": "feedback_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_items_merged_into_id_feedback_items_id_fk": { + "name": "feedback_items_merged_into_id_feedback_items_id_fk", + "tableFrom": "feedback_items", + "tableTo": "feedback_items", + "columnsFrom": [ + "merged_into_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "feedback_items_author_id_users_id_fk": { + "name": "feedback_items_author_id_users_id_fk", + "tableFrom": "feedback_items", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_items_kind_ck": { + "name": "feedback_items_kind_ck", + "value": "\"feedback_items\".\"kind\" IN ('idee', 'probleme', 'question')" + }, + "feedback_items_status_ck": { + "name": "feedback_items_status_ck", + "value": "\"feedback_items\".\"status\" IN ('recue', 'etude', 'prevue', 'en_cours', 'livree', 'pas_maintenant')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_pulses": { + "name": "feedback_pulses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_pulses_once_uq": { + "name": "feedback_pulses_once_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "app_version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "feedback_pulses_org_idx": { + "name": "feedback_pulses_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_pulses_organization_id_organizations_id_fk": { + "name": "feedback_pulses_organization_id_organizations_id_fk", + "tableFrom": "feedback_pulses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_pulses_user_id_users_id_fk": { + "name": "feedback_pulses_user_id_users_id_fk", + "tableFrom": "feedback_pulses", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_pulses_answer_ck": { + "name": "feedback_pulses_answer_ck", + "value": "\"feedback_pulses\".\"answer\" IN ('oui', 'non')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_testers": { + "name": "feedback_testers", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_testers_organization_id_organizations_id_fk": { + "name": "feedback_testers_organization_id_organizations_id_fk", + "tableFrom": "feedback_testers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_testers_user_id_users_id_fk": { + "name": "feedback_testers_user_id_users_id_fk", + "tableFrom": "feedback_testers", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_testers_organization_id_user_id_pk": { + "name": "feedback_testers_organization_id_user_id_pk", + "columns": [ + "organization_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback_votes": { + "name": "feedback_votes", + "schema": "", + "columns": { + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_votes_feedback_id_feedback_items_id_fk": { + "name": "feedback_votes_feedback_id_feedback_items_id_fk", + "tableFrom": "feedback_votes", + "tableTo": "feedback_items", + "columnsFrom": [ + "feedback_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_votes_user_id_users_id_fk": { + "name": "feedback_votes_user_id_users_id_fk", + "tableFrom": "feedback_votes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_votes_feedback_id_user_id_pk": { + "name": "feedback_votes_feedback_id_user_id_pk", + "columns": [ + "feedback_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.file_downloads": { + "name": "file_downloads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sensitivity": { + "name": "sensitivity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disposition": { + "name": "disposition", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "file_downloads_entity_idx": { + "name": "file_downloads_entity_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "file_downloads_organization_id_organizations_id_fk": { + "name": "file_downloads_organization_id_organizations_id_fk", + "tableFrom": "file_downloads", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "file_downloads_user_id_users_id_fk": { + "name": "file_downloads_user_id_users_id_fk", + "tableFrom": "file_downloads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "file_downloads_source_ck": { + "name": "file_downloads_source_ck", + "value": "\"file_downloads\".\"source\" IN ('business_document', 'business_document_version', 'employee_file', 'vault_zip', 'privacy_export', 'signature_request', 'sos_zip', 'generated_report', 'generated_hr_document', 'data_export')" + }, + "file_downloads_disposition_ck": { + "name": "file_downloads_disposition_ck", + "value": "\"file_downloads\".\"disposition\" IN ('inline', 'attachment', 'zip')" + } + }, + "isRLSEnabled": false + }, + "public.fixed_assets": { + "name": "fixed_assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "financing": { + "name": "financing", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "acquired_on": { + "name": "acquired_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "useful_life_months": { + "name": "useful_life_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lease_monthly_ht": { + "name": "lease_monthly_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "lease_end_on": { + "name": "lease_end_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "lease_residual_ht": { + "name": "lease_residual_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "disposed_on": { + "name": "disposed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "disposal_reason": { + "name": "disposal_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "fixed_assets_est_idx": { + "name": "fixed_assets_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fixed_assets_invoice_uq": { + "name": "fixed_assets_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"fixed_assets\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "fixed_assets_pennylane_uq": { + "name": "fixed_assets_pennylane_uq", + "columns": [ + { + "expression": "pennylane_record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"fixed_assets\".\"pennylane_record_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "fixed_assets_organization_id_organizations_id_fk": { + "name": "fixed_assets_organization_id_organizations_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fixed_assets_establishment_id_establishments_id_fk": { + "name": "fixed_assets_establishment_id_establishments_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fixed_assets_supplier_id_suppliers_id_fk": { + "name": "fixed_assets_supplier_id_suppliers_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "fixed_assets_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_pennylane_record_id_pennylane_records_id_fk": { + "name": "fixed_assets_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_document_id_business_documents_id_fk": { + "name": "fixed_assets_document_id_business_documents_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_created_by_users_id_fk": { + "name": "fixed_assets_created_by_users_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "fixed_assets_category_ck": { + "name": "fixed_assets_category_ck", + "value": "\"fixed_assets\".\"category\" IN ('materiel_cuisine', 'mobilier', 'informatique', 'agencement', 'vehicule', 'autre')" + }, + "fixed_assets_financing_ck": { + "name": "fixed_assets_financing_ck", + "value": "\"fixed_assets\".\"financing\" IN ('achat', 'credit_bail', 'location_financiere')" + }, + "fixed_assets_purchase_ck": { + "name": "fixed_assets_purchase_ck", + "value": "\"fixed_assets\".\"financing\" <> 'achat' OR (\"fixed_assets\".\"amount_ht\" IS NOT NULL AND \"fixed_assets\".\"amount_ht\" > 0 AND \"fixed_assets\".\"useful_life_months\" IS NOT NULL)" + }, + "fixed_assets_lease_ck": { + "name": "fixed_assets_lease_ck", + "value": "\"fixed_assets\".\"financing\" = 'achat' OR (\"fixed_assets\".\"lease_monthly_ht\" IS NOT NULL AND \"fixed_assets\".\"lease_monthly_ht\" > 0 AND \"fixed_assets\".\"lease_end_on\" IS NOT NULL AND \"fixed_assets\".\"lease_end_on\" > \"fixed_assets\".\"acquired_on\")" + }, + "fixed_assets_life_ck": { + "name": "fixed_assets_life_ck", + "value": "\"fixed_assets\".\"useful_life_months\" IS NULL OR \"fixed_assets\".\"useful_life_months\" BETWEEN 1 AND 600" + }, + "fixed_assets_amounts_ck": { + "name": "fixed_assets_amounts_ck", + "value": "(\"fixed_assets\".\"amount_ht\" IS NULL OR \"fixed_assets\".\"amount_ht\" >= 0) AND (\"fixed_assets\".\"lease_residual_ht\" IS NULL OR \"fixed_assets\".\"lease_residual_ht\" >= 0)" + }, + "fixed_assets_disposal_ck": { + "name": "fixed_assets_disposal_ck", + "value": "\"fixed_assets\".\"disposed_on\" IS NULL OR (\"fixed_assets\".\"disposed_on\" >= \"fixed_assets\".\"acquired_on\" AND \"fixed_assets\".\"disposal_reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.floor_items": { + "name": "floor_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "shape": { + "name": "shape", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "w": { + "name": "w", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "h": { + "name": "h", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "rotation": { + "name": "rotation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "floor_items_room_idx": { + "name": "floor_items_room_idx", + "columns": [ + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "floor_items_table_label_uq": { + "name": "floor_items_table_label_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"label\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"floor_items\".\"kind\" = 'table' AND \"floor_items\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "floor_items_organization_id_organizations_id_fk": { + "name": "floor_items_organization_id_organizations_id_fk", + "tableFrom": "floor_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "floor_items_establishment_id_establishments_id_fk": { + "name": "floor_items_establishment_id_establishments_id_fk", + "tableFrom": "floor_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "floor_items_room_id_floor_rooms_id_fk": { + "name": "floor_items_room_id_floor_rooms_id_fk", + "tableFrom": "floor_items", + "tableTo": "floor_rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "floor_items_kind_ck": { + "name": "floor_items_kind_ck", + "value": "\"floor_items\".\"kind\" IN ('table', 'wall', 'bar', 'door', 'window', 'pillar', 'plant', 'zone', 'text')" + }, + "floor_items_table_ck": { + "name": "floor_items_table_ck", + "value": "\"floor_items\".\"kind\" <> 'table' OR (\"floor_items\".\"shape\" IN ('round', 'square', 'rect') AND \"floor_items\".\"label\" IS NOT NULL AND \"floor_items\".\"seats\" BETWEEN 1 AND 40)" + }, + "floor_items_size_ck": { + "name": "floor_items_size_ck", + "value": "\"floor_items\".\"w\" BETWEEN 5 AND 10000 AND \"floor_items\".\"h\" BETWEEN 5 AND 10000 AND \"floor_items\".\"rotation\" BETWEEN 0 AND 359" + } + }, + "isRLSEnabled": false + }, + "public.floor_rooms": { + "name": "floor_rooms", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width_cm": { + "name": "width_cm", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1200 + }, + "height_cm": { + "name": "height_cm", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 800 + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "floor_rooms_est_idx": { + "name": "floor_rooms_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "floor_rooms_organization_id_organizations_id_fk": { + "name": "floor_rooms_organization_id_organizations_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "floor_rooms_establishment_id_establishments_id_fk": { + "name": "floor_rooms_establishment_id_establishments_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "floor_rooms_created_by_users_id_fk": { + "name": "floor_rooms_created_by_users_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "floor_rooms_size_ck": { + "name": "floor_rooms_size_ck", + "value": "\"floor_rooms\".\"width_cm\" BETWEEN 200 AND 10000 AND \"floor_rooms\".\"height_cm\" BETWEEN 200 AND 10000" + } + }, + "isRLSEnabled": false + }, + "public.forecast_events": { + "name": "forecast_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_day": { + "name": "from_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "to_day": { + "name": "to_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "impact_pct": { + "name": "impact_pct", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forecast_events_org_idx": { + "name": "forecast_events_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forecast_events_organization_id_organizations_id_fk": { + "name": "forecast_events_organization_id_organizations_id_fk", + "tableFrom": "forecast_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forecast_events_establishment_id_establishments_id_fk": { + "name": "forecast_events_establishment_id_establishments_id_fk", + "tableFrom": "forecast_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forecast_events_created_by_users_id_fk": { + "name": "forecast_events_created_by_users_id_fk", + "tableFrom": "forecast_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "forecast_events_range_ck": { + "name": "forecast_events_range_ck", + "value": "\"forecast_events\".\"to_day\" >= \"forecast_events\".\"from_day\" AND \"forecast_events\".\"to_day\" - \"forecast_events\".\"from_day\" <= 92" + }, + "forecast_events_impact_ck": { + "name": "forecast_events_impact_ck", + "value": "\"forecast_events\".\"impact_pct\" IS NULL OR (\"forecast_events\".\"impact_pct\" >= -100 AND \"forecast_events\".\"impact_pct\" <= 500)" + } + }, + "isRLSEnabled": false + }, + "public.forum_replies": { + "name": "forum_replies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "topic_id": { + "name": "topic_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forum_replies_topic_idx": { + "name": "forum_replies_topic_idx", + "columns": [ + { + "expression": "topic_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forum_replies_organization_id_organizations_id_fk": { + "name": "forum_replies_organization_id_organizations_id_fk", + "tableFrom": "forum_replies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_replies_topic_id_forum_topics_id_fk": { + "name": "forum_replies_topic_id_forum_topics_id_fk", + "tableFrom": "forum_replies", + "tableTo": "forum_topics", + "columnsFrom": [ + "topic_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_replies_author_id_users_id_fk": { + "name": "forum_replies_author_id_users_id_fk", + "tableFrom": "forum_replies", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.forum_topics": { + "name": "forum_topics", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'question'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pinned": { + "name": "pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "solution_reply_id": { + "name": "solution_reply_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "idea_id": { + "name": "idea_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forum_topics_number_uq": { + "name": "forum_topics_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "forum_topics_org_idx": { + "name": "forum_topics_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "pinned", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_activity_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forum_topics_organization_id_organizations_id_fk": { + "name": "forum_topics_organization_id_organizations_id_fk", + "tableFrom": "forum_topics", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_topics_author_id_users_id_fk": { + "name": "forum_topics_author_id_users_id_fk", + "tableFrom": "forum_topics", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "forum_topics_idea_id_feedback_items_id_fk": { + "name": "forum_topics_idea_id_feedback_items_id_fk", + "tableFrom": "forum_topics", + "tableTo": "feedback_items", + "columnsFrom": [ + "idea_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "forum_topics_category_ck": { + "name": "forum_topics_category_ck", + "value": "\"forum_topics\".\"category\" IN ('question', 'astuce', 'discussion')" + } + }, + "isRLSEnabled": false + }, + "public.google_post_settings": { + "name": "google_post_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "schedule_mode": { + "name": "schedule_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'per_week'" + }, + "weekdays": { + "name": "weekdays", + "type": "integer[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[2,5]::integer[]" + }, + "per_week": { + "name": "per_week", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "post_time": { + "name": "post_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'10:00'" + }, + "lead_hours": { + "name": "lead_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 48 + }, + "src_menu": { + "name": "src_menu", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_events": { + "name": "src_events", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_hours": { + "name": "src_hours", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_best_sellers": { + "name": "src_best_sellers", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_seasonal": { + "name": "src_seasonal", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_reviews": { + "name": "src_reviews", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "review_min_rating": { + "name": "review_min_rating", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "default_cta_type": { + "name": "default_cta_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "default_cta_url": { + "name": "default_cta_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'fr'" + }, + "autopublish": { + "name": "autopublish", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enabled_by": { + "name": "enabled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "enabled_at": { + "name": "enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmation": { + "name": "confirmation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_generated_at": { + "name": "last_generated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "google_post_settings_org_idx": { + "name": "google_post_settings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "google_post_settings_establishment_id_establishments_id_fk": { + "name": "google_post_settings_establishment_id_establishments_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_post_settings_organization_id_organizations_id_fk": { + "name": "google_post_settings_organization_id_organizations_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_post_settings_enabled_by_users_id_fk": { + "name": "google_post_settings_enabled_by_users_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "users", + "columnsFrom": [ + "enabled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_post_settings_updated_by_users_id_fk": { + "name": "google_post_settings_updated_by_users_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "google_post_settings_mode_ck": { + "name": "google_post_settings_mode_ck", + "value": "\"google_post_settings\".\"schedule_mode\" IN ('weekdays', 'per_week')" + }, + "google_post_settings_weekdays_ck": { + "name": "google_post_settings_weekdays_ck", + "value": "cardinality(\"google_post_settings\".\"weekdays\") BETWEEN 1 AND 7 AND \"google_post_settings\".\"weekdays\" <@ ARRAY[1,2,3,4,5,6,7]::integer[]" + }, + "google_post_settings_per_week_ck": { + "name": "google_post_settings_per_week_ck", + "value": "\"google_post_settings\".\"per_week\" BETWEEN 1 AND 7" + }, + "google_post_settings_time_ck": { + "name": "google_post_settings_time_ck", + "value": "\"google_post_settings\".\"post_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "google_post_settings_lead_ck": { + "name": "google_post_settings_lead_ck", + "value": "\"google_post_settings\".\"lead_hours\" BETWEEN 12 AND 168" + }, + "google_post_settings_rating_ck": { + "name": "google_post_settings_rating_ck", + "value": "\"google_post_settings\".\"review_min_rating\" BETWEEN 4 AND 5" + }, + "google_post_settings_cta_ck": { + "name": "google_post_settings_cta_ck", + "value": "\"google_post_settings\".\"default_cta_type\" IS NULL OR \"google_post_settings\".\"default_cta_type\" IN ('BOOK', 'ORDER', 'SHOP', 'LEARN_MORE', 'SIGN_UP', 'CALL')" + }, + "google_post_settings_autopublish_ck": { + "name": "google_post_settings_autopublish_ck", + "value": "NOT \"google_post_settings\".\"autopublish\" OR \"google_post_settings\".\"confirmation\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.google_posts": { + "name": "google_posts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "generator": { + "name": "generator", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "facts": { + "name": "facts", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "topic_type": { + "name": "topic_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'STANDARD'" + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cta_type": { + "name": "cta_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cta_url": { + "name": "cta_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_title": { + "name": "event_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_start_date": { + "name": "event_start_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_start_time": { + "name": "event_start_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_end_date": { + "name": "event_end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_end_time": { + "name": "event_end_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_coupon": { + "name": "offer_coupon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_url": { + "name": "offer_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_terms": { + "name": "offer_terms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "visual_id": { + "name": "visual_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "image_mime": { + "name": "image_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blocked_words": { + "name": "blocked_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "google_name": { + "name": "google_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_state": { + "name": "google_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "search_url": { + "name": "search_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "ai_cost_usd": { + "name": "ai_cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "google_posts_due_idx": { + "name": "google_posts_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_cal_idx": { + "name": "google_posts_cal_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_for", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_source_uq": { + "name": "google_posts_source_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"google_posts\".\"source_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_token_uq": { + "name": "google_posts_token_uq", + "columns": [ + { + "expression": "public_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "google_posts_organization_id_organizations_id_fk": { + "name": "google_posts_organization_id_organizations_id_fk", + "tableFrom": "google_posts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_posts_establishment_id_establishments_id_fk": { + "name": "google_posts_establishment_id_establishments_id_fk", + "tableFrom": "google_posts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_posts_visual_id_studio_visuals_id_fk": { + "name": "google_posts_visual_id_studio_visuals_id_fk", + "tableFrom": "google_posts", + "tableTo": "studio_visuals", + "columnsFrom": [ + "visual_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_posts_approved_by_users_id_fk": { + "name": "google_posts_approved_by_users_id_fk", + "tableFrom": "google_posts", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_posts_created_by_users_id_fk": { + "name": "google_posts_created_by_users_id_fk", + "tableFrom": "google_posts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "google_posts_source_ck": { + "name": "google_posts_source_ck", + "value": "\"google_posts\".\"source\" IN ('manuel', 'menu_du_jour', 'evenement', 'horaires', 'meilleures_ventes', 'saison', 'avis')" + }, + "google_posts_generator_ck": { + "name": "google_posts_generator_ck", + "value": "\"google_posts\".\"generator\" IN ('ia', 'modele', 'humain')" + }, + "google_posts_topic_ck": { + "name": "google_posts_topic_ck", + "value": "\"google_posts\".\"topic_type\" IN ('STANDARD', 'EVENT', 'OFFER')" + }, + "google_posts_status_ck": { + "name": "google_posts_status_ck", + "value": "\"google_posts\".\"status\" IN ('brouillon', 'planifie', 'publishing', 'publie', 'echec', 'bloque', 'annule', 'expire', 'retire')" + }, + "google_posts_summary_ck": { + "name": "google_posts_summary_ck", + "value": "char_length(\"google_posts\".\"summary\") BETWEEN 1 AND 1500" + }, + "google_posts_cta_ck": { + "name": "google_posts_cta_ck", + "value": "\"google_posts\".\"cta_type\" IS NULL OR \"google_posts\".\"cta_type\" IN ('BOOK', 'ORDER', 'SHOP', 'LEARN_MORE', 'SIGN_UP', 'CALL')" + }, + "google_posts_image_ck": { + "name": "google_posts_image_ck", + "value": "(\"google_posts\".\"image\" IS NULL) = (\"google_posts\".\"image_mime\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.haccp_corrective_actions": { + "name": "haccp_corrective_actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_id": { + "name": "source_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dedup_key": { + "name": "dedup_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "detected_at": { + "name": "detected_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "action_taken": { + "name": "action_taken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "haccp_corrective_actions_dedup_uq": { + "name": "haccp_corrective_actions_dedup_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedup_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "haccp_corrective_actions_open_idx": { + "name": "haccp_corrective_actions_open_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "detected_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"haccp_corrective_actions\".\"closed_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "haccp_corrective_actions_organization_id_organizations_id_fk": { + "name": "haccp_corrective_actions_organization_id_organizations_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_corrective_actions_establishment_id_establishments_id_fk": { + "name": "haccp_corrective_actions_establishment_id_establishments_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_corrective_actions_closed_by_users_id_fk": { + "name": "haccp_corrective_actions_closed_by_users_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "haccp_corrective_actions_created_by_users_id_fk": { + "name": "haccp_corrective_actions_created_by_users_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "haccp_corrective_actions_source_ck": { + "name": "haccp_corrective_actions_source_ck", + "value": "\"haccp_corrective_actions\".\"source\" IN ('sonde_hors_plage', 'sonde_muette', 'releves_manquants', 'nettoyage_manquant', 'date_limite', 'manuel')" + }, + "haccp_corrective_actions_close_ck": { + "name": "haccp_corrective_actions_close_ck", + "value": "(\"haccp_corrective_actions\".\"closed_at\" IS NULL) = (\"haccp_corrective_actions\".\"action_taken\" IS NULL) AND (\"haccp_corrective_actions\".\"closed_at\" IS NULL) = (\"haccp_corrective_actions\".\"closed_by\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.incidents": { + "name": "incidents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actions_taken": { + "name": "actions_taken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "reported_by": { + "name": "reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reported_at": { + "name": "reported_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "incidents_est_idx": { + "name": "incidents_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurred_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "incidents_organization_id_organizations_id_fk": { + "name": "incidents_organization_id_organizations_id_fk", + "tableFrom": "incidents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "incidents_establishment_id_establishments_id_fk": { + "name": "incidents_establishment_id_establishments_id_fk", + "tableFrom": "incidents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "incidents_reported_by_users_id_fk": { + "name": "incidents_reported_by_users_id_fk", + "tableFrom": "incidents", + "tableTo": "users", + "columnsFrom": [ + "reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "incidents_closed_by_users_id_fk": { + "name": "incidents_closed_by_users_id_fk", + "tableFrom": "incidents", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "incidents_kind_ck": { + "name": "incidents_kind_ck", + "value": "\"incidents\".\"kind\" IN ('client', 'accident', 'casse', 'vol', 'securite', 'hygiene', 'livraison', 'autre')" + }, + "incidents_severity_ck": { + "name": "incidents_severity_ck", + "value": "\"incidents\".\"severity\" IN ('mineur', 'important', 'grave')" + }, + "incidents_status_ck": { + "name": "incidents_status_ck", + "value": "\"incidents\".\"status\" IN ('ouvert', 'clos')" + }, + "incidents_closed_ck": { + "name": "incidents_closed_ck", + "value": "\"incidents\".\"status\" = 'ouvert' OR (\"incidents\".\"closed_at\" IS NOT NULL AND \"incidents\".\"follow_up\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.inspection_shares": { + "name": "inspection_shares", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inspector_code": { + "name": "inspector_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_name": { + "name": "created_by_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "access_count": { + "name": "access_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_access_at": { + "name": "last_access_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inspection_shares_token_uq": { + "name": "inspection_shares_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inspection_shares_est_idx": { + "name": "inspection_shares_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inspection_shares_organization_id_organizations_id_fk": { + "name": "inspection_shares_organization_id_organizations_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inspection_shares_establishment_id_establishments_id_fk": { + "name": "inspection_shares_establishment_id_establishments_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inspection_shares_created_by_users_id_fk": { + "name": "inspection_shares_created_by_users_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_connections": { + "name": "integration_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "connection_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'not_configured'" + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_config": { + "name": "public_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_sync": { + "name": "auto_sync", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sync_interval_hours": { + "name": "sync_interval_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 24 + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integration_conn_uq": { + "name": "integration_conn_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_connections_organization_id_organizations_id_fk": { + "name": "integration_connections_organization_id_organizations_id_fk", + "tableFrom": "integration_connections", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_connections_establishment_id_establishments_id_fk": { + "name": "integration_connections_establishment_id_establishments_id_fk", + "tableFrom": "integration_connections", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "integration_conn_interval_ck": { + "name": "integration_conn_interval_ck", + "value": "\"integration_connections\".\"sync_interval_hours\" BETWEEN 1 AND 168" + }, + "integration_conn_failures_ck": { + "name": "integration_conn_failures_ck", + "value": "\"integration_connections\".\"consecutive_failures\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.integration_sync_runs": { + "name": "integration_sync_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "counts": { + "name": "counts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "errors": { + "name": "errors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "integration_sync_runs_idx": { + "name": "integration_sync_runs_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_sync_runs_organization_id_organizations_id_fk": { + "name": "integration_sync_runs_organization_id_organizations_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_sync_runs_establishment_id_establishments_id_fk": { + "name": "integration_sync_runs_establishment_id_establishments_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_sync_runs_user_id_users_id_fk": { + "name": "integration_sync_runs_user_id_users_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "integration_sync_runs_trigger_ck": { + "name": "integration_sync_runs_trigger_ck", + "value": "\"integration_sync_runs\".\"trigger\" IN ('manual', 'auto')" + }, + "integration_sync_runs_outcome_ck": { + "name": "integration_sync_runs_outcome_ck", + "value": "\"integration_sync_runs\".\"outcome\" IN ('success', 'partial', 'error')" + } + }, + "isRLSEnabled": false + }, + "public.intercompany_flows": { + "name": "intercompany_flows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payer_company_id": { + "name": "payer_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payee_company_id": { + "name": "payee_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "flow_date": { + "name": "flow_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "agreement_ref": { + "name": "agreement_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'saisie'" + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "bank_transaction_id": { + "name": "bank_transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "intercompany_flows_org_idx": { + "name": "intercompany_flows_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "flow_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "intercompany_flows_invoice_uq": { + "name": "intercompany_flows_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"intercompany_flows\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "intercompany_flows_bank_uq": { + "name": "intercompany_flows_bank_uq", + "columns": [ + { + "expression": "bank_transaction_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"intercompany_flows\".\"bank_transaction_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "intercompany_flows_organization_id_organizations_id_fk": { + "name": "intercompany_flows_organization_id_organizations_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_payer_company_id_companies_id_fk": { + "name": "intercompany_flows_payer_company_id_companies_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "companies", + "columnsFrom": [ + "payer_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_payee_company_id_companies_id_fk": { + "name": "intercompany_flows_payee_company_id_companies_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "companies", + "columnsFrom": [ + "payee_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "intercompany_flows_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "intercompany_flows_bank_transaction_id_bank_transactions_id_fk": { + "name": "intercompany_flows_bank_transaction_id_bank_transactions_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "bank_transactions", + "columnsFrom": [ + "bank_transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "intercompany_flows_created_by_users_id_fk": { + "name": "intercompany_flows_created_by_users_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "intercompany_flows_cancelled_by_users_id_fk": { + "name": "intercompany_flows_cancelled_by_users_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "intercompany_flows_pair_ck": { + "name": "intercompany_flows_pair_ck", + "value": "\"intercompany_flows\".\"payer_company_id\" <> \"intercompany_flows\".\"payee_company_id\"" + }, + "intercompany_flows_amount_ck": { + "name": "intercompany_flows_amount_ck", + "value": "\"intercompany_flows\".\"amount_ht\" > 0 AND (\"intercompany_flows\".\"vat_amount\" IS NULL OR \"intercompany_flows\".\"vat_amount\" >= 0)" + }, + "intercompany_flows_source_ck": { + "name": "intercompany_flows_source_ck", + "value": "\"intercompany_flows\".\"source\" IN ('saisie', 'facture', 'banque')" + }, + "intercompany_flows_kind_ck": { + "name": "intercompany_flows_kind_ck", + "value": "\"intercompany_flows\".\"kind\" IN ('refacturation', 'management_fees', 'loyer', 'vente', 'interets', 'dividendes', 'pret', 'remboursement_pret', 'apport_compte_courant', 'remboursement_compte_courant', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.inventories": { + "name": "inventories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "count_date": { + "name": "count_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "total_value": { + "name": "total_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inventories_est_idx": { + "name": "inventories_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "count_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inventories_validated_day_uq": { + "name": "inventories_validated_day_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "count_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"inventories\".\"status\" = 'validated'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inventories_organization_id_organizations_id_fk": { + "name": "inventories_organization_id_organizations_id_fk", + "tableFrom": "inventories", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventories_establishment_id_establishments_id_fk": { + "name": "inventories_establishment_id_establishments_id_fk", + "tableFrom": "inventories", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "inventories_created_by_users_id_fk": { + "name": "inventories_created_by_users_id_fk", + "tableFrom": "inventories", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventories_validated_by_users_id_fk": { + "name": "inventories_validated_by_users_id_fk", + "tableFrom": "inventories", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "inventories_status_ck": { + "name": "inventories_status_ck", + "value": "\"inventories\".\"status\" IN ('draft', 'validated')" + } + }, + "isRLSEnabled": false + }, + "public.inventory_lines": { + "name": "inventory_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inventory_id": { + "name": "inventory_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inventory_lines_item_uq": { + "name": "inventory_lines_item_uq", + "columns": [ + { + "expression": "inventory_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inventory_lines_organization_id_organizations_id_fk": { + "name": "inventory_lines_organization_id_organizations_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventory_lines_inventory_id_inventories_id_fk": { + "name": "inventory_lines_inventory_id_inventories_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "inventories", + "columnsFrom": [ + "inventory_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventory_lines_item_id_purchase_items_id_fk": { + "name": "inventory_lines_item_id_purchase_items_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "inventory_lines_qty_ck": { + "name": "inventory_lines_qty_ck", + "value": "\"inventory_lines\".\"quantity\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.investment_scenarios": { + "name": "investment_scenarios", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'etude'" + }, + "price": { + "name": "price", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "fees": { + "name": "fees", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "works": { + "name": "works", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "working_capital": { + "name": "working_capital", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "equity": { + "name": "equity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "loan_rate_pct": { + "name": "loan_rate_pct", + "type": "numeric(6, 3)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "loan_years": { + "name": "loan_years", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 7 + }, + "revenue_ht": { + "name": "revenue_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "ebe": { + "name": "ebe", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "adjustments": { + "name": "adjustments", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "owner_pay": { + "name": "owner_pay", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "maintenance_capex": { + "name": "maintenance_capex", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "investment_scenarios_org_idx": { + "name": "investment_scenarios_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "investment_scenarios_organization_id_organizations_id_fk": { + "name": "investment_scenarios_organization_id_organizations_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "investment_scenarios_establishment_id_establishments_id_fk": { + "name": "investment_scenarios_establishment_id_establishments_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "investment_scenarios_created_by_users_id_fk": { + "name": "investment_scenarios_created_by_users_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "investment_scenarios_updated_by_users_id_fk": { + "name": "investment_scenarios_updated_by_users_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "investment_scenarios_kind_ck": { + "name": "investment_scenarios_kind_ck", + "value": "\"investment_scenarios\".\"kind\" IN ('rachat_fonds', 'rachat_parts', 'travaux', 'equipement', 'ouverture', 'autre')" + }, + "investment_scenarios_status_ck": { + "name": "investment_scenarios_status_ck", + "value": "\"investment_scenarios\".\"status\" IN ('etude', 'retenu', 'abandonne', 'realise')" + }, + "investment_scenarios_years_ck": { + "name": "investment_scenarios_years_ck", + "value": "\"investment_scenarios\".\"loan_years\" BETWEEN 1 AND 30" + }, + "investment_scenarios_rate_ck": { + "name": "investment_scenarios_rate_ck", + "value": "\"investment_scenarios\".\"loan_rate_pct\" >= 0 AND \"investment_scenarios\".\"loan_rate_pct\" <= 20" + }, + "investment_scenarios_amounts_ck": { + "name": "investment_scenarios_amounts_ck", + "value": "\"investment_scenarios\".\"price\" >= 0 AND \"investment_scenarios\".\"fees\" >= 0 AND \"investment_scenarios\".\"works\" >= 0 AND \"investment_scenarios\".\"working_capital\" >= 0 AND \"investment_scenarios\".\"equity\" >= 0 AND \"investment_scenarios\".\"owner_pay\" >= 0 AND \"investment_scenarios\".\"maintenance_capex\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.invoice_label_links": { + "name": "invoice_label_links", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "link_key": { + "name": "link_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invoice_label_links_key_uq": { + "name": "invoice_label_links_key_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "link_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invoice_label_links_organization_id_organizations_id_fk": { + "name": "invoice_label_links_organization_id_organizations_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoice_label_links_item_id_purchase_items_id_fk": { + "name": "invoice_label_links_item_id_purchase_items_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoice_label_links_created_by_users_id_fk": { + "name": "invoice_label_links_created_by_users_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.item_stock_settings": { + "name": "item_stock_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "min_stock": { + "name": "min_stock", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "target_stock": { + "name": "target_stock", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "overstock_days": { + "name": "overstock_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "item_stock_settings_uq": { + "name": "item_stock_settings_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "item_stock_settings_organization_id_organizations_id_fk": { + "name": "item_stock_settings_organization_id_organizations_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "item_stock_settings_establishment_id_establishments_id_fk": { + "name": "item_stock_settings_establishment_id_establishments_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "item_stock_settings_item_id_purchase_items_id_fk": { + "name": "item_stock_settings_item_id_purchase_items_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "item_stock_settings_ck": { + "name": "item_stock_settings_ck", + "value": "(\"item_stock_settings\".\"min_stock\" IS NULL OR \"item_stock_settings\".\"min_stock\" >= 0) AND (\"item_stock_settings\".\"target_stock\" IS NULL OR \"item_stock_settings\".\"target_stock\" >= 0) AND (\"item_stock_settings\".\"overstock_days\" IS NULL OR \"item_stock_settings\".\"overstock_days\" BETWEEN 1 AND 365)" + } + }, + "isRLSEnabled": false + }, + "public.job_openings": { + "name": "job_openings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_kind": { + "name": "contract_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'cdi'" + }, + "weekly_hours": { + "name": "weekly_hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "start_wanted": { + "name": "start_wanted", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_openings_org_idx": { + "name": "job_openings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_openings_organization_id_organizations_id_fk": { + "name": "job_openings_organization_id_organizations_id_fk", + "tableFrom": "job_openings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_openings_establishment_id_establishments_id_fk": { + "name": "job_openings_establishment_id_establishments_id_fk", + "tableFrom": "job_openings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_openings_created_by_users_id_fk": { + "name": "job_openings_created_by_users_id_fk", + "tableFrom": "job_openings", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "job_openings_status_ck": { + "name": "job_openings_status_ck", + "value": "\"job_openings\".\"status\" IN ('ouvert', 'pourvu', 'ferme')" + }, + "job_openings_hours_ck": { + "name": "job_openings_hours_ck", + "value": "\"job_openings\".\"weekly_hours\" IS NULL OR (\"job_openings\".\"weekly_hours\" > 0 AND \"job_openings\".\"weekly_hours\" <= 48)" + } + }, + "isRLSEnabled": false + }, + "public.known_devices": { + "name": "known_devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_ip": { + "name": "last_ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "alerted_at": { + "name": "alerted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "known_devices_uq": { + "name": "known_devices_uq", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "known_devices_user_idx": { + "name": "known_devices_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_seen_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "known_devices_user_id_users_id_fk": { + "name": "known_devices_user_id_users_id_fk", + "tableFrom": "known_devices", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lead_activities": { + "name": "lead_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "lead_id": { + "name": "lead_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "lead_activities_lead_idx": { + "name": "lead_activities_lead_idx", + "columns": [ + { + "expression": "lead_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "lead_activities_organization_id_organizations_id_fk": { + "name": "lead_activities_organization_id_organizations_id_fk", + "tableFrom": "lead_activities", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lead_activities_lead_id_leads_id_fk": { + "name": "lead_activities_lead_id_leads_id_fk", + "tableFrom": "lead_activities", + "tableTo": "leads", + "columnsFrom": [ + "lead_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lead_activities_created_by_users_id_fk": { + "name": "lead_activities_created_by_users_id_fk", + "tableFrom": "lead_activities", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.leads": { + "name": "leads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_kind": { + "name": "event_kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "guests": { + "name": "guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "budget_ttc": { + "name": "budget_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "company": { + "name": "company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'nouveau'" + }, + "lost_reason": { + "name": "lost_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_action_on": { + "name": "next_action_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "next_action": { + "name": "next_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "set_menu_id": { + "name": "set_menu_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "leads_org_stage_idx": { + "name": "leads_org_stage_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stage", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_action_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "leads_est_idx": { + "name": "leads_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "leads_organization_id_organizations_id_fk": { + "name": "leads_organization_id_organizations_id_fk", + "tableFrom": "leads", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leads_establishment_id_establishments_id_fk": { + "name": "leads_establishment_id_establishments_id_fk", + "tableFrom": "leads", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "leads_customer_id_customers_id_fk": { + "name": "leads_customer_id_customers_id_fk", + "tableFrom": "leads", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_owner_user_id_users_id_fk": { + "name": "leads_owner_user_id_users_id_fk", + "tableFrom": "leads", + "tableTo": "users", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_set_menu_id_set_menus_id_fk": { + "name": "leads_set_menu_id_set_menus_id_fk", + "tableFrom": "leads", + "tableTo": "set_menus", + "columnsFrom": [ + "set_menu_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_created_by_users_id_fk": { + "name": "leads_created_by_users_id_fk", + "tableFrom": "leads", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leads_stage_ck": { + "name": "leads_stage_ck", + "value": "\"leads\".\"stage\" IN ('nouveau', 'contacte', 'devis', 'negociation', 'gagne', 'perdu')" + }, + "leads_guests_ck": { + "name": "leads_guests_ck", + "value": "\"leads\".\"guests\" IS NULL OR (\"leads\".\"guests\" > 0 AND \"leads\".\"guests\" <= 5000)" + }, + "leads_budget_ck": { + "name": "leads_budget_ck", + "value": "\"leads\".\"budget_ttc\" IS NULL OR \"leads\".\"budget_ttc\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.leave_adjustments": { + "name": "leave_adjustments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counter": { + "name": "counter", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "leave_adjustments_emp_idx": { + "name": "leave_adjustments_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "leave_adjustments_organization_id_organizations_id_fk": { + "name": "leave_adjustments_organization_id_organizations_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_adjustments_employee_id_employees_id_fk": { + "name": "leave_adjustments_employee_id_employees_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_adjustments_created_by_users_id_fk": { + "name": "leave_adjustments_created_by_users_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leave_adjustments_counter_ck": { + "name": "leave_adjustments_counter_ck", + "value": "\"leave_adjustments\".\"counter\" IN ('cp_n1', 'cp_n', 'rc')" + }, + "leave_adjustments_amount_ck": { + "name": "leave_adjustments_amount_ck", + "value": "\"leave_adjustments\".\"amount\" <> 0 AND abs(\"leave_adjustments\".\"amount\") <= 500" + } + }, + "isRLSEnabled": false + }, + "public.leave_settings": { + "name": "leave_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cp_unit": { + "name": "cp_unit", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvrables'" + }, + "overtime_as_rest": { + "name": "overtime_as_rest", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "leave_settings_establishment_id_establishments_id_fk": { + "name": "leave_settings_establishment_id_establishments_id_fk", + "tableFrom": "leave_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_settings_organization_id_organizations_id_fk": { + "name": "leave_settings_organization_id_organizations_id_fk", + "tableFrom": "leave_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_settings_updated_by_users_id_fk": { + "name": "leave_settings_updated_by_users_id_fk", + "tableFrom": "leave_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leave_settings_unit_ck": { + "name": "leave_settings_unit_ck", + "value": "\"leave_settings\".\"cp_unit\" IN ('ouvrables', 'ouvres')" + } + }, + "isRLSEnabled": false + }, + "public.logbook_entries": { + "name": "logbook_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "important": { + "name": "important", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "done_note": { + "name": "done_note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "logbook_entries_est_idx": { + "name": "logbook_entries_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "logbook_entries_organization_id_organizations_id_fk": { + "name": "logbook_entries_organization_id_organizations_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "logbook_entries_establishment_id_establishments_id_fk": { + "name": "logbook_entries_establishment_id_establishments_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "logbook_entries_author_id_users_id_fk": { + "name": "logbook_entries_author_id_users_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "logbook_entries_done_by_users_id_fk": { + "name": "logbook_entries_done_by_users_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "logbook_entries_category_ck": { + "name": "logbook_entries_category_ck", + "value": "\"logbook_entries\".\"category\" IN ('info', 'a_traiter', 'client', 'livraison', 'equipe')" + } + }, + "isRLSEnabled": false + }, + "public.logbook_reads": { + "name": "logbook_reads", + "schema": "", + "columns": { + "entry_id": { + "name": "entry_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "logbook_reads_entry_id_logbook_entries_id_fk": { + "name": "logbook_reads_entry_id_logbook_entries_id_fk", + "tableFrom": "logbook_reads", + "tableTo": "logbook_entries", + "columnsFrom": [ + "entry_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "logbook_reads_user_id_users_id_fk": { + "name": "logbook_reads_user_id_users_id_fk", + "tableFrom": "logbook_reads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "logbook_reads_entry_id_user_id_pk": { + "name": "logbook_reads_entry_id_user_id_pk", + "columns": [ + "entry_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.loyalty_events": { + "name": "loyalty_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visits": { + "name": "visits", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "loyalty_events_customer_idx": { + "name": "loyalty_events_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "loyalty_events_est_idx": { + "name": "loyalty_events_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "loyalty_events_organization_id_organizations_id_fk": { + "name": "loyalty_events_organization_id_organizations_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_establishment_id_establishments_id_fk": { + "name": "loyalty_events_establishment_id_establishments_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_customer_id_customers_id_fk": { + "name": "loyalty_events_customer_id_customers_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_created_by_users_id_fk": { + "name": "loyalty_events_created_by_users_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "loyalty_events_kind_ck": { + "name": "loyalty_events_kind_ck", + "value": "\"loyalty_events\".\"kind\" IN ('ajustement', 'recompense')" + }, + "loyalty_events_visits_ck": { + "name": "loyalty_events_visits_ck", + "value": "\"loyalty_events\".\"visits\" <> 0 AND (\"loyalty_events\".\"kind\" <> 'recompense' OR \"loyalty_events\".\"visits\" < 0)" + } + }, + "isRLSEnabled": false + }, + "public.loyalty_programs": { + "name": "loyalty_programs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "visits_per_reward": { + "name": "visits_per_reward", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reward_label": { + "name": "reward_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starts_on": { + "name": "starts_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "loyalty_programs_est_uq": { + "name": "loyalty_programs_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "loyalty_programs_org_idx": { + "name": "loyalty_programs_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "loyalty_programs_organization_id_organizations_id_fk": { + "name": "loyalty_programs_organization_id_organizations_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_programs_establishment_id_establishments_id_fk": { + "name": "loyalty_programs_establishment_id_establishments_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_programs_updated_by_users_id_fk": { + "name": "loyalty_programs_updated_by_users_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "loyalty_programs_visits_ck": { + "name": "loyalty_programs_visits_ck", + "value": "\"loyalty_programs\".\"visits_per_reward\" BETWEEN 2 AND 50" + } + }, + "isRLSEnabled": false + }, + "public.mail_accounts": { + "name": "mail_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gmail'" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'connected'" + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "cursor_ms": { + "name": "cursor_ms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_by": { + "name": "connected_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_accounts_email_uq": { + "name": "mail_accounts_email_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_accounts_organization_id_organizations_id_fk": { + "name": "mail_accounts_organization_id_organizations_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_accounts_establishment_id_establishments_id_fk": { + "name": "mail_accounts_establishment_id_establishments_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_accounts_connected_by_users_id_fk": { + "name": "mail_accounts_connected_by_users_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "users", + "columnsFrom": [ + "connected_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_accounts_provider_ck": { + "name": "mail_accounts_provider_ck", + "value": "\"mail_accounts\".\"provider\" IN ('gmail', 'outlook')" + }, + "mail_accounts_status_ck": { + "name": "mail_accounts_status_ck", + "value": "\"mail_accounts\".\"status\" IN ('connected', 'error', 'disabled')" + }, + "mail_accounts_failures_ck": { + "name": "mail_accounts_failures_ck", + "value": "\"mail_accounts\".\"consecutive_failures\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.mail_documents": { + "name": "mail_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "part_id": { + "name": "part_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_verifier'" + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "suggested_issue_id": { + "name": "suggested_issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "match_reason": { + "name": "match_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "business_document_id": { + "name": "business_document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "maintenance_invoice_id": { + "name": "maintenance_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_documents_part_uq": { + "name": "mail_documents_part_uq", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "part_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_documents_org_idx": { + "name": "mail_documents_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_documents_organization_id_organizations_id_fk": { + "name": "mail_documents_organization_id_organizations_id_fk", + "tableFrom": "mail_documents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_documents_message_id_mail_messages_id_fk": { + "name": "mail_documents_message_id_mail_messages_id_fk", + "tableFrom": "mail_documents", + "tableTo": "mail_messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_documents_establishment_id_establishments_id_fk": { + "name": "mail_documents_establishment_id_establishments_id_fk", + "tableFrom": "mail_documents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_supplier_id_suppliers_id_fk": { + "name": "mail_documents_supplier_id_suppliers_id_fk", + "tableFrom": "mail_documents", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_pennylane_record_id_pennylane_records_id_fk": { + "name": "mail_documents_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "mail_documents", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_suggested_issue_id_maintenance_issues_id_fk": { + "name": "mail_documents_suggested_issue_id_maintenance_issues_id_fk", + "tableFrom": "mail_documents", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "suggested_issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_business_document_id_business_documents_id_fk": { + "name": "mail_documents_business_document_id_business_documents_id_fk", + "tableFrom": "mail_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "business_document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_maintenance_invoice_id_maintenance_invoices_id_fk": { + "name": "mail_documents_maintenance_invoice_id_maintenance_invoices_id_fk", + "tableFrom": "mail_documents", + "tableTo": "maintenance_invoices", + "columnsFrom": [ + "maintenance_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_decided_by_users_id_fk": { + "name": "mail_documents_decided_by_users_id_fk", + "tableFrom": "mail_documents", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_documents_kind_ck": { + "name": "mail_documents_kind_ck", + "value": "\"mail_documents\".\"kind\" IN ('facture', 'devis', 'attestation', 'autre')" + }, + "mail_documents_status_ck": { + "name": "mail_documents_status_ck", + "value": "\"mail_documents\".\"status\" IN ('a_verifier', 'verifiee', 'classee', 'ignoree')" + }, + "mail_documents_size_ck": { + "name": "mail_documents_size_ck", + "value": "\"mail_documents\".\"size\" <= 4718592" + } + }, + "isRLSEnabled": false + }, + "public.mail_messages": { + "name": "mail_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_id": { + "name": "thread_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_email": { + "name": "from_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "to_text": { + "name": "to_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "attachment_count": { + "name": "attachment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_messages_ext_uq": { + "name": "mail_messages_ext_uq", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_messages_org_idx": { + "name": "mail_messages_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_messages_organization_id_organizations_id_fk": { + "name": "mail_messages_organization_id_organizations_id_fk", + "tableFrom": "mail_messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_messages_account_id_mail_accounts_id_fk": { + "name": "mail_messages_account_id_mail_accounts_id_fk", + "tableFrom": "mail_messages", + "tableTo": "mail_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_messages_category_ck": { + "name": "mail_messages_category_ck", + "value": "\"mail_messages\".\"category\" IN ('facture', 'devis', 'attestation', 'reservation', 'commande', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.mail_reply_drafts": { + "name": "mail_reply_drafts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_valider'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "outbox_id": { + "name": "outbox_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_reply_drafts_message_uq": { + "name": "mail_reply_drafts_message_uq", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_reply_drafts_org_idx": { + "name": "mail_reply_drafts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_reply_drafts_organization_id_organizations_id_fk": { + "name": "mail_reply_drafts_organization_id_organizations_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_account_id_mail_accounts_id_fk": { + "name": "mail_reply_drafts_account_id_mail_accounts_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_message_id_mail_messages_id_fk": { + "name": "mail_reply_drafts_message_id_mail_messages_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_template_id_mail_reply_templates_id_fk": { + "name": "mail_reply_drafts_template_id_mail_reply_templates_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_reply_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_reply_drafts_decided_by_users_id_fk": { + "name": "mail_reply_drafts_decided_by_users_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_reply_drafts_status_ck": { + "name": "mail_reply_drafts_status_ck", + "value": "\"mail_reply_drafts\".\"status\" IN ('a_valider', 'envoye', 'ecarte')" + } + }, + "isRLSEnabled": false + }, + "public.mail_reply_templates": { + "name": "mail_reply_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "mail_reply_templates_org_idx": { + "name": "mail_reply_templates_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_reply_templates_organization_id_organizations_id_fk": { + "name": "mail_reply_templates_organization_id_organizations_id_fk", + "tableFrom": "mail_reply_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_templates_created_by_users_id_fk": { + "name": "mail_reply_templates_created_by_users_id_fk", + "tableFrom": "mail_reply_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_reply_templates_category_ck": { + "name": "mail_reply_templates_category_ck", + "value": "\"mail_reply_templates\".\"category\" IN ('facture', 'devis', 'attestation', 'reservation', 'commande', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_interventions": { + "name": "maintenance_interventions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "performed_on": { + "name": "performed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cost_ht": { + "name": "cost_ht", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": false + }, + "invoice_ref": { + "name": "invoice_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_due_on": { + "name": "next_due_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_interventions_eq_idx": { + "name": "maintenance_interventions_eq_idx", + "columns": [ + { + "expression": "equipment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "performed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_interventions_organization_id_organizations_id_fk": { + "name": "maintenance_interventions_organization_id_organizations_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_interventions_establishment_id_establishments_id_fk": { + "name": "maintenance_interventions_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_equipment_id_equipment_id_fk": { + "name": "maintenance_interventions_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_interventions_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_recorded_by_users_id_fk": { + "name": "maintenance_interventions_recorded_by_users_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_interventions_cancelled_by_users_id_fk": { + "name": "maintenance_interventions_cancelled_by_users_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_interventions_kind_ck": { + "name": "maintenance_interventions_kind_ck", + "value": "\"maintenance_interventions\".\"kind\" IN ('preventive', 'curative', 'reglementaire')" + }, + "maintenance_interventions_cost_ck": { + "name": "maintenance_interventions_cost_ck", + "value": "\"maintenance_interventions\".\"cost_ht\" IS NULL OR \"maintenance_interventions\".\"cost_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_invoices": { + "name": "maintenance_invoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quote_id": { + "name": "quote_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'reparation'" + }, + "repairer": { + "name": "repairer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "document_mime": { + "name": "document_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_name": { + "name": "document_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "match_reason": { + "name": "match_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "linked_by": { + "name": "linked_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_invoices_est_idx": { + "name": "maintenance_invoices_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_invoices_issue_idx": { + "name": "maintenance_invoices_issue_idx", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_invoices_pennylane_uq": { + "name": "maintenance_invoices_pennylane_uq", + "columns": [ + { + "expression": "pennylane_record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"maintenance_invoices\".\"pennylane_record_id\" IS NOT NULL AND \"maintenance_invoices\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_invoices_organization_id_organizations_id_fk": { + "name": "maintenance_invoices_organization_id_organizations_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_invoices_establishment_id_establishments_id_fk": { + "name": "maintenance_invoices_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_equipment_id_equipment_id_fk": { + "name": "maintenance_invoices_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_invoices_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_quote_id_maintenance_quotes_id_fk": { + "name": "maintenance_invoices_quote_id_maintenance_quotes_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "maintenance_quotes", + "columnsFrom": [ + "quote_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_pennylane_record_id_pennylane_records_id_fk": { + "name": "maintenance_invoices_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_invoices_linked_by_users_id_fk": { + "name": "maintenance_invoices_linked_by_users_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "users", + "columnsFrom": [ + "linked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_invoices_cancelled_by_users_id_fk": { + "name": "maintenance_invoices_cancelled_by_users_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_invoices_source_ck": { + "name": "maintenance_invoices_source_ck", + "value": "\"maintenance_invoices\".\"source\" IN ('pennylane', 'document', 'saisie')" + }, + "maintenance_invoices_kind_ck": { + "name": "maintenance_invoices_kind_ck", + "value": "\"maintenance_invoices\".\"kind\" IN ('entretien', 'reparation', 'controle')" + }, + "maintenance_invoices_amount_ck": { + "name": "maintenance_invoices_amount_ck", + "value": "(\"maintenance_invoices\".\"amount_ht\" IS NOT NULL OR \"maintenance_invoices\".\"amount_ttc\" IS NOT NULL) AND (\"maintenance_invoices\".\"amount_ht\" IS NULL OR \"maintenance_invoices\".\"amount_ht\" >= 0) AND (\"maintenance_invoices\".\"amount_ttc\" IS NULL OR \"maintenance_invoices\".\"amount_ttc\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_issues": { + "name": "maintenance_issues", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "reported_by": { + "name": "reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reported_at": { + "name": "reported_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "resolved_at": { + "name": "resolved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "resolution": { + "name": "resolution", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_issues_est_idx": { + "name": "maintenance_issues_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_issues_organization_id_organizations_id_fk": { + "name": "maintenance_issues_organization_id_organizations_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_issues_establishment_id_establishments_id_fk": { + "name": "maintenance_issues_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_issues_equipment_id_equipment_id_fk": { + "name": "maintenance_issues_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_issues_reported_by_users_id_fk": { + "name": "maintenance_issues_reported_by_users_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "users", + "columnsFrom": [ + "reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_issues_resolved_by_users_id_fk": { + "name": "maintenance_issues_resolved_by_users_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "users", + "columnsFrom": [ + "resolved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_issues_severity_ck": { + "name": "maintenance_issues_severity_ck", + "value": "\"maintenance_issues\".\"severity\" IN ('bloquant', 'genant', 'mineur')" + }, + "maintenance_issues_status_ck": { + "name": "maintenance_issues_status_ck", + "value": "\"maintenance_issues\".\"status\" IN ('ouvert', 'en_cours', 'resolu')" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_quotes": { + "name": "maintenance_quotes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "repairer": { + "name": "repairer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quote_ref": { + "name": "quote_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "document_mime": { + "name": "document_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_name": { + "name": "document_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_valider'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_quotes_issue_idx": { + "name": "maintenance_quotes_issue_idx", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_quotes_est_idx": { + "name": "maintenance_quotes_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_quotes_one_valid_uq": { + "name": "maintenance_quotes_one_valid_uq", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"maintenance_quotes\".\"status\" = 'valide'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_quotes_organization_id_organizations_id_fk": { + "name": "maintenance_quotes_organization_id_organizations_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_quotes_establishment_id_establishments_id_fk": { + "name": "maintenance_quotes_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_quotes_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_quotes_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_quotes_decided_by_users_id_fk": { + "name": "maintenance_quotes_decided_by_users_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_quotes_created_by_users_id_fk": { + "name": "maintenance_quotes_created_by_users_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_quotes_status_ck": { + "name": "maintenance_quotes_status_ck", + "value": "\"maintenance_quotes\".\"status\" IN ('a_valider', 'valide', 'refuse')" + }, + "maintenance_quotes_amount_ck": { + "name": "maintenance_quotes_amount_ck", + "value": "(\"maintenance_quotes\".\"amount_ht\" IS NOT NULL OR \"maintenance_quotes\".\"amount_ttc\" IS NOT NULL) AND (\"maintenance_quotes\".\"amount_ht\" IS NULL OR \"maintenance_quotes\".\"amount_ht\" >= 0) AND (\"maintenance_quotes\".\"amount_ttc\" IS NULL OR \"maintenance_quotes\".\"amount_ttc\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.marketing_campaigns": { + "name": "marketing_campaigns", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "segment": { + "name": "segment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sms_text": { + "name": "sms_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "recipients_count": { + "name": "recipients_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "marketing_campaigns_org_idx": { + "name": "marketing_campaigns_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "marketing_campaigns_organization_id_organizations_id_fk": { + "name": "marketing_campaigns_organization_id_organizations_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "marketing_campaigns_establishment_id_establishments_id_fk": { + "name": "marketing_campaigns_establishment_id_establishments_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "marketing_campaigns_created_by_users_id_fk": { + "name": "marketing_campaigns_created_by_users_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "marketing_campaigns_status_ck": { + "name": "marketing_campaigns_status_ck", + "value": "\"marketing_campaigns\".\"status\" IN ('brouillon', 'envoyee')" + } + }, + "isRLSEnabled": false + }, + "public.media_assets": { + "name": "media_assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'upload'" + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_count": { + "name": "used_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "media_assets_org_idx": { + "name": "media_assets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_assets_recipe_idx": { + "name": "media_assets_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_assets_hash_uq": { + "name": "media_assets_hash_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "media_assets_organization_id_organizations_id_fk": { + "name": "media_assets_organization_id_organizations_id_fk", + "tableFrom": "media_assets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "media_assets_establishment_id_establishments_id_fk": { + "name": "media_assets_establishment_id_establishments_id_fk", + "tableFrom": "media_assets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "media_assets_recipe_id_recipes_id_fk": { + "name": "media_assets_recipe_id_recipes_id_fk", + "tableFrom": "media_assets", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "media_assets_created_by_users_id_fk": { + "name": "media_assets_created_by_users_id_fk", + "tableFrom": "media_assets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "media_assets_source_ck": { + "name": "media_assets_source_ck", + "value": "\"media_assets\".\"source\" IN ('upload', 'fiche', 'studio')" + }, + "media_assets_mime_ck": { + "name": "media_assets_mime_ck", + "value": "\"media_assets\".\"mime\" IN ('image/jpeg', 'image/png', 'image/webp')" + }, + "media_assets_size_ck": { + "name": "media_assets_size_ck", + "value": "\"media_assets\".\"size\" BETWEEN 1 AND 5242880" + }, + "media_assets_title_ck": { + "name": "media_assets_title_ck", + "value": "char_length(\"media_assets\".\"title\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + }, + "public.membership_establishments": { + "name": "membership_establishments", + "schema": "", + "columns": { + "membership_id": { + "name": "membership_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "membership_establishments_membership_id_memberships_id_fk": { + "name": "membership_establishments_membership_id_memberships_id_fk", + "tableFrom": "membership_establishments", + "tableTo": "memberships", + "columnsFrom": [ + "membership_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "membership_establishments_establishment_id_establishments_id_fk": { + "name": "membership_establishments_establishment_id_establishments_id_fk", + "tableFrom": "membership_establishments", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "membership_establishments_membership_id_establishment_id_pk": { + "name": "membership_establishments_membership_id_establishment_id_pk", + "columns": [ + "membership_id", + "establishment_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memberships": { + "name": "memberships", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "all_establishments": { + "name": "all_establishments", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "permissions_added": { + "name": "permissions_added", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "permissions_removed": { + "name": "permissions_removed", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "memberships_user_org_uq": { + "name": "memberships_user_org_uq", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memberships_user_id_users_id_fk": { + "name": "memberships_user_id_users_id_fk", + "tableFrom": "memberships", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memberships_organization_id_organizations_id_fk": { + "name": "memberships_organization_id_organizations_id_fk", + "tableFrom": "memberships", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "messages_conv_idx": { + "name": "messages_conv_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "messages_organization_id_organizations_id_fk": { + "name": "messages_organization_id_organizations_id_fk", + "tableFrom": "messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_conversation_id_conversations_id_fk": { + "name": "messages_conversation_id_conversations_id_fk", + "tableFrom": "messages", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_user_id_users_id_fk": { + "name": "messages_user_id_users_id_fk", + "tableFrom": "messages", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mfa_challenges": { + "name": "mfa_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mfa_challenges_user_idx": { + "name": "mfa_challenges_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mfa_challenges_user_id_users_id_fk": { + "name": "mfa_challenges_user_id_users_id_fk", + "tableFrom": "mfa_challenges", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.monthly_budgets": { + "name": "monthly_budgets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "month": { + "name": "month", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "revenue_ht": { + "name": "revenue_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "charges_ht": { + "name": "charges_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "food_cost_pct": { + "name": "food_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "beverage_cost_pct": { + "name": "beverage_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "labor_cost_pct": { + "name": "labor_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "monthly_budgets_est_month_uq": { + "name": "monthly_budgets_est_month_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "monthly_budgets_org_idx": { + "name": "monthly_budgets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "monthly_budgets_organization_id_organizations_id_fk": { + "name": "monthly_budgets_organization_id_organizations_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "monthly_budgets_establishment_id_establishments_id_fk": { + "name": "monthly_budgets_establishment_id_establishments_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "monthly_budgets_updated_by_users_id_fk": { + "name": "monthly_budgets_updated_by_users_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "monthly_budgets_month_ck": { + "name": "monthly_budgets_month_ck", + "value": "extract(day from \"monthly_budgets\".\"month\") = 1" + }, + "monthly_budgets_values_ck": { + "name": "monthly_budgets_values_ck", + "value": "(\"monthly_budgets\".\"revenue_ht\" IS NULL OR \"monthly_budgets\".\"revenue_ht\" >= 0) AND (\"monthly_budgets\".\"charges_ht\" IS NULL OR \"monthly_budgets\".\"charges_ht\" >= 0) AND (\"monthly_budgets\".\"covers\" IS NULL OR \"monthly_budgets\".\"covers\" >= 0)\n AND (\"monthly_budgets\".\"food_cost_pct\" IS NULL OR \"monthly_budgets\".\"food_cost_pct\" BETWEEN 0 AND 100) AND (\"monthly_budgets\".\"beverage_cost_pct\" IS NULL OR \"monthly_budgets\".\"beverage_cost_pct\" BETWEEN 0 AND 100) AND (\"monthly_budgets\".\"labor_cost_pct\" IS NULL OR \"monthly_budgets\".\"labor_cost_pct\" BETWEEN 0 AND 100)" + } + }, + "isRLSEnabled": false + }, + "public.notification_deliveries": { + "name": "notification_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "notification_id": { + "name": "notification_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_outbox_id": { + "name": "email_outbox_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "push_subscription_id": { + "name": "push_subscription_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_deliveries_org_idx": { + "name": "notification_deliveries_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_deliveries_user_idx": { + "name": "notification_deliveries_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_deliveries_pending_idx": { + "name": "notification_deliveries_pending_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_deliveries_organization_id_organizations_id_fk": { + "name": "notification_deliveries_organization_id_organizations_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_deliveries_user_id_users_id_fk": { + "name": "notification_deliveries_user_id_users_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_deliveries_notification_id_notifications_id_fk": { + "name": "notification_deliveries_notification_id_notifications_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "notifications", + "columnsFrom": [ + "notification_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "notification_deliveries_email_outbox_id_email_outbox_id_fk": { + "name": "notification_deliveries_email_outbox_id_email_outbox_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "email_outbox", + "columnsFrom": [ + "email_outbox_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "notification_deliveries_push_subscription_id_push_subscriptions_id_fk": { + "name": "notification_deliveries_push_subscription_id_push_subscriptions_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "push_subscriptions", + "columnsFrom": [ + "push_subscription_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_deliveries_channel_ck": { + "name": "notification_deliveries_channel_ck", + "value": "\"notification_deliveries\".\"channel\" IN ('in_app', 'email', 'push', 'sms')" + }, + "notification_deliveries_status_ck": { + "name": "notification_deliveries_status_ck", + "value": "\"notification_deliveries\".\"status\" IN ('envoye', 'en_attente', 'echec', 'simule', 'desactive', 'indisponible')" + } + }, + "isRLSEnabled": false + }, + "public.notification_preferences": { + "name": "notification_preferences", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notification_preferences_organization_id_organizations_id_fk": { + "name": "notification_preferences_organization_id_organizations_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_preferences_user_id_users_id_fk": { + "name": "notification_preferences_user_id_users_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "notification_preferences_organization_id_user_id_category_channel_pk": { + "name": "notification_preferences_organization_id_user_id_category_channel_pk", + "columns": [ + "organization_id", + "user_id", + "category", + "channel" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_preferences_channel_ck": { + "name": "notification_preferences_channel_ck", + "value": "\"notification_preferences\".\"channel\" IN ('in_app', 'email', 'push', 'sms')" + } + }, + "isRLSEnabled": false + }, + "public.notification_templates": { + "name": "notification_templates", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notification_templates_organization_id_organizations_id_fk": { + "name": "notification_templates_organization_id_organizations_id_fk", + "tableFrom": "notification_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_templates_updated_by_users_id_fk": { + "name": "notification_templates_updated_by_users_id_fk", + "tableFrom": "notification_templates", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "notification_templates_organization_id_category_channel_pk": { + "name": "notification_templates_organization_id_category_channel_pk", + "columns": [ + "organization_id", + "category", + "channel" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_templates_channel_ck": { + "name": "notification_templates_channel_ck", + "value": "\"notification_templates\".\"channel\" IN ('email', 'push', 'sms')" + } + }, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_user_idx": { + "name": "notifications_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_organization_id_organizations_id_fk": { + "name": "notifications_organization_id_organizations_id_fk", + "tableFrom": "notifications", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oil_checks": { + "name": "oil_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "polar_pct": { + "name": "polar_pct", + "type": "numeric(4, 1)", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "oil_checks_est_idx": { + "name": "oil_checks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oil_checks_organization_id_organizations_id_fk": { + "name": "oil_checks_organization_id_organizations_id_fk", + "tableFrom": "oil_checks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oil_checks_establishment_id_establishments_id_fk": { + "name": "oil_checks_establishment_id_establishments_id_fk", + "tableFrom": "oil_checks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "oil_checks_equipment_id_equipment_id_fk": { + "name": "oil_checks_equipment_id_equipment_id_fk", + "tableFrom": "oil_checks", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "oil_checks_recorded_by_users_id_fk": { + "name": "oil_checks_recorded_by_users_id_fk", + "tableFrom": "oil_checks", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "oil_checks_cancelled_by_users_id_fk": { + "name": "oil_checks_cancelled_by_users_id_fk", + "tableFrom": "oil_checks", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "oil_checks_kind_ck": { + "name": "oil_checks_kind_ck", + "value": "\"oil_checks\".\"kind\" IN ('controle', 'filtrage', 'changement')" + }, + "oil_checks_action_ck": { + "name": "oil_checks_action_ck", + "value": "\"oil_checks\".\"conform\" OR \"oil_checks\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.onboarding_items": { + "name": "onboarding_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "step_id": { + "name": "step_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "due_on": { + "name": "due_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "auto_check": { + "name": "auto_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "done_how": { + "name": "done_how", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_items_emp_idx": { + "name": "onboarding_items_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "onboarding_items_step_uq": { + "name": "onboarding_items_step_uq", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "step_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"onboarding_items\".\"step_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_items_organization_id_organizations_id_fk": { + "name": "onboarding_items_organization_id_organizations_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_items_employee_id_employees_id_fk": { + "name": "onboarding_items_employee_id_employees_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_items_step_id_onboarding_steps_id_fk": { + "name": "onboarding_items_step_id_onboarding_steps_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "onboarding_steps", + "columnsFrom": [ + "step_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "onboarding_items_done_by_users_id_fk": { + "name": "onboarding_items_done_by_users_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "onboarding_items_how_ck": { + "name": "onboarding_items_how_ck", + "value": "\"onboarding_items\".\"done_how\" IS NULL OR \"onboarding_items\".\"done_how\" IN ('manuel', 'auto')" + } + }, + "isRLSEnabled": false + }, + "public.onboarding_steps": { + "name": "onboarding_steps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "day_offset": { + "name": "day_offset", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "auto_check": { + "name": "auto_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_steps_org_idx": { + "name": "onboarding_steps_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_steps_organization_id_organizations_id_fk": { + "name": "onboarding_steps_organization_id_organizations_id_fk", + "tableFrom": "onboarding_steps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "onboarding_steps_offset_ck": { + "name": "onboarding_steps_offset_ck", + "value": "\"onboarding_steps\".\"day_offset\" BETWEEN -60 AND 365" + } + }, + "isRLSEnabled": false + }, + "public.organizations": { + "name": "organizations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_demo": { + "name": "is_demo", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "stock_valuation": { + "name": "stock_valuation", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'dernier_prix'" + }, + "require_mfa": { + "name": "require_mfa", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_via": { + "name": "created_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "onboarding_dismissed_at": { + "name": "onboarding_dismissed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "onboarding_skipped": { + "name": "onboarding_skipped", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "is_test": { + "name": "is_test", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "suspended_at": { + "name": "suspended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organizations_slug_unique": { + "name": "organizations_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": { + "organizations_stock_valuation_ck": { + "name": "organizations_stock_valuation_ck", + "value": "\"organizations\".\"stock_valuation\" IN ('dernier_prix', 'cump', 'fifo')" + }, + "organizations_demo_or_test_ck": { + "name": "organizations_demo_or_test_ck", + "value": "NOT (\"organizations\".\"is_demo\" AND \"organizations\".\"is_test\")" + } + }, + "isRLSEnabled": false + }, + "public.partner_booking_imports": { + "name": "partner_booking_imports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "partner": { + "name": "partner", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created": { + "name": "created", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated": { + "name": "updated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cancelled": { + "name": "cancelled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "unchanged": { + "name": "unchanged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skipped": { + "name": "skipped", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "notes": { + "name": "notes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "partner_booking_imports_est_idx": { + "name": "partner_booking_imports_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "partner_booking_imports_organization_id_organizations_id_fk": { + "name": "partner_booking_imports_organization_id_organizations_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "partner_booking_imports_establishment_id_establishments_id_fk": { + "name": "partner_booking_imports_establishment_id_establishments_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "partner_booking_imports_created_by_users_id_fk": { + "name": "partner_booking_imports_created_by_users_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "partner_booking_imports_partner_ck": { + "name": "partner_booking_imports_partner_ck", + "value": "\"partner_booking_imports\".\"partner\" IN ('thefork', 'opentable', 'google')" + }, + "partner_booking_imports_origin_ck": { + "name": "partner_booking_imports_origin_ck", + "value": "\"partner_booking_imports\".\"origin\" IN ('api', 'fichier', 'demo')" + } + }, + "isRLSEnabled": false + }, + "public.payroll_bonuses": { + "name": "payroll_bonuses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount_gross": { + "name": "amount_gross", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payroll_bonuses_est_date_idx": { + "name": "payroll_bonuses_est_date_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payroll_bonuses_org_idx": { + "name": "payroll_bonuses_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payroll_bonuses_organization_id_organizations_id_fk": { + "name": "payroll_bonuses_organization_id_organizations_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_establishment_id_establishments_id_fk": { + "name": "payroll_bonuses_establishment_id_establishments_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_employee_id_employees_id_fk": { + "name": "payroll_bonuses_employee_id_employees_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_created_by_users_id_fk": { + "name": "payroll_bonuses_created_by_users_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "payroll_bonuses_amount_ck": { + "name": "payroll_bonuses_amount_ck", + "value": "\"payroll_bonuses\".\"amount_gross\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.payroll_parameters": { + "name": "payroll_parameters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "effective_from": { + "name": "effective_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "employer_charge_pct": { + "name": "employer_charge_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "labor_alert_pct": { + "name": "labor_alert_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "source_note": { + "name": "source_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "min_productivity_ht": { + "name": "min_productivity_ht", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "meal_value": { + "name": "meal_value", + "type": "numeric(8, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payroll_parameters_est_from_uq": { + "name": "payroll_parameters_est_from_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payroll_parameters_org_idx": { + "name": "payroll_parameters_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payroll_parameters_organization_id_organizations_id_fk": { + "name": "payroll_parameters_organization_id_organizations_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_parameters_establishment_id_establishments_id_fk": { + "name": "payroll_parameters_establishment_id_establishments_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_parameters_created_by_users_id_fk": { + "name": "payroll_parameters_created_by_users_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "payroll_parameters_pct_ck": { + "name": "payroll_parameters_pct_ck", + "value": "(\"payroll_parameters\".\"employer_charge_pct\" IS NULL OR \"payroll_parameters\".\"employer_charge_pct\" BETWEEN 0 AND 100) AND (\"payroll_parameters\".\"labor_alert_pct\" IS NULL OR \"payroll_parameters\".\"labor_alert_pct\" BETWEEN 0 AND 100)" + }, + "payroll_parameters_prod_ck": { + "name": "payroll_parameters_prod_ck", + "value": "\"payroll_parameters\".\"min_productivity_ht\" IS NULL OR \"payroll_parameters\".\"min_productivity_ht\" > 0" + }, + "payroll_parameters_meal_ck": { + "name": "payroll_parameters_meal_ck", + "value": "\"payroll_parameters\".\"meal_value\" IS NULL OR \"payroll_parameters\".\"meal_value\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.pennylane_category_mappings": { + "name": "pennylane_category_mappings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category_key": { + "name": "category_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_category_mappings_uq": { + "name": "pennylane_category_mappings_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "category_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_category_mappings_organization_id_organizations_id_fk": { + "name": "pennylane_category_mappings_organization_id_organizations_id_fk", + "tableFrom": "pennylane_category_mappings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_category_mappings_updated_by_users_id_fk": { + "name": "pennylane_category_mappings_updated_by_users_id_fk", + "tableFrom": "pennylane_category_mappings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.pennylane_item_prices": { + "name": "pennylane_item_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "record_id": { + "name": "record_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "line_index": { + "name": "line_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_item_prices_line_uq": { + "name": "pennylane_item_prices_line_uq", + "columns": [ + { + "expression": "record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "line_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pennylane_item_prices_item_idx": { + "name": "pennylane_item_prices_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_item_prices_organization_id_organizations_id_fk": { + "name": "pennylane_item_prices_organization_id_organizations_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_establishment_id_establishments_id_fk": { + "name": "pennylane_item_prices_establishment_id_establishments_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_record_id_pennylane_records_id_fk": { + "name": "pennylane_item_prices_record_id_pennylane_records_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "pennylane_records", + "columnsFrom": [ + "record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_item_id_purchase_items_id_fk": { + "name": "pennylane_item_prices_item_id_purchase_items_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pennylane_item_prices_method_ck": { + "name": "pennylane_item_prices_method_ck", + "value": "\"pennylane_item_prices\".\"method\" IN ('confirme', 'reference', 'libelle')" + }, + "pennylane_item_prices_values_ck": { + "name": "pennylane_item_prices_values_ck", + "value": "\"pennylane_item_prices\".\"quantity\" > 0 AND \"pennylane_item_prices\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.pennylane_records": { + "name": "pennylane_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "third_party": { + "name": "third_party", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "remaining": { + "name": "remaining", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "payment_status": { + "name": "payment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unknown'" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tax": { + "name": "tax", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "bank_account_ref": { + "name": "bank_account_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "raw": { + "name": "raw", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "synced_at": { + "name": "synced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_records_uq": { + "name": "pennylane_records_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pennylane_records_date_idx": { + "name": "pennylane_records_date_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_records_organization_id_organizations_id_fk": { + "name": "pennylane_records_organization_id_organizations_id_fk", + "tableFrom": "pennylane_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_records_establishment_id_establishments_id_fk": { + "name": "pennylane_records_establishment_id_establishments_id_fk", + "tableFrom": "pennylane_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pennylane_records_kind_ck": { + "name": "pennylane_records_kind_ck", + "value": "\"pennylane_records\".\"kind\" IN ('supplier_invoice', 'customer_invoice', 'transaction', 'bank_account')" + } + }, + "isRLSEnabled": false + }, + "public.planning_absences": { + "name": "planning_absences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "part": { + "name": "part", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'journee'" + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_absences_uq": { + "name": "planning_absences_uq", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "part", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_absences_organization_id_organizations_id_fk": { + "name": "planning_absences_organization_id_organizations_id_fk", + "tableFrom": "planning_absences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_absences_employee_id_employees_id_fk": { + "name": "planning_absences_employee_id_employees_id_fk", + "tableFrom": "planning_absences", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_absences_created_by_users_id_fk": { + "name": "planning_absences_created_by_users_id_fk", + "tableFrom": "planning_absences", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_absences_part_ck": { + "name": "planning_absences_part_ck", + "value": "\"planning_absences\".\"part\" IN ('journee', 'matin', 'apres_midi')" + } + }, + "isRLSEnabled": false + }, + "public.planning_day_budgets": { + "name": "planning_day_budgets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "sales_ht": { + "name": "sales_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_day_budgets_uq": { + "name": "planning_day_budgets_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "planning_day_budgets_org_idx": { + "name": "planning_day_budgets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_day_budgets_organization_id_organizations_id_fk": { + "name": "planning_day_budgets_organization_id_organizations_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_budgets_establishment_id_establishments_id_fk": { + "name": "planning_day_budgets_establishment_id_establishments_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_budgets_updated_by_users_id_fk": { + "name": "planning_day_budgets_updated_by_users_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_day_budgets_ck": { + "name": "planning_day_budgets_ck", + "value": "\"planning_day_budgets\".\"sales_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.planning_day_notes": { + "name": "planning_day_notes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_day_notes_uq": { + "name": "planning_day_notes_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_day_notes_organization_id_organizations_id_fk": { + "name": "planning_day_notes_organization_id_organizations_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_notes_establishment_id_establishments_id_fk": { + "name": "planning_day_notes_establishment_id_establishments_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_notes_updated_by_users_id_fk": { + "name": "planning_day_notes_updated_by_users_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_day_notes_len_ck": { + "name": "planning_day_notes_len_ck", + "value": "char_length(\"planning_day_notes\".\"text\") BETWEEN 1 AND 500" + } + }, + "isRLSEnabled": false + }, + "public.planning_weeks": { + "name": "planning_weeks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "week_start": { + "name": "week_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_by": { + "name": "published_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "changed_at": { + "name": "changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sales_forecast_ht": { + "name": "sales_forecast_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "hours_budget": { + "name": "hours_budget", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": false + }, + "published_teams": { + "name": "published_teams", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "published_pdf": { + "name": "published_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_weeks_uq": { + "name": "planning_weeks_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "week_start", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_weeks_organization_id_organizations_id_fk": { + "name": "planning_weeks_organization_id_organizations_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_weeks_establishment_id_establishments_id_fk": { + "name": "planning_weeks_establishment_id_establishments_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_weeks_published_by_users_id_fk": { + "name": "planning_weeks_published_by_users_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "users", + "columnsFrom": [ + "published_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_settings": { + "name": "platform_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "default": 1 + }, + "signup_open": { + "name": "signup_open", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "mail_organization_id": { + "name": "mail_organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "vapid_public_key": { + "name": "vapid_public_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vapid_private_enc": { + "name": "vapid_private_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "platform_settings_mail_organization_id_organizations_id_fk": { + "name": "platform_settings_mail_organization_id_organizations_id_fk", + "tableFrom": "platform_settings", + "tableTo": "organizations", + "columnsFrom": [ + "mail_organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "platform_settings_updated_by_users_id_fk": { + "name": "platform_settings_updated_by_users_id_fk", + "tableFrom": "platform_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "platform_settings_single_ck": { + "name": "platform_settings_single_ck", + "value": "\"platform_settings\".\"id\" = 1" + } + }, + "isRLSEnabled": false + }, + "public.posting_records": { + "name": "posting_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "values": { + "name": "values", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installed_on": { + "name": "installed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_size": { + "name": "photo_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "validated_by_name": { + "name": "validated_by_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "posting_records_uq": { + "name": "posting_records_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "posting_records_org_idx": { + "name": "posting_records_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "posting_records_organization_id_organizations_id_fk": { + "name": "posting_records_organization_id_organizations_id_fk", + "tableFrom": "posting_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "posting_records_establishment_id_establishments_id_fk": { + "name": "posting_records_establishment_id_establishments_id_fk", + "tableFrom": "posting_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "posting_records_validated_by_users_id_fk": { + "name": "posting_records_validated_by_users_id_fk", + "tableFrom": "posting_records", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "posting_records_updated_by_users_id_fk": { + "name": "posting_records_updated_by_users_id_fk", + "tableFrom": "posting_records", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "posting_records_photo_ck": { + "name": "posting_records_photo_ck", + "value": "(\"posting_records\".\"photo\" IS NULL) = (\"posting_records\".\"photo_mime\" IS NULL) AND (\"posting_records\".\"photo\" IS NULL OR \"posting_records\".\"photo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + }, + "posting_records_validation_ck": { + "name": "posting_records_validation_ck", + "value": "(\"posting_records\".\"validated_at\" IS NULL) = (\"posting_records\".\"validated_by_name\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.price_request_lines": { + "name": "price_request_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "price_request_lines_item_uq": { + "name": "price_request_lines_item_uq", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_lines_organization_id_organizations_id_fk": { + "name": "price_request_lines_organization_id_organizations_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_lines_request_id_price_requests_id_fk": { + "name": "price_request_lines_request_id_price_requests_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "price_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_lines_item_id_purchase_items_id_fk": { + "name": "price_request_lines_item_id_purchase_items_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_lines_amount_ck": { + "name": "price_request_lines_amount_ck", + "value": "\"price_request_lines\".\"amount\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.price_request_offers": { + "name": "price_request_offers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_supplier_id": { + "name": "request_supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "line_id": { + "name": "line_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "awarded": { + "name": "awarded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_request_offers_uq": { + "name": "price_request_offers_uq", + "columns": [ + { + "expression": "request_supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "line_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_offers_organization_id_organizations_id_fk": { + "name": "price_request_offers_organization_id_organizations_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_offers_request_supplier_id_price_request_suppliers_id_fk": { + "name": "price_request_offers_request_supplier_id_price_request_suppliers_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "price_request_suppliers", + "columnsFrom": [ + "request_supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_offers_line_id_price_request_lines_id_fk": { + "name": "price_request_offers_line_id_price_request_lines_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "price_request_lines", + "columnsFrom": [ + "line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_offers_price_ck": { + "name": "price_request_offers_price_ck", + "value": "\"price_request_offers\".\"unit_price_ht\" IS NULL OR \"price_request_offers\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.price_request_suppliers": { + "name": "price_request_suppliers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emailed": { + "name": "emailed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "answered_at": { + "name": "answered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "answered_via": { + "name": "answered_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answered_name": { + "name": "answered_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answer_note": { + "name": "answer_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_request_suppliers_uq": { + "name": "price_request_suppliers_uq", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "price_request_suppliers_token_uq": { + "name": "price_request_suppliers_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_suppliers_organization_id_organizations_id_fk": { + "name": "price_request_suppliers_organization_id_organizations_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_suppliers_request_id_price_requests_id_fk": { + "name": "price_request_suppliers_request_id_price_requests_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "price_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_suppliers_supplier_id_suppliers_id_fk": { + "name": "price_request_suppliers_supplier_id_suppliers_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_suppliers_via_ck": { + "name": "price_request_suppliers_via_ck", + "value": "\"price_request_suppliers\".\"answered_via\" IS NULL OR \"price_request_suppliers\".\"answered_via\" IN ('en_ligne', 'saisie')" + } + }, + "isRLSEnabled": false + }, + "public.price_requests": { + "name": "price_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_by": { + "name": "reply_by", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "needed_by": { + "name": "needed_by", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "awarded_at": { + "name": "awarded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_requests_number_uq": { + "name": "price_requests_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "price_requests_est_idx": { + "name": "price_requests_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_requests_organization_id_organizations_id_fk": { + "name": "price_requests_organization_id_organizations_id_fk", + "tableFrom": "price_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_requests_establishment_id_establishments_id_fk": { + "name": "price_requests_establishment_id_establishments_id_fk", + "tableFrom": "price_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "price_requests_created_by_users_id_fk": { + "name": "price_requests_created_by_users_id_fk", + "tableFrom": "price_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_requests_status_ck": { + "name": "price_requests_status_ck", + "value": "\"price_requests\".\"status\" IN ('brouillon', 'envoyee', 'attribuee', 'annulee')" + } + }, + "isRLSEnabled": false + }, + "public.privacy_requests": { + "name": "privacy_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_kind": { + "name": "subject_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_label": { + "name": "subject_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_type": { + "name": "request_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "target_on": { + "name": "target_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'recue'" + }, + "responded_on": { + "name": "responded_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "handled_by": { + "name": "handled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "privacy_requests_org_idx": { + "name": "privacy_requests_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "privacy_requests_organization_id_organizations_id_fk": { + "name": "privacy_requests_organization_id_organizations_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "privacy_requests_establishment_id_establishments_id_fk": { + "name": "privacy_requests_establishment_id_establishments_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "privacy_requests_employee_id_employees_id_fk": { + "name": "privacy_requests_employee_id_employees_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_customer_id_customers_id_fk": { + "name": "privacy_requests_customer_id_customers_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_handled_by_users_id_fk": { + "name": "privacy_requests_handled_by_users_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "users", + "columnsFrom": [ + "handled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_created_by_users_id_fk": { + "name": "privacy_requests_created_by_users_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "privacy_requests_kind_ck": { + "name": "privacy_requests_kind_ck", + "value": "\"privacy_requests\".\"subject_kind\" IN ('salarie', 'client', 'autre')" + }, + "privacy_requests_type_ck": { + "name": "privacy_requests_type_ck", + "value": "\"privacy_requests\".\"request_type\" IN ('acces', 'rectification', 'effacement', 'opposition')" + }, + "privacy_requests_channel_ck": { + "name": "privacy_requests_channel_ck", + "value": "\"privacy_requests\".\"channel\" IN ('email', 'courrier', 'oral', 'sur_place', 'autre')" + }, + "privacy_requests_status_ck": { + "name": "privacy_requests_status_ck", + "value": "\"privacy_requests\".\"status\" IN ('recue', 'en_cours', 'traitee', 'refusee', 'sans_suite')" + }, + "privacy_requests_done_ck": { + "name": "privacy_requests_done_ck", + "value": "\"privacy_requests\".\"status\" NOT IN ('traitee', 'refusee') OR \"privacy_requests\".\"responded_on\" IS NOT NULL" + }, + "privacy_requests_refused_ck": { + "name": "privacy_requests_refused_ck", + "value": "\"privacy_requests\".\"status\" <> 'refusee' OR \"privacy_requests\".\"outcome\" IS NOT NULL" + }, + "privacy_requests_dates_ck": { + "name": "privacy_requests_dates_ck", + "value": "\"privacy_requests\".\"responded_on\" IS NULL OR \"privacy_requests\".\"responded_on\" >= \"privacy_requests\".\"received_on\"" + } + }, + "isRLSEnabled": false + }, + "public.product_temperatures": { + "name": "product_temperatures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_at": { + "name": "start_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "start_temp": { + "name": "start_temp", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": true + }, + "end_at": { + "name": "end_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "end_temp": { + "name": "end_temp", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "completed_by": { + "name": "completed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "product_temperatures_est_idx": { + "name": "product_temperatures_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "start_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "product_temperatures_organization_id_organizations_id_fk": { + "name": "product_temperatures_organization_id_organizations_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_temperatures_establishment_id_establishments_id_fk": { + "name": "product_temperatures_establishment_id_establishments_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "product_temperatures_recorded_by_users_id_fk": { + "name": "product_temperatures_recorded_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_temperatures_completed_by_users_id_fk": { + "name": "product_temperatures_completed_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "completed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_temperatures_cancelled_by_users_id_fk": { + "name": "product_temperatures_cancelled_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "product_temperatures_kind_ck": { + "name": "product_temperatures_kind_ck", + "value": "\"product_temperatures\".\"kind\" IN ('refroidissement', 'remise_en_temperature', 'coeur_chaud', 'coeur_froid')" + }, + "product_temperatures_status_ck": { + "name": "product_temperatures_status_ck", + "value": "\"product_temperatures\".\"status\" IN ('en_cours', 'termine')" + }, + "product_temperatures_action_ck": { + "name": "product_temperatures_action_ck", + "value": "\"product_temperatures\".\"conform\" IS NOT FALSE OR \"product_temperatures\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.purchase_control_settings": { + "name": "purchase_control_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rise_threshold_pct": { + "name": "rise_threshold_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "rise_window_days": { + "name": "rise_window_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "reception_tolerance_pct": { + "name": "reception_tolerance_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_control_settings_org_uq": { + "name": "purchase_control_settings_org_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_control_settings\".\"establishment_id\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_control_settings_est_uq": { + "name": "purchase_control_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_control_settings\".\"establishment_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_control_settings_organization_id_organizations_id_fk": { + "name": "purchase_control_settings_organization_id_organizations_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_control_settings_establishment_id_establishments_id_fk": { + "name": "purchase_control_settings_establishment_id_establishments_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_control_settings_updated_by_users_id_fk": { + "name": "purchase_control_settings_updated_by_users_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_control_settings_ck": { + "name": "purchase_control_settings_ck", + "value": "(\"purchase_control_settings\".\"rise_threshold_pct\" IS NULL OR (\"purchase_control_settings\".\"rise_threshold_pct\" > 0 AND \"purchase_control_settings\".\"rise_threshold_pct\" <= 100)) AND (\"purchase_control_settings\".\"rise_window_days\" IS NULL OR \"purchase_control_settings\".\"rise_window_days\" BETWEEN 7 AND 365) AND (\"purchase_control_settings\".\"reception_tolerance_pct\" IS NULL OR (\"purchase_control_settings\".\"reception_tolerance_pct\" >= 0 AND \"purchase_control_settings\".\"reception_tolerance_pct\" <= 50))" + } + }, + "isRLSEnabled": false + }, + "public.purchase_invoice_lines": { + "name": "purchase_invoice_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "line_ht": { + "name": "line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_lines_invoice_idx": { + "name": "purchase_lines_invoice_idx", + "columns": [ + { + "expression": "invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_lines_item_idx": { + "name": "purchase_lines_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_invoice_lines_organization_id_organizations_id_fk": { + "name": "purchase_invoice_lines_organization_id_organizations_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoice_lines_invoice_id_purchase_invoices_id_fk": { + "name": "purchase_invoice_lines_invoice_id_purchase_invoices_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoice_lines_item_id_purchase_items_id_fk": { + "name": "purchase_invoice_lines_item_id_purchase_items_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_lines_qty_ck": { + "name": "purchase_lines_qty_ck", + "value": "\"purchase_invoice_lines\".\"quantity\" > 0" + }, + "purchase_lines_price_ck": { + "name": "purchase_lines_price_ck", + "value": "\"purchase_invoice_lines\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.purchase_invoices": { + "name": "purchase_invoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'invoice'" + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_vat": { + "name": "total_vat", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "printed_ttc": { + "name": "printed_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "credit_request_id": { + "name": "credit_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paid_at": { + "name": "paid_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_invoices_period_idx": { + "name": "purchase_invoices_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_number_uq": { + "name": "purchase_invoices_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"invoice_number\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_credit_request_uq": { + "name": "purchase_invoices_credit_request_uq", + "columns": [ + { + "expression": "credit_request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL AND \"purchase_invoices\".\"credit_request_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_order_uq": { + "name": "purchase_invoices_order_uq", + "columns": [ + { + "expression": "purchase_order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL AND \"purchase_invoices\".\"kind\" = 'invoice' AND \"purchase_invoices\".\"purchase_order_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_invoices_organization_id_organizations_id_fk": { + "name": "purchase_invoices_organization_id_organizations_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoices_establishment_id_establishments_id_fk": { + "name": "purchase_invoices_establishment_id_establishments_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_supplier_id_suppliers_id_fk": { + "name": "purchase_invoices_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_purchase_order_id_purchase_orders_id_fk": { + "name": "purchase_invoices_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_credit_request_id_credit_requests_id_fk": { + "name": "purchase_invoices_credit_request_id_credit_requests_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "credit_requests", + "columnsFrom": [ + "credit_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_created_by_users_id_fk": { + "name": "purchase_invoices_created_by_users_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_invoices_cancelled_by_users_id_fk": { + "name": "purchase_invoices_cancelled_by_users_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_invoices_kind_ck": { + "name": "purchase_invoices_kind_ck", + "value": "\"purchase_invoices\".\"kind\" IN ('invoice', 'credit_note')" + }, + "purchase_invoices_ttc_ck": { + "name": "purchase_invoices_ttc_ck", + "value": "\"purchase_invoices\".\"total_ttc\" = \"purchase_invoices\".\"total_ht\" + \"purchase_invoices\".\"total_vat\"" + }, + "purchase_invoices_due_ck": { + "name": "purchase_invoices_due_ck", + "value": "\"purchase_invoices\".\"due_date\" IS NULL OR \"purchase_invoices\".\"due_date\" >= \"purchase_invoices\".\"invoice_date\"" + } + }, + "isRLSEnabled": false + }, + "public.purchase_items": { + "name": "purchase_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "storage_zone": { + "name": "storage_zone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "default_supplier_id": { + "name": "default_supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_ref": { + "name": "supplier_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "barcode": { + "name": "barcode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "catalog_price_ht": { + "name": "catalog_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "catalog_price_date": { + "name": "catalog_price_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_items_org_idx": { + "name": "purchase_items_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_items_org_name_unit_uq": { + "name": "purchase_items_org_name_unit_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "unit", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_items_org_barcode_uq": { + "name": "purchase_items_org_barcode_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "barcode", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_items\".\"barcode\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_items_organization_id_organizations_id_fk": { + "name": "purchase_items_organization_id_organizations_id_fk", + "tableFrom": "purchase_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_items_default_supplier_id_suppliers_id_fk": { + "name": "purchase_items_default_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_items", + "tableTo": "suppliers", + "columnsFrom": [ + "default_supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_items_pack_ck": { + "name": "purchase_items_pack_ck", + "value": "\"purchase_items\".\"pack_size\" IS NULL OR \"purchase_items\".\"pack_size\" > 0" + }, + "purchase_items_catalog_ck": { + "name": "purchase_items_catalog_ck", + "value": "\"purchase_items\".\"catalog_price_ht\" IS NULL OR \"purchase_items\".\"catalog_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.purchase_order_groups": { + "name": "purchase_order_groups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expected_date": { + "name": "expected_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_order_groups_number_uq": { + "name": "purchase_order_groups_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_order_groups_organization_id_organizations_id_fk": { + "name": "purchase_order_groups_organization_id_organizations_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_groups_supplier_id_suppliers_id_fk": { + "name": "purchase_order_groups_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_order_groups_created_by_users_id_fk": { + "name": "purchase_order_groups_created_by_users_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_order_groups_status_ck": { + "name": "purchase_order_groups_status_ck", + "value": "\"purchase_order_groups\".\"status\" IN ('draft', 'sent', 'cancelled')" + } + }, + "isRLSEnabled": false + }, + "public.purchase_order_lines": { + "name": "purchase_order_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "packs": { + "name": "packs", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "line_ht": { + "name": "line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "received_quantity": { + "name": "received_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "received_unit_price_ht": { + "name": "received_unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "received_line_ht": { + "name": "received_line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "reception_note": { + "name": "reception_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_order_lines_order_idx": { + "name": "purchase_order_lines_order_idx", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_order_lines_item_uq": { + "name": "purchase_order_lines_item_uq", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_order_lines_organization_id_organizations_id_fk": { + "name": "purchase_order_lines_organization_id_organizations_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_lines_order_id_purchase_orders_id_fk": { + "name": "purchase_order_lines_order_id_purchase_orders_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "purchase_orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_lines_item_id_purchase_items_id_fk": { + "name": "purchase_order_lines_item_id_purchase_items_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_order_lines_qty_ck": { + "name": "purchase_order_lines_qty_ck", + "value": "\"purchase_order_lines\".\"quantity\" > 0 AND \"purchase_order_lines\".\"unit_price_ht\" >= 0 AND (\"purchase_order_lines\".\"received_quantity\" IS NULL OR \"purchase_order_lines\".\"received_quantity\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.purchase_orders": { + "name": "purchase_orders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "expected_date": { + "name": "expected_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines_ht": { + "name": "lines_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "delivery_fee_ht": { + "name": "delivery_fee_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "ordered_at": { + "name": "ordered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "received_date": { + "name": "received_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "received_time": { + "name": "received_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "delivery_note_number": { + "name": "delivery_note_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplier_gaps_ack_at": { + "name": "supplier_gaps_ack_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "supplier_gaps_ack_by": { + "name": "supplier_gaps_ack_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "received_ht": { + "name": "received_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "reception_comment": { + "name": "reception_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_by": { + "name": "received_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_request_id": { + "name": "price_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_orders_group_idx": { + "name": "purchase_orders_group_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_orders_est_idx": { + "name": "purchase_orders_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_orders_number_uq": { + "name": "purchase_orders_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_orders_organization_id_organizations_id_fk": { + "name": "purchase_orders_organization_id_organizations_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_orders_establishment_id_establishments_id_fk": { + "name": "purchase_orders_establishment_id_establishments_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_supplier_id_suppliers_id_fk": { + "name": "purchase_orders_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_supplier_gaps_ack_by_users_id_fk": { + "name": "purchase_orders_supplier_gaps_ack_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "supplier_gaps_ack_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_orders_received_by_users_id_fk": { + "name": "purchase_orders_received_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "received_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_orders_price_request_id_price_requests_id_fk": { + "name": "purchase_orders_price_request_id_price_requests_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "price_requests", + "columnsFrom": [ + "price_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_group_id_purchase_order_groups_id_fk": { + "name": "purchase_orders_group_id_purchase_order_groups_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "purchase_order_groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_created_by_users_id_fk": { + "name": "purchase_orders_created_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_orders_status_ck": { + "name": "purchase_orders_status_ck", + "value": "\"purchase_orders\".\"status\" IN ('draft', 'sent', 'confirmed', 'received', 'cancelled')" + }, + "purchase_orders_time_ck": { + "name": "purchase_orders_time_ck", + "value": "\"purchase_orders\".\"received_time\" IS NULL OR \"purchase_orders\".\"received_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + } + }, + "isRLSEnabled": false + }, + "public.push_subscriptions": { + "name": "push_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Appareil'" + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "push_subscriptions_endpoint_uq": { + "name": "push_subscriptions_endpoint_uq", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "push_subscriptions_user_idx": { + "name": "push_subscriptions_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "push_subscriptions_organization_id_organizations_id_fk": { + "name": "push_subscriptions_organization_id_organizations_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.quotes": { + "name": "quotes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_kind": { + "name": "event_kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_time": { + "name": "event_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "guests": { + "name": "guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "client_name": { + "name": "client_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_company": { + "name": "client_company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_email": { + "name": "client_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_phone": { + "name": "client_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_address": { + "name": "client_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "issued_on": { + "name": "issued_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_vat": { + "name": "total_vat", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "deposit_percent": { + "name": "deposit_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "deposit_amount": { + "name": "deposit_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "deposit_received_on": { + "name": "deposit_received_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "terms": { + "name": "terms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "viewed_at": { + "name": "viewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_name": { + "name": "accepted_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_via": { + "name": "accepted_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_meta": { + "name": "accepted_meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "refused_reason": { + "name": "refused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lead_id": { + "name": "lead_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "quotes_number_uq": { + "name": "quotes_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "quotes_token_uq": { + "name": "quotes_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"quotes\".\"token_hash\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "quotes_org_idx": { + "name": "quotes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "quotes_organization_id_organizations_id_fk": { + "name": "quotes_organization_id_organizations_id_fk", + "tableFrom": "quotes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "quotes_establishment_id_establishments_id_fk": { + "name": "quotes_establishment_id_establishments_id_fk", + "tableFrom": "quotes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "quotes_customer_id_customers_id_fk": { + "name": "quotes_customer_id_customers_id_fk", + "tableFrom": "quotes", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_reservation_id_reservations_id_fk": { + "name": "quotes_reservation_id_reservations_id_fk", + "tableFrom": "quotes", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_lead_id_leads_id_fk": { + "name": "quotes_lead_id_leads_id_fk", + "tableFrom": "quotes", + "tableTo": "leads", + "columnsFrom": [ + "lead_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_created_by_users_id_fk": { + "name": "quotes_created_by_users_id_fk", + "tableFrom": "quotes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "quotes_status_ck": { + "name": "quotes_status_ck", + "value": "\"quotes\".\"status\" IN ('brouillon', 'envoye', 'accepte', 'refuse', 'annule')" + }, + "quotes_valid_ck": { + "name": "quotes_valid_ck", + "value": "\"quotes\".\"valid_until\" >= \"quotes\".\"issued_on\"" + }, + "quotes_guests_ck": { + "name": "quotes_guests_ck", + "value": "\"quotes\".\"guests\" IS NULL OR \"quotes\".\"guests\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reception_control_lines": { + "name": "reception_control_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "control_id": { + "name": "control_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "stock_lot_id": { + "name": "stock_lot_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "packaging_ok": { + "name": "packaging_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "label_ok": { + "name": "label_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "reception_control_lines_ctl_idx": { + "name": "reception_control_lines_ctl_idx", + "columns": [ + { + "expression": "control_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reception_control_lines_organization_id_organizations_id_fk": { + "name": "reception_control_lines_organization_id_organizations_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_control_lines_control_id_reception_controls_id_fk": { + "name": "reception_control_lines_control_id_reception_controls_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "reception_controls", + "columnsFrom": [ + "control_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_control_lines_item_id_purchase_items_id_fk": { + "name": "reception_control_lines_item_id_purchase_items_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reception_control_lines_stock_lot_id_stock_expiry_lots_id_fk": { + "name": "reception_control_lines_stock_lot_id_stock_expiry_lots_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "stock_expiry_lots", + "columnsFrom": [ + "stock_lot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reception_controls": { + "name": "reception_controls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delivery_note": { + "name": "delivery_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "truck_temperature": { + "name": "truck_temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "vehicle_clean": { + "name": "vehicle_clean", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "decision": { + "name": "decision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reception_controls_est_idx": { + "name": "reception_controls_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reception_controls_organization_id_organizations_id_fk": { + "name": "reception_controls_organization_id_organizations_id_fk", + "tableFrom": "reception_controls", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_controls_establishment_id_establishments_id_fk": { + "name": "reception_controls_establishment_id_establishments_id_fk", + "tableFrom": "reception_controls", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reception_controls_supplier_id_suppliers_id_fk": { + "name": "reception_controls_supplier_id_suppliers_id_fk", + "tableFrom": "reception_controls", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reception_controls_purchase_order_id_purchase_orders_id_fk": { + "name": "reception_controls_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "reception_controls", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reception_controls_recorded_by_users_id_fk": { + "name": "reception_controls_recorded_by_users_id_fk", + "tableFrom": "reception_controls", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reception_controls_cancelled_by_users_id_fk": { + "name": "reception_controls_cancelled_by_users_id_fk", + "tableFrom": "reception_controls", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reception_controls_decision_ck": { + "name": "reception_controls_decision_ck", + "value": "\"reception_controls\".\"decision\" IN ('accepte', 'accepte_reserve', 'refuse')" + }, + "reception_controls_action_ck": { + "name": "reception_controls_action_ck", + "value": "\"reception_controls\".\"conform\" OR \"reception_controls\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.recipe_lines": { + "name": "recipe_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sub_recipe_id": { + "name": "sub_recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "waste_pct": { + "name": "waste_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_lines_recipe_idx": { + "name": "recipe_lines_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_lines_sub_idx": { + "name": "recipe_lines_sub_idx", + "columns": [ + { + "expression": "sub_recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_lines_organization_id_organizations_id_fk": { + "name": "recipe_lines_organization_id_organizations_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_lines_recipe_id_recipes_id_fk": { + "name": "recipe_lines_recipe_id_recipes_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_lines_item_id_purchase_items_id_fk": { + "name": "recipe_lines_item_id_purchase_items_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "recipe_lines_sub_recipe_id_recipes_id_fk": { + "name": "recipe_lines_sub_recipe_id_recipes_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "recipes", + "columnsFrom": [ + "sub_recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipe_lines_waste_ck": { + "name": "recipe_lines_waste_ck", + "value": "\"recipe_lines\".\"waste_pct\" IS NULL OR (\"recipe_lines\".\"waste_pct\" >= 0 AND \"recipe_lines\".\"waste_pct\" < 100)" + }, + "recipe_lines_qty_ck": { + "name": "recipe_lines_qty_ck", + "value": "\"recipe_lines\".\"quantity\" > 0" + }, + "recipe_lines_source_ck": { + "name": "recipe_lines_source_ck", + "value": "(\"recipe_lines\".\"item_id\" IS NULL) <> (\"recipe_lines\".\"sub_recipe_id\" IS NULL)" + }, + "recipe_lines_self_ck": { + "name": "recipe_lines_self_ck", + "value": "\"recipe_lines\".\"sub_recipe_id\" IS NULL OR \"recipe_lines\".\"sub_recipe_id\" <> \"recipe_lines\".\"recipe_id\"" + } + }, + "isRLSEnabled": false + }, + "public.recipe_versions": { + "name": "recipe_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "effective_from": { + "name": "effective_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "yield_quantity": { + "name": "yield_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "yield_unit": { + "name": "yield_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_versions_no_uq": { + "name": "recipe_versions_no_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_from_uq": { + "name": "recipe_versions_from_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_origin_uq": { + "name": "recipe_versions_origin_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"recipe_versions\".\"effective_from\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_org_idx": { + "name": "recipe_versions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_versions_organization_id_organizations_id_fk": { + "name": "recipe_versions_organization_id_organizations_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_versions_recipe_id_recipes_id_fk": { + "name": "recipe_versions_recipe_id_recipes_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_versions_created_by_users_id_fk": { + "name": "recipe_versions_created_by_users_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipe_versions_ck": { + "name": "recipe_versions_ck", + "value": "\"recipe_versions\".\"version\" >= 1 AND \"recipe_versions\".\"portions\" > 0 AND ((\"recipe_versions\".\"version\" = 1) = (\"recipe_versions\".\"effective_from\" IS NULL))" + } + }, + "isRLSEnabled": false + }, + "public.recipes": { + "name": "recipes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "course": { + "name": "course", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'plat'" + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'1'" + }, + "selling_price_ttc": { + "name": "selling_price_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.10'" + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "yield_quantity": { + "name": "yield_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "yield_unit": { + "name": "yield_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "target_margin_pct": { + "name": "target_margin_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "portion_weight_g": { + "name": "portion_weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "quality_tolerance_pct": { + "name": "quality_tolerance_pct", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "plating_standard": { + "name": "plating_standard", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipes_org_idx": { + "name": "recipes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipes_org_name_uq": { + "name": "recipes_org_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipes_organization_id_organizations_id_fk": { + "name": "recipes_organization_id_organizations_id_fk", + "tableFrom": "recipes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipes_created_by_users_id_fk": { + "name": "recipes_created_by_users_id_fk", + "tableFrom": "recipes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipes_portions_ck": { + "name": "recipes_portions_ck", + "value": "\"recipes\".\"portions\" > 0" + }, + "recipes_yield_ck": { + "name": "recipes_yield_ck", + "value": "(\"recipes\".\"yield_quantity\" IS NULL AND \"recipes\".\"yield_unit\" IS NULL) OR (\"recipes\".\"yield_quantity\" > 0 AND \"recipes\".\"yield_unit\" IS NOT NULL)" + }, + "recipes_margin_ck": { + "name": "recipes_margin_ck", + "value": "\"recipes\".\"target_margin_pct\" IS NULL OR (\"recipes\".\"target_margin_pct\" >= 0 AND \"recipes\".\"target_margin_pct\" < 100)" + }, + "recipes_quality_ck": { + "name": "recipes_quality_ck", + "value": "(\"recipes\".\"portion_weight_g\" IS NULL OR \"recipes\".\"portion_weight_g\" BETWEEN 1 AND 20000) AND (\"recipes\".\"quality_tolerance_pct\" IS NULL OR \"recipes\".\"quality_tolerance_pct\" BETWEEN 1 AND 50)" + } + }, + "isRLSEnabled": false + }, + "public.recovery_codes": { + "name": "recovery_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recovery_codes_user_idx": { + "name": "recovery_codes_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recovery_codes_user_id_users_id_fk": { + "name": "recovery_codes_user_id_users_id_fk", + "tableFrom": "recovery_codes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.register_entries": { + "name": "register_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "topic": { + "name": "topic", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "organism": { + "name": "organism", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "performed_on": { + "name": "performed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "next_due_on": { + "name": "next_due_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "participants": { + "name": "participants", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "observations": { + "name": "observations", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'saisie'" + }, + "source_ref": { + "name": "source_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "register_entries_est_idx": { + "name": "register_entries_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "performed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "register_entries_source_uq": { + "name": "register_entries_source_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"register_entries\".\"source_ref\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "register_entries_organization_id_organizations_id_fk": { + "name": "register_entries_organization_id_organizations_id_fk", + "tableFrom": "register_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "register_entries_establishment_id_establishments_id_fk": { + "name": "register_entries_establishment_id_establishments_id_fk", + "tableFrom": "register_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "register_entries_employee_id_employees_id_fk": { + "name": "register_entries_employee_id_employees_id_fk", + "tableFrom": "register_entries", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_supplier_id_suppliers_id_fk": { + "name": "register_entries_supplier_id_suppliers_id_fk", + "tableFrom": "register_entries", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_document_id_business_documents_id_fk": { + "name": "register_entries_document_id_business_documents_id_fk", + "tableFrom": "register_entries", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_created_by_users_id_fk": { + "name": "register_entries_created_by_users_id_fk", + "tableFrom": "register_entries", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "register_entries_cancelled_by_users_id_fk": { + "name": "register_entries_cancelled_by_users_id_fk", + "tableFrom": "register_entries", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "register_entries_kind_ck": { + "name": "register_entries_kind_ck", + "value": "\"register_entries\".\"kind\" IN ('epi', 'exercice_incendie', 'controle', 'vigilance')" + }, + "register_entries_result_ck": { + "name": "register_entries_result_ck", + "value": "\"register_entries\".\"result\" IS NULL OR \"register_entries\".\"result\" IN ('conforme', 'reserves', 'non_conforme')" + }, + "register_entries_source_ck": { + "name": "register_entries_source_ck", + "value": "\"register_entries\".\"source\" IN ('saisie', 'document')" + }, + "register_entries_due_ck": { + "name": "register_entries_due_ck", + "value": "\"register_entries\".\"next_due_on\" IS NULL OR \"register_entries\".\"next_due_on\" >= \"register_entries\".\"performed_on\"" + }, + "register_entries_counts_ck": { + "name": "register_entries_counts_ck", + "value": "(\"register_entries\".\"quantity\" IS NULL OR \"register_entries\".\"quantity\" BETWEEN 1 AND 1000) AND (\"register_entries\".\"participants\" IS NULL OR \"register_entries\".\"participants\" BETWEEN 0 AND 10000) AND (\"register_entries\".\"duration_minutes\" IS NULL OR \"register_entries\".\"duration_minutes\" BETWEEN 1 AND 1440)" + }, + "register_entries_cancel_ck": { + "name": "register_entries_cancel_ck", + "value": "\"register_entries\".\"cancelled_at\" IS NULL OR (\"register_entries\".\"cancelled_by\" IS NOT NULL AND \"register_entries\".\"cancel_reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.regulatory_obligations": { + "name": "regulatory_obligations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "applicability": { + "name": "applicability", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source_status": { + "name": "source_status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_reference": { + "name": "source_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference_origin": { + "name": "reference_origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "catalogued_on": { + "name": "catalogued_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "verified_at": { + "name": "verified_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "validation_status": { + "name": "validation_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'non_validee'" + }, + "validator_name": { + "name": "validator_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validator_quality": { + "name": "validator_quality", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validated_on": { + "name": "validated_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "legal_delay_text": { + "name": "legal_delay_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hr_check": { + "name": "hr_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "regulatory_obligations_code_uq": { + "name": "regulatory_obligations_code_uq", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "regulatory_obligations_domain_ck": { + "name": "regulatory_obligations_domain_ck", + "value": "\"regulatory_obligations\".\"domain\" IN ('hygiene', 'social', 'securite', 'fiscal', 'affichage', 'licences', 'consommateurs', 'environnement', 'donnees_personnelles')" + }, + "regulatory_obligations_source_ck": { + "name": "regulatory_obligations_source_ck", + "value": "\"regulatory_obligations\".\"source_status\" IN ('documentee', 'a_documenter') AND (\"regulatory_obligations\".\"source_status\" = 'a_documenter' OR \"regulatory_obligations\".\"source_reference\" IS NOT NULL)" + }, + "regulatory_obligations_validation_ck": { + "name": "regulatory_obligations_validation_ck", + "value": "\"regulatory_obligations\".\"validation_status\" IN ('non_validee', 'validee_par_professionnel') AND (\"regulatory_obligations\".\"validation_status\" = 'non_validee' OR (\"regulatory_obligations\".\"validator_name\" IS NOT NULL AND \"regulatory_obligations\".\"validator_quality\" IS NOT NULL AND \"regulatory_obligations\".\"validated_on\" IS NOT NULL))" + }, + "regulatory_obligations_active_ck": { + "name": "regulatory_obligations_active_ck", + "value": "NOT \"regulatory_obligations\".\"active\" OR (\"regulatory_obligations\".\"validation_status\" = 'validee_par_professionnel' AND \"regulatory_obligations\".\"source_status\" = 'documentee' AND \"regulatory_obligations\".\"source_url\" IS NOT NULL AND \"regulatory_obligations\".\"verified_at\" IS NOT NULL)" + }, + "regulatory_obligations_hr_ck": { + "name": "regulatory_obligations_hr_ck", + "value": "\"regulatory_obligations\".\"hr_check\" IS NULL OR \"regulatory_obligations\".\"hr_check\" IN ('work_permit', 'medical_visit', 'dpae')" + } + }, + "isRLSEnabled": false + }, + "public.report_schedules": { + "name": "report_schedules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gestion'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Rapport de gestion'" + }, + "send_time": { + "name": "send_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'07:00'" + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "attach_pdf": { + "name": "attach_pdf", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notify_in_app": { + "name": "notify_in_app", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "recipients": { + "name": "recipients", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "last_period_from": { + "name": "last_period_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "last_sent_at": { + "name": "last_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "indicators": { + "name": "indicators", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "send_condition": { + "name": "send_condition", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "report_schedules_org_idx": { + "name": "report_schedules_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "report_schedules_organization_id_organizations_id_fk": { + "name": "report_schedules_organization_id_organizations_id_fk", + "tableFrom": "report_schedules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_schedules_establishment_id_establishments_id_fk": { + "name": "report_schedules_establishment_id_establishments_id_fk", + "tableFrom": "report_schedules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_schedules_created_by_users_id_fk": { + "name": "report_schedules_created_by_users_id_fk", + "tableFrom": "report_schedules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "report_schedules_audience_ck": { + "name": "report_schedules_audience_ck", + "value": "\"report_schedules\".\"audience\" IS NULL OR \"report_schedules\".\"audience\" IN ('proprietaire', 'direction', 'comptable', 'equipe', 'cuisine')" + }, + "report_schedules_freq_ck": { + "name": "report_schedules_freq_ck", + "value": "\"report_schedules\".\"frequency\" IN ('daily', 'weekly', 'monthly')" + }, + "report_schedules_time_ck": { + "name": "report_schedules_time_ck", + "value": "\"report_schedules\".\"send_time\" ~ '^(0[5-9]|1[0-9]|2[0-2]):(00|15|30|45)$'" + }, + "report_schedules_days_ck": { + "name": "report_schedules_days_ck", + "value": "\"report_schedules\".\"frequency\" <> 'daily' OR (CASE WHEN jsonb_typeof(\"report_schedules\".\"weekdays\") = 'array' THEN jsonb_array_length(\"report_schedules\".\"weekdays\") >= 1 ELSE false END)" + }, + "report_schedules_kind_ck": { + "name": "report_schedules_kind_ck", + "value": "\"report_schedules\".\"kind\" IN ('gestion', 'fermeture', 'groupe')" + }, + "report_schedules_closing_ck": { + "name": "report_schedules_closing_ck", + "value": "\"report_schedules\".\"kind\" <> 'fermeture' OR (\"report_schedules\".\"frequency\" = 'daily' AND \"report_schedules\".\"establishment_id\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.reputation_policies": { + "name": "reputation_policies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "levels": { + "name": "levels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "forbidden_words": { + "name": "forbidden_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "email_alerts": { + "name": "email_alerts", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "escalate_to": { + "name": "escalate_to", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reputation_policies_org_uq": { + "name": "reputation_policies_org_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reputation_policies\".\"establishment_id\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "reputation_policies_est_uq": { + "name": "reputation_policies_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reputation_policies\".\"establishment_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reputation_policies_organization_id_organizations_id_fk": { + "name": "reputation_policies_organization_id_organizations_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_policies_establishment_id_establishments_id_fk": { + "name": "reputation_policies_establishment_id_establishments_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_policies_escalate_to_users_id_fk": { + "name": "reputation_policies_escalate_to_users_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "users", + "columnsFrom": [ + "escalate_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reputation_policies_updated_by_users_id_fk": { + "name": "reputation_policies_updated_by_users_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reputation_policies_tone_ck": { + "name": "reputation_policies_tone_ck", + "value": "\"reputation_policies\".\"tone\" IS NULL OR \"reputation_policies\".\"tone\" IN ('formel', 'chaleureux', 'sobre')" + }, + "reputation_policies_lang_ck": { + "name": "reputation_policies_lang_ck", + "value": "\"reputation_policies\".\"language\" IS NULL OR \"reputation_policies\".\"language\" IN ('fr', 'en')" + } + }, + "isRLSEnabled": false + }, + "public.reputation_settings": { + "name": "reputation_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "review_url": { + "name": "review_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signature": { + "name": "signature", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reputation_settings_establishment_id_establishments_id_fk": { + "name": "reputation_settings_establishment_id_establishments_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_settings_organization_id_organizations_id_fk": { + "name": "reputation_settings_organization_id_organizations_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_settings_updated_by_users_id_fk": { + "name": "reputation_settings_updated_by_users_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reservation_exceptions": { + "name": "reservation_exceptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "service_id": { + "name": "service_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed": { + "name": "closed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "service_capacity": { + "name": "service_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_exceptions_day_idx": { + "name": "reservation_exceptions_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_exceptions_organization_id_organizations_id_fk": { + "name": "reservation_exceptions_organization_id_organizations_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_exceptions_establishment_id_establishments_id_fk": { + "name": "reservation_exceptions_establishment_id_establishments_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservation_exceptions_service_id_reservation_services_id_fk": { + "name": "reservation_exceptions_service_id_reservation_services_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "reservation_services", + "columnsFrom": [ + "service_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_exceptions_created_by_users_id_fk": { + "name": "reservation_exceptions_created_by_users_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_exceptions_cap_ck": { + "name": "reservation_exceptions_cap_ck", + "value": "\"reservation_exceptions\".\"closed\" OR \"reservation_exceptions\".\"service_capacity\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reservation_services": { + "name": "reservation_services", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "first_time": { + "name": "first_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_time": { + "name": "last_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slot_minutes": { + "name": "slot_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "slot_capacity": { + "name": "slot_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "service_capacity": { + "name": "service_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_services_est_idx": { + "name": "reservation_services_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_services_organization_id_organizations_id_fk": { + "name": "reservation_services_organization_id_organizations_id_fk", + "tableFrom": "reservation_services", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_services_establishment_id_establishments_id_fk": { + "name": "reservation_services_establishment_id_establishments_id_fk", + "tableFrom": "reservation_services", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_services_time_ck": { + "name": "reservation_services_time_ck", + "value": "\"reservation_services\".\"first_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_services\".\"last_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "reservation_services_slot_ck": { + "name": "reservation_services_slot_ck", + "value": "\"reservation_services\".\"slot_minutes\" IN (15, 30, 60) AND \"reservation_services\".\"duration_minutes\" BETWEEN 15 AND 720" + }, + "reservation_services_cap_ck": { + "name": "reservation_services_cap_ck", + "value": "(\"reservation_services\".\"slot_capacity\" IS NULL OR \"reservation_services\".\"slot_capacity\" > 0) AND (\"reservation_services\".\"service_capacity\" IS NULL OR \"reservation_services\".\"service_capacity\" > 0)" + } + }, + "isRLSEnabled": false + }, + "public.reservation_settings": { + "name": "reservation_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reminder_email": { + "name": "reminder_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reminder_hour": { + "name": "reminder_hour", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "online_enabled": { + "name": "online_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "online_token": { + "name": "online_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "online_by": { + "name": "online_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "online_max_covers": { + "name": "online_max_covers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 8 + }, + "waitlist_auto_offer": { + "name": "waitlist_auto_offer", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "online_auto_confirm": { + "name": "online_auto_confirm", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "online_lead_minutes": { + "name": "online_lead_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "online_days": { + "name": "online_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 60 + }, + "online_message": { + "name": "online_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "online_groups": { + "name": "online_groups", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_settings_online_token_uq": { + "name": "reservation_settings_online_token_uq", + "columns": [ + { + "expression": "online_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_settings_establishment_id_establishments_id_fk": { + "name": "reservation_settings_establishment_id_establishments_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_settings_organization_id_organizations_id_fk": { + "name": "reservation_settings_organization_id_organizations_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_settings_online_by_users_id_fk": { + "name": "reservation_settings_online_by_users_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "users", + "columnsFrom": [ + "online_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_settings_hour_ck": { + "name": "reservation_settings_hour_ck", + "value": "\"reservation_settings\".\"reminder_hour\" BETWEEN 7 AND 21" + }, + "reservation_settings_online_ck": { + "name": "reservation_settings_online_ck", + "value": "\"reservation_settings\".\"online_max_covers\" BETWEEN 1 AND 50 AND \"reservation_settings\".\"online_lead_minutes\" BETWEEN 0 AND 2880 AND \"reservation_settings\".\"online_days\" BETWEEN 1 AND 365" + } + }, + "isRLSEnabled": false + }, + "public.reservation_tables": { + "name": "reservation_tables", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "starts_at": { + "name": "starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ends_at": { + "name": "ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "released_at": { + "name": "released_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_tables_res_idx": { + "name": "reservation_tables_res_idx", + "columns": [ + { + "expression": "reservation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservation_tables_table_idx": { + "name": "reservation_tables_table_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "starts_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_tables_organization_id_organizations_id_fk": { + "name": "reservation_tables_organization_id_organizations_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_tables_establishment_id_establishments_id_fk": { + "name": "reservation_tables_establishment_id_establishments_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservation_tables_reservation_id_reservations_id_fk": { + "name": "reservation_tables_reservation_id_reservations_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_tables_table_id_floor_items_id_fk": { + "name": "reservation_tables_table_id_floor_items_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "floor_items", + "columnsFrom": [ + "table_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_tables_range_ck": { + "name": "reservation_tables_range_ck", + "value": "\"reservation_tables\".\"ends_at\" > \"reservation_tables\".\"starts_at\"" + } + }, + "isRLSEnabled": false + }, + "public.reservation_waitlist": { + "name": "reservation_waitlist", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "time_from": { + "name": "time_from", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "time_to": { + "name": "time_to", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "offered_at": { + "name": "offered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "offered_from_reservation_id": { + "name": "offered_from_reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "offered_time": { + "name": "offered_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "close_reason": { + "name": "close_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_waitlist_day_idx": { + "name": "reservation_waitlist_day_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_waitlist_organization_id_organizations_id_fk": { + "name": "reservation_waitlist_organization_id_organizations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_waitlist_establishment_id_establishments_id_fk": { + "name": "reservation_waitlist_establishment_id_establishments_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_waitlist_offered_from_reservation_id_reservations_id_fk": { + "name": "reservation_waitlist_offered_from_reservation_id_reservations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "reservations", + "columnsFrom": [ + "offered_from_reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservation_waitlist_reservation_id_reservations_id_fk": { + "name": "reservation_waitlist_reservation_id_reservations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservation_waitlist_created_by_users_id_fk": { + "name": "reservation_waitlist_created_by_users_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_waitlist_status_ck": { + "name": "reservation_waitlist_status_ck", + "value": "\"reservation_waitlist\".\"status\" IN ('en_attente', 'proposee', 'convertie', 'annulee')" + }, + "reservation_waitlist_covers_ck": { + "name": "reservation_waitlist_covers_ck", + "value": "\"reservation_waitlist\".\"covers\" BETWEEN 1 AND 500" + }, + "reservation_waitlist_time_ck": { + "name": "reservation_waitlist_time_ck", + "value": "\"reservation_waitlist\".\"time_from\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_waitlist\".\"time_to\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_waitlist\".\"time_to\" >= \"reservation_waitlist\".\"time_from\"" + }, + "reservation_waitlist_contact_ck": { + "name": "reservation_waitlist_contact_ck", + "value": "\"reservation_waitlist\".\"phone\" IS NOT NULL OR \"reservation_waitlist\".\"email\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.reservations": { + "name": "reservations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "service_id": { + "name": "service_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "time": { + "name": "time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starts_at": { + "name": "starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ends_at": { + "name": "ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'confirmee'" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'telephone'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request": { + "name": "request", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "arrived_at": { + "name": "arrived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "confirmation_sent_at": { + "name": "confirmation_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reminder_sent_at": { + "name": "reminder_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "external_ref": { + "name": "external_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservations_day_idx": { + "name": "reservations_day_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_customer_idx": { + "name": "reservations_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_external_ref_uq": { + "name": "reservations_external_ref_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reservations\".\"external_ref\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservations_organization_id_organizations_id_fk": { + "name": "reservations_organization_id_organizations_id_fk", + "tableFrom": "reservations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservations_establishment_id_establishments_id_fk": { + "name": "reservations_establishment_id_establishments_id_fk", + "tableFrom": "reservations", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservations_service_id_reservation_services_id_fk": { + "name": "reservations_service_id_reservation_services_id_fk", + "tableFrom": "reservations", + "tableTo": "reservation_services", + "columnsFrom": [ + "service_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservations_customer_id_customers_id_fk": { + "name": "reservations_customer_id_customers_id_fk", + "tableFrom": "reservations", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservations_created_by_users_id_fk": { + "name": "reservations_created_by_users_id_fk", + "tableFrom": "reservations", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservations_status_ck": { + "name": "reservations_status_ck", + "value": "\"reservations\".\"status\" IN ('en_attente', 'confirmee', 'arrivee', 'terminee', 'no_show', 'annulee')" + }, + "reservations_covers_ck": { + "name": "reservations_covers_ck", + "value": "\"reservations\".\"covers\" BETWEEN 1 AND 500" + }, + "reservations_time_ck": { + "name": "reservations_time_ck", + "value": "\"reservations\".\"time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservations\".\"ends_at\" > \"reservations\".\"starts_at\"" + } + }, + "isRLSEnabled": false + }, + "public.review_autopublish": { + "name": "review_autopublish", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "levels": { + "name": "levels", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled_by": { + "name": "enabled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "enabled_at": { + "name": "enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmation": { + "name": "confirmation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "review_autopublish_establishment_id_establishments_id_fk": { + "name": "review_autopublish_establishment_id_establishments_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_autopublish_organization_id_organizations_id_fk": { + "name": "review_autopublish_organization_id_organizations_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_autopublish_enabled_by_users_id_fk": { + "name": "review_autopublish_enabled_by_users_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "users", + "columnsFrom": [ + "enabled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "review_autopublish_updated_by_users_id_fk": { + "name": "review_autopublish_updated_by_users_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.review_publications": { + "name": "review_publications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "review_id": { + "name": "review_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blocked_words": { + "name": "blocked_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "google_reply_state": { + "name": "google_reply_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "review_publications_review_uq": { + "name": "review_publications_review_uq", + "columns": [ + { + "expression": "review_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "review_publications_due_idx": { + "name": "review_publications_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "review_publications_organization_id_organizations_id_fk": { + "name": "review_publications_organization_id_organizations_id_fk", + "tableFrom": "review_publications", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_publications_establishment_id_establishments_id_fk": { + "name": "review_publications_establishment_id_establishments_id_fk", + "tableFrom": "review_publications", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_publications_review_id_reviews_id_fk": { + "name": "review_publications_review_id_reviews_id_fk", + "tableFrom": "review_publications", + "tableTo": "reviews", + "columnsFrom": [ + "review_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "review_publications_status_ck": { + "name": "review_publications_status_ck", + "value": "\"review_publications\".\"status\" IN ('scheduled', 'publishing', 'published', 'failed', 'blocked', 'cancelled', 'skipped')" + } + }, + "isRLSEnabled": false + }, + "public.reviews": { + "name": "reviews", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reviewed_on": { + "name": "reviewed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fingerprint": { + "name": "fingerprint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_text": { + "name": "reply_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "replied_at": { + "name": "replied_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "replied_by": { + "name": "replied_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assigned_to": { + "name": "assigned_to", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "assigned_by": { + "name": "assigned_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rule_action": { + "name": "rule_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "alerted_at": { + "name": "alerted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_name": { + "name": "external_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_updated_at": { + "name": "external_updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reply_origin": { + "name": "reply_origin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reviews_fingerprint_uq": { + "name": "reviews_fingerprint_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "fingerprint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_external_uq": { + "name": "reviews_external_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reviews\".\"external_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_est_day_idx": { + "name": "reviews_est_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reviewed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_assigned_idx": { + "name": "reviews_assigned_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "assigned_to", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"reviews\".\"assigned_to\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reviews_organization_id_organizations_id_fk": { + "name": "reviews_organization_id_organizations_id_fk", + "tableFrom": "reviews", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reviews_establishment_id_establishments_id_fk": { + "name": "reviews_establishment_id_establishments_id_fk", + "tableFrom": "reviews", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reviews_replied_by_users_id_fk": { + "name": "reviews_replied_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "replied_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reviews_assigned_to_users_id_fk": { + "name": "reviews_assigned_to_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "assigned_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reviews_assigned_by_users_id_fk": { + "name": "reviews_assigned_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "assigned_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reviews_created_by_users_id_fk": { + "name": "reviews_created_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reviews_reply_origin_ck": { + "name": "reviews_reply_origin_ck", + "value": "\"reviews\".\"reply_origin\" IS NULL OR \"reviews\".\"reply_origin\" IN ('manuel', 'google', 'auto')" + }, + "reviews_rating_ck": { + "name": "reviews_rating_ck", + "value": "\"reviews\".\"rating\" BETWEEN 1 AND 5" + }, + "reviews_source_ck": { + "name": "reviews_source_ck", + "value": "\"reviews\".\"source\" IN ('google', 'tripadvisor', 'thefork', 'facebook', 'direct', 'autre')" + }, + "reviews_rule_action_ck": { + "name": "reviews_rule_action_ck", + "value": "\"reviews\".\"rule_action\" IS NULL OR \"reviews\".\"rule_action\" IN ('remercier', 'remercier_inviter', 'demander_retour', 'transmettre', 'alerte')" + } + }, + "isRLSEnabled": false + }, + "public.sales_challenges": { + "name": "sales_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'perso'" + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keywords": { + "name": "keywords", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "from_day": { + "name": "from_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "to_day": { + "name": "to_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "rewards": { + "name": "rewards", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "target_value": { + "name": "target_value", + "type": "numeric(14, 3)", + "primaryKey": false, + "notNull": false + }, + "results": { + "name": "results", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_challenges_org_idx": { + "name": "sales_challenges_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_challenges_organization_id_organizations_id_fk": { + "name": "sales_challenges_organization_id_organizations_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_challenges_establishment_id_establishments_id_fk": { + "name": "sales_challenges_establishment_id_establishments_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_challenges_created_by_users_id_fk": { + "name": "sales_challenges_created_by_users_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_challenges_metric_ck": { + "name": "sales_challenges_metric_ck", + "value": "\"sales_challenges\".\"metric\" IN ('quantite', 'ca_ht', 'ca_heure')" + }, + "sales_challenges_range_ck": { + "name": "sales_challenges_range_ck", + "value": "\"sales_challenges\".\"to_day\" >= \"sales_challenges\".\"from_day\" AND \"sales_challenges\".\"to_day\" - \"sales_challenges\".\"from_day\" <= 366" + }, + "sales_challenges_target_ck": { + "name": "sales_challenges_target_ck", + "value": "\"sales_challenges\".\"target_value\" IS NULL OR \"sales_challenges\".\"target_value\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.sales_entries": { + "name": "sales_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "batch_id": { + "name": "batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_date": { + "name": "business_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "ticket_ref": { + "name": "ticket_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "payment_method": { + "name": "payment_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "format_version": { + "name": "format_version", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "line_ref": { + "name": "line_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sold_time": { + "name": "sold_time", + "type": "time", + "primaryKey": false, + "notNull": false + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "product": { + "name": "product", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(12, 3)", + "primaryKey": false, + "notNull": false + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "table_label": { + "name": "table_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discount_ttc": { + "name": "discount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "comp_ttc": { + "name": "comp_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "product_code": { + "name": "product_code", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sales_entries_row_uq": { + "name": "sales_entries_row_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_entries_period_idx": { + "name": "sales_entries_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_entries_ticket_idx": { + "name": "sales_entries_ticket_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ticket_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_entries_organization_id_organizations_id_fk": { + "name": "sales_entries_organization_id_organizations_id_fk", + "tableFrom": "sales_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_entries_establishment_id_establishments_id_fk": { + "name": "sales_entries_establishment_id_establishments_id_fk", + "tableFrom": "sales_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_entries_batch_id_sales_import_batches_id_fk": { + "name": "sales_entries_batch_id_sales_import_batches_id_fk", + "tableFrom": "sales_entries", + "tableTo": "sales_import_batches", + "columnsFrom": [ + "batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_ttc_consistency_ck": { + "name": "sales_ttc_consistency_ck", + "value": "\"sales_entries\".\"amount_ttc\" = \"sales_entries\".\"amount_ht\" + \"sales_entries\".\"vat_amount\"" + }, + "sales_format_version_ck": { + "name": "sales_format_version_ck", + "value": "\"sales_entries\".\"format_version\" IN (1, 2)" + }, + "sales_channel_ck": { + "name": "sales_channel_ck", + "value": "\"sales_entries\".\"channel\" IS NULL OR \"sales_entries\".\"channel\" IN ('sur_place', 'emporter', 'livraison', 'click_collect', 'autre')" + }, + "sales_discount_ck": { + "name": "sales_discount_ck", + "value": "\"sales_entries\".\"discount_ttc\" IS NULL OR \"sales_entries\".\"discount_ttc\" >= 0" + }, + "sales_comp_ck": { + "name": "sales_comp_ck", + "value": "\"sales_entries\".\"comp_ttc\" IS NULL OR \"sales_entries\".\"comp_ttc\" >= 0" + }, + "sales_quantity_ck": { + "name": "sales_quantity_ck", + "value": "\"sales_entries\".\"quantity\" IS NULL OR \"sales_entries\".\"quantity\" <> 0" + } + }, + "isRLSEnabled": false + }, + "public.sales_families": { + "name": "sales_families", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_families_name_uq": { + "name": "sales_families_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_families_organization_id_organizations_id_fk": { + "name": "sales_families_organization_id_organizations_id_fk", + "tableFrom": "sales_families", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_families_created_by_users_id_fk": { + "name": "sales_families_created_by_users_id_fk", + "tableFrom": "sales_families", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_family_rules": { + "name": "sales_family_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "family_id": { + "name": "family_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_kind": { + "name": "match_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_family_rules_uq": { + "name": "sales_family_rules_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_family_rules_organization_id_organizations_id_fk": { + "name": "sales_family_rules_organization_id_organizations_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_family_rules_family_id_sales_families_id_fk": { + "name": "sales_family_rules_family_id_sales_families_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "sales_families", + "columnsFrom": [ + "family_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_family_rules_created_by_users_id_fk": { + "name": "sales_family_rules_created_by_users_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_family_rules_kind_ck": { + "name": "sales_family_rules_kind_ck", + "value": "\"sales_family_rules\".\"match_kind\" IN ('category', 'product')" + } + }, + "isRLSEnabled": false + }, + "public.sales_import_batches": { + "name": "sales_import_batches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_sha256": { + "name": "file_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "row_count": { + "name": "row_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "period_from": { + "name": "period_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_to": { + "name": "period_to", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "import_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "imported_by": { + "name": "imported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reverted_at": { + "name": "reverted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reverted_by": { + "name": "reverted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payment_count": { + "name": "payment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_batches_file_uq": { + "name": "sales_batches_file_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "file_sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_import_batches_organization_id_organizations_id_fk": { + "name": "sales_import_batches_organization_id_organizations_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_import_batches_establishment_id_establishments_id_fk": { + "name": "sales_import_batches_establishment_id_establishments_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_import_batches_imported_by_users_id_fk": { + "name": "sales_import_batches_imported_by_users_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "users", + "columnsFrom": [ + "imported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sales_import_batches_reverted_by_users_id_fk": { + "name": "sales_import_batches_reverted_by_users_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "users", + "columnsFrom": [ + "reverted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_import_profiles": { + "name": "sales_import_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header_signature": { + "name": "header_signature", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "headers": { + "name": "headers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "mapping": { + "name": "mapping", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "use_count": { + "name": "use_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_import_profiles_sig_uq": { + "name": "sales_import_profiles_sig_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "header_signature", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_import_profiles_organization_id_organizations_id_fk": { + "name": "sales_import_profiles_organization_id_organizations_id_fk", + "tableFrom": "sales_import_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_import_profiles_created_by_users_id_fk": { + "name": "sales_import_profiles_created_by_users_id_fk", + "tableFrom": "sales_import_profiles", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_import_profiles_name_ck": { + "name": "sales_import_profiles_name_ck", + "value": "length(\"sales_import_profiles\".\"name\") BETWEEN 1 AND 80" + } + }, + "isRLSEnabled": false + }, + "public.sales_payments": { + "name": "sales_payments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "batch_id": { + "name": "batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_date": { + "name": "business_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "ticket_ref": { + "name": "ticket_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_payments_row_uq": { + "name": "sales_payments_row_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_payments_period_idx": { + "name": "sales_payments_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_payments_organization_id_organizations_id_fk": { + "name": "sales_payments_organization_id_organizations_id_fk", + "tableFrom": "sales_payments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_payments_establishment_id_establishments_id_fk": { + "name": "sales_payments_establishment_id_establishments_id_fk", + "tableFrom": "sales_payments", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_payments_batch_id_sales_import_batches_id_fk": { + "name": "sales_payments_batch_id_sales_import_batches_id_fk", + "tableFrom": "sales_payments", + "tableTo": "sales_import_batches", + "columnsFrom": [ + "batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_product_recipe_history": { + "name": "sales_product_recipe_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "portions_per_sale": { + "name": "portions_per_sale", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_product_recipe_history_uq": { + "name": "sales_product_recipe_history_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "valid_until", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_product_recipe_history_organization_id_organizations_id_fk": { + "name": "sales_product_recipe_history_organization_id_organizations_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_product_recipe_history_recipe_id_recipes_id_fk": { + "name": "sales_product_recipe_history_recipe_id_recipes_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_product_recipe_history_created_by_users_id_fk": { + "name": "sales_product_recipe_history_created_by_users_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_product_recipes": { + "name": "sales_product_recipes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "portions_per_sale": { + "name": "portions_per_sale", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "match_code": { + "name": "match_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_product_recipes_key_uq": { + "name": "sales_product_recipes_key_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_product_recipes_code_uq": { + "name": "sales_product_recipes_code_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"sales_product_recipes\".\"match_code\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_product_recipes_recipe_idx": { + "name": "sales_product_recipes_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_product_recipes_organization_id_organizations_id_fk": { + "name": "sales_product_recipes_organization_id_organizations_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_product_recipes_recipe_id_recipes_id_fk": { + "name": "sales_product_recipes_recipe_id_recipes_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_product_recipes_created_by_users_id_fk": { + "name": "sales_product_recipes_created_by_users_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sales_product_recipes_updated_by_users_id_fk": { + "name": "sales_product_recipes_updated_by_users_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_product_recipes_ck": { + "name": "sales_product_recipes_ck", + "value": "(\"sales_product_recipes\".\"recipe_id\" IS NULL AND \"sales_product_recipes\".\"portions_per_sale\" IS NULL) OR (\"sales_product_recipes\".\"recipe_id\" IS NOT NULL AND \"sales_product_recipes\".\"portions_per_sale\" > 0)" + } + }, + "isRLSEnabled": false + }, + "public.sales_server_links": { + "name": "sales_server_links", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "server_key": { + "name": "server_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "server_label": { + "name": "server_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_server_links_uq": { + "name": "sales_server_links_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "server_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_server_links_org_idx": { + "name": "sales_server_links_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_server_links_organization_id_organizations_id_fk": { + "name": "sales_server_links_organization_id_organizations_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_establishment_id_establishments_id_fk": { + "name": "sales_server_links_establishment_id_establishments_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_employee_id_employees_id_fk": { + "name": "sales_server_links_employee_id_employees_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_created_by_users_id_fk": { + "name": "sales_server_links_created_by_users_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_server_links_key_ck": { + "name": "sales_server_links_key_ck", + "value": "length(\"sales_server_links\".\"server_key\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + }, + "public.sales_service_periods": { + "name": "sales_service_periods", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_service_periods_name_uq": { + "name": "sales_service_periods_name_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_service_periods_organization_id_organizations_id_fk": { + "name": "sales_service_periods_organization_id_organizations_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_service_periods_establishment_id_establishments_id_fk": { + "name": "sales_service_periods_establishment_id_establishments_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_service_periods_created_by_users_id_fk": { + "name": "sales_service_periods_created_by_users_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_service_periods_time_ck": { + "name": "sales_service_periods_time_ck", + "value": "\"sales_service_periods\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"sales_service_periods\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"sales_service_periods\".\"start_time\" <> \"sales_service_periods\".\"end_time\"" + } + }, + "isRLSEnabled": false + }, + "public.sensitive_views": { + "name": "sensitive_views", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "area": { + "name": "area", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "viewed_at": { + "name": "viewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sensitive_views_org_idx": { + "name": "sensitive_views_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "viewed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sensitive_views_user_idx": { + "name": "sensitive_views_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "viewed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sensitive_views_organization_id_organizations_id_fk": { + "name": "sensitive_views_organization_id_organizations_id_fk", + "tableFrom": "sensitive_views", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sensitive_views_user_id_users_id_fk": { + "name": "sensitive_views_user_id_users_id_fk", + "tableFrom": "sensitive_views", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.seo_listings": { + "name": "seo_listings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "directory": { + "name": "directory", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nap_hash": { + "name": "nap_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "checked_by": { + "name": "checked_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_listings_est_dir_uq": { + "name": "seo_listings_est_dir_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "directory", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_listings_org_idx": { + "name": "seo_listings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_listings_organization_id_organizations_id_fk": { + "name": "seo_listings_organization_id_organizations_id_fk", + "tableFrom": "seo_listings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_listings_establishment_id_establishments_id_fk": { + "name": "seo_listings_establishment_id_establishments_id_fk", + "tableFrom": "seo_listings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_listings_checked_by_users_id_fk": { + "name": "seo_listings_checked_by_users_id_fk", + "tableFrom": "seo_listings", + "tableTo": "users", + "columnsFrom": [ + "checked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "seo_listings_status_ck": { + "name": "seo_listings_status_ck", + "value": "\"seo_listings\".\"status\" IN ('en_ligne', 'absent', 'non_concerne')" + } + }, + "isRLSEnabled": false + }, + "public.seo_profiles": { + "name": "seo_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cuisines": { + "name": "cuisines", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "price_range": { + "name": "price_range", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "menu_url": { + "name": "menu_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "links": { + "name": "links", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "keywords": { + "name": "keywords", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_profiles_est_uq": { + "name": "seo_profiles_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_profiles_org_idx": { + "name": "seo_profiles_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_profiles_organization_id_organizations_id_fk": { + "name": "seo_profiles_organization_id_organizations_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_profiles_establishment_id_establishments_id_fk": { + "name": "seo_profiles_establishment_id_establishments_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_profiles_updated_by_users_id_fk": { + "name": "seo_profiles_updated_by_users_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "seo_profiles_price_ck": { + "name": "seo_profiles_price_ck", + "value": "\"seo_profiles\".\"price_range\" IS NULL OR \"seo_profiles\".\"price_range\" IN ('\u20ac', '\u20ac\u20ac', '\u20ac\u20ac\u20ac', '\u20ac\u20ac\u20ac\u20ac')" + } + }, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sessions_user_idx": { + "name": "sessions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sessions_organization_id_organizations_id_fk": { + "name": "sessions_organization_id_organizations_id_fk", + "tableFrom": "sessions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.set_menus": { + "name": "set_menus", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "occasion": { + "name": "occasion", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "min_guests": { + "name": "min_guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_guests": { + "name": "max_guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "available_from": { + "name": "available_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "available_to": { + "name": "available_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "recipe_ids": { + "name": "recipe_ids", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::uuid[]" + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "set_menus_est_idx": { + "name": "set_menus_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "set_menus_organization_id_organizations_id_fk": { + "name": "set_menus_organization_id_organizations_id_fk", + "tableFrom": "set_menus", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "set_menus_establishment_id_establishments_id_fk": { + "name": "set_menus_establishment_id_establishments_id_fk", + "tableFrom": "set_menus", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "set_menus_created_by_users_id_fk": { + "name": "set_menus_created_by_users_id_fk", + "tableFrom": "set_menus", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "set_menus_category_ck": { + "name": "set_menus_category_ck", + "value": "\"set_menus\".\"category\" IN ('carte', 'groupe', 'evenement')" + }, + "set_menus_guests_ck": { + "name": "set_menus_guests_ck", + "value": "(\"set_menus\".\"min_guests\" IS NULL OR \"set_menus\".\"min_guests\" > 0) AND (\"set_menus\".\"max_guests\" IS NULL OR \"set_menus\".\"max_guests\" > 0) AND (\"set_menus\".\"min_guests\" IS NULL OR \"set_menus\".\"max_guests\" IS NULL OR \"set_menus\".\"min_guests\" <= \"set_menus\".\"max_guests\")" + }, + "set_menus_dates_ck": { + "name": "set_menus_dates_ck", + "value": "\"set_menus\".\"available_from\" IS NULL OR \"set_menus\".\"available_to\" IS NULL OR \"set_menus\".\"available_from\" <= \"set_menus\".\"available_to\"" + } + }, + "isRLSEnabled": false + }, + "public.shift_swaps": { + "name": "shift_swaps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "shift_id": { + "name": "shift_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "from_employee_id": { + "name": "from_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_employee_id": { + "name": "to_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counter_shift_id": { + "name": "counter_shift_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "shift_snapshot": { + "name": "shift_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counter_snapshot": { + "name": "counter_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'attente_collegue'" + }, + "colleague_answered_at": { + "name": "colleague_answered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shift_swaps_est_status_idx": { + "name": "shift_swaps_est_status_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shift_swaps_from_idx": { + "name": "shift_swaps_from_idx", + "columns": [ + { + "expression": "from_employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shift_swaps_to_idx": { + "name": "shift_swaps_to_idx", + "columns": [ + { + "expression": "to_employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shift_swaps_organization_id_organizations_id_fk": { + "name": "shift_swaps_organization_id_organizations_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_establishment_id_establishments_id_fk": { + "name": "shift_swaps_establishment_id_establishments_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_shift_id_shifts_id_fk": { + "name": "shift_swaps_shift_id_shifts_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "shifts", + "columnsFrom": [ + "shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "shift_swaps_from_employee_id_employees_id_fk": { + "name": "shift_swaps_from_employee_id_employees_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "employees", + "columnsFrom": [ + "from_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_to_employee_id_employees_id_fk": { + "name": "shift_swaps_to_employee_id_employees_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "employees", + "columnsFrom": [ + "to_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_counter_shift_id_shifts_id_fk": { + "name": "shift_swaps_counter_shift_id_shifts_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "shifts", + "columnsFrom": [ + "counter_shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "shift_swaps_decided_by_users_id_fk": { + "name": "shift_swaps_decided_by_users_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shift_swaps_created_by_users_id_fk": { + "name": "shift_swaps_created_by_users_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shift_swaps_status_ck": { + "name": "shift_swaps_status_ck", + "value": "\"shift_swaps\".\"status\" IN ('attente_collegue', 'attente_responsable', 'acceptee', 'refusee', 'annulee', 'expiree')" + }, + "shift_swaps_people_ck": { + "name": "shift_swaps_people_ck", + "value": "\"shift_swaps\".\"from_employee_id\" <> \"shift_swaps\".\"to_employee_id\"" + } + }, + "isRLSEnabled": false + }, + "public.shift_templates": { + "name": "shift_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "break_minutes": { + "name": "break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shift_templates_est_idx": { + "name": "shift_templates_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shift_templates_organization_id_organizations_id_fk": { + "name": "shift_templates_organization_id_organizations_id_fk", + "tableFrom": "shift_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_templates_establishment_id_establishments_id_fk": { + "name": "shift_templates_establishment_id_establishments_id_fk", + "tableFrom": "shift_templates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_templates_created_by_users_id_fk": { + "name": "shift_templates_created_by_users_id_fk", + "tableFrom": "shift_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shift_templates_time_ck": { + "name": "shift_templates_time_ck", + "value": "\"shift_templates\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shift_templates\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shift_templates\".\"start_time\" <> \"shift_templates\".\"end_time\"" + }, + "shift_templates_break_ck": { + "name": "shift_templates_break_ck", + "value": "\"shift_templates\".\"break_minutes\" >= 0 AND \"shift_templates\".\"break_minutes\" <= 240" + } + }, + "isRLSEnabled": false + }, + "public.shifts": { + "name": "shifts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "break_minutes": { + "name": "break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_start": { + "name": "actual_start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_end": { + "name": "actual_end", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_break_minutes": { + "name": "actual_break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "meals": { + "name": "meals", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "no_show": { + "name": "no_show", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shifts_est_date_idx": { + "name": "shifts_est_date_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shifts_emp_date_idx": { + "name": "shifts_emp_date_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shifts_organization_id_organizations_id_fk": { + "name": "shifts_organization_id_organizations_id_fk", + "tableFrom": "shifts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_establishment_id_establishments_id_fk": { + "name": "shifts_establishment_id_establishments_id_fk", + "tableFrom": "shifts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_employee_id_employees_id_fk": { + "name": "shifts_employee_id_employees_id_fk", + "tableFrom": "shifts", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_validated_by_users_id_fk": { + "name": "shifts_validated_by_users_id_fk", + "tableFrom": "shifts", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shifts_created_by_users_id_fk": { + "name": "shifts_created_by_users_id_fk", + "tableFrom": "shifts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shifts_meals_ck": { + "name": "shifts_meals_ck", + "value": "\"shifts\".\"meals\" >= 0 AND \"shifts\".\"meals\" <= 3" + }, + "shifts_time_ck": { + "name": "shifts_time_ck", + "value": "\"shifts\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shifts\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shifts\".\"start_time\" <> \"shifts\".\"end_time\"" + }, + "shifts_break_ck": { + "name": "shifts_break_ck", + "value": "\"shifts\".\"break_minutes\" >= 0 AND \"shifts\".\"break_minutes\" <= 240" + } + }, + "isRLSEnabled": false + }, + "public.signature_requests": { + "name": "signature_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_id": { + "name": "contract_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_pdf": { + "name": "document_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "document_sha256": { + "name": "document_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "signer_email": { + "name": "signer_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employer_name": { + "name": "employer_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code_expires_at": { + "name": "code_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "code_sent_at": { + "name": "code_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "codes_sent": { + "name": "codes_sent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "code_attempts": { + "name": "code_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "signed_at": { + "name": "signed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "signed_name": { + "name": "signed_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signed_pdf": { + "name": "signed_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "signed_sha256": { + "name": "signed_sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refusal_note": { + "name": "refusal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "drawn_signature": { + "name": "drawn_signature", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "reminders_sent": { + "name": "reminders_sent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_reminder_at": { + "name": "last_reminder_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "signature_requests_token_uq": { + "name": "signature_requests_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "signature_requests_emp_idx": { + "name": "signature_requests_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "signature_requests_organization_id_organizations_id_fk": { + "name": "signature_requests_organization_id_organizations_id_fk", + "tableFrom": "signature_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_establishment_id_establishments_id_fk": { + "name": "signature_requests_establishment_id_establishments_id_fk", + "tableFrom": "signature_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_employee_id_employees_id_fk": { + "name": "signature_requests_employee_id_employees_id_fk", + "tableFrom": "signature_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_file_id_employee_files_id_fk": { + "name": "signature_requests_file_id_employee_files_id_fk", + "tableFrom": "signature_requests", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "signature_requests_created_by_users_id_fk": { + "name": "signature_requests_created_by_users_id_fk", + "tableFrom": "signature_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "signature_requests_status_ck": { + "name": "signature_requests_status_ck", + "value": "\"signature_requests\".\"status\" IN ('en_attente', 'signe', 'refuse', 'annule')" + } + }, + "isRLSEnabled": false + }, + "public.skills": { + "name": "skills", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "skills_name_uq": { + "name": "skills_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"skills\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "skills_organization_id_organizations_id_fk": { + "name": "skills_organization_id_organizations_id_fk", + "tableFrom": "skills", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.social_posts": { + "name": "social_posts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "visual_id": { + "name": "visual_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "networks": { + "name": "networks", + "type": "text[]", + "primaryKey": false, + "notNull": true + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_mime": { + "name": "image_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "image_format": { + "name": "image_format", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external": { + "name": "external", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stats": { + "name": "stats", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stats_at": { + "name": "stats_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "social_posts_cal_idx": { + "name": "social_posts_cal_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_due_idx": { + "name": "social_posts_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_source_uq": { + "name": "social_posts_source_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"social_posts\".\"source_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_token_uq": { + "name": "social_posts_token_uq", + "columns": [ + { + "expression": "public_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "social_posts_organization_id_organizations_id_fk": { + "name": "social_posts_organization_id_organizations_id_fk", + "tableFrom": "social_posts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_posts_establishment_id_establishments_id_fk": { + "name": "social_posts_establishment_id_establishments_id_fk", + "tableFrom": "social_posts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_posts_visual_id_studio_visuals_id_fk": { + "name": "social_posts_visual_id_studio_visuals_id_fk", + "tableFrom": "social_posts", + "tableTo": "studio_visuals", + "columnsFrom": [ + "visual_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "social_posts_approved_by_users_id_fk": { + "name": "social_posts_approved_by_users_id_fk", + "tableFrom": "social_posts", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "social_posts_created_by_users_id_fk": { + "name": "social_posts_created_by_users_id_fk", + "tableFrom": "social_posts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "social_posts_source_ck": { + "name": "social_posts_source_ck", + "value": "\"social_posts\".\"source\" IN ('manuel', 'menu_du_jour', 'evenement', 'fermeture', 'avis')" + }, + "social_posts_status_ck": { + "name": "social_posts_status_ck", + "value": "\"social_posts\".\"status\" IN ('a_valider', 'planifie', 'publie', 'partiel', 'echec', 'annule')" + }, + "social_posts_networks_ck": { + "name": "social_posts_networks_ck", + "value": "\"social_posts\".\"networks\" <@ ARRAY['instagram','facebook']::text[] AND cardinality(\"social_posts\".\"networks\") >= 1" + }, + "social_posts_image_ck": { + "name": "social_posts_image_ck", + "value": "(\"social_posts\".\"image\" IS NULL) = (\"social_posts\".\"image_mime\" IS NULL) AND (\"social_posts\".\"image_mime\" IS NULL OR \"social_posts\".\"image_mime\" = 'image/png')" + }, + "social_posts_format_ck": { + "name": "social_posts_format_ck", + "value": "\"social_posts\".\"image_format\" IS NULL OR \"social_posts\".\"image_format\" IN ('carre', 'portrait', 'facebook')" + }, + "social_posts_caption_ck": { + "name": "social_posts_caption_ck", + "value": "char_length(\"social_posts\".\"caption\") BETWEEN 1 AND 2200" + } + }, + "isRLSEnabled": false + }, + "public.social_settings": { + "name": "social_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "networks": { + "name": "networks", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY['instagram','facebook']::text[]" + }, + "require_approval": { + "name": "require_approval", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "auto_menu": { + "name": "auto_menu", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "menu_time": { + "name": "menu_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'11:00'" + }, + "auto_events": { + "name": "auto_events", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "event_time": { + "name": "event_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'18:00'" + }, + "closure_days_before": { + "name": "closure_days_before", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "auto_reviews": { + "name": "auto_reviews", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "review_min_rating": { + "name": "review_min_rating", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "review_time": { + "name": "review_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'17:30'" + }, + "hashtags": { + "name": "hashtags", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_posts_per_day": { + "name": "max_posts_per_day", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "repeat_days": { + "name": "repeat_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 14 + }, + "auto_best_times": { + "name": "auto_best_times", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "social_settings_org_idx": { + "name": "social_settings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "social_settings_establishment_id_establishments_id_fk": { + "name": "social_settings_establishment_id_establishments_id_fk", + "tableFrom": "social_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_settings_organization_id_organizations_id_fk": { + "name": "social_settings_organization_id_organizations_id_fk", + "tableFrom": "social_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_settings_updated_by_users_id_fk": { + "name": "social_settings_updated_by_users_id_fk", + "tableFrom": "social_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "social_settings_repeat_ck": { + "name": "social_settings_repeat_ck", + "value": "\"social_settings\".\"max_posts_per_day\" BETWEEN 1 AND 5 AND \"social_settings\".\"repeat_days\" BETWEEN 0 AND 90" + }, + "social_settings_networks_ck": { + "name": "social_settings_networks_ck", + "value": "\"social_settings\".\"networks\" <@ ARRAY['instagram','facebook']::text[] AND cardinality(\"social_settings\".\"networks\") >= 1" + }, + "social_settings_times_ck": { + "name": "social_settings_times_ck", + "value": "\"social_settings\".\"menu_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"social_settings\".\"event_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"social_settings\".\"review_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "social_settings_rating_ck": { + "name": "social_settings_rating_ck", + "value": "\"social_settings\".\"review_min_rating\" BETWEEN 4 AND 5" + }, + "social_settings_days_ck": { + "name": "social_settings_days_ck", + "value": "\"social_settings\".\"closure_days_before\" BETWEEN 0 AND 14" + } + }, + "isRLSEnabled": false + }, + "public.stock_expiry_lots": { + "name": "stock_expiry_lots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_on": { + "name": "expires_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_line_id": { + "name": "order_line_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_reason": { + "name": "closed_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "loss_id": { + "name": "loss_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_expiry_lots_loss_idx": { + "name": "stock_expiry_lots_loss_idx", + "columns": [ + { + "expression": "loss_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"stock_expiry_lots\".\"loss_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_expiry_lots_open_idx": { + "name": "stock_expiry_lots_open_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"stock_expiry_lots\".\"closed_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_expiry_lots_item_idx": { + "name": "stock_expiry_lots_item_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_expiry_lots_organization_id_organizations_id_fk": { + "name": "stock_expiry_lots_organization_id_organizations_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_establishment_id_establishments_id_fk": { + "name": "stock_expiry_lots_establishment_id_establishments_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_item_id_purchase_items_id_fk": { + "name": "stock_expiry_lots_item_id_purchase_items_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_order_line_id_purchase_order_lines_id_fk": { + "name": "stock_expiry_lots_order_line_id_purchase_order_lines_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "purchase_order_lines", + "columnsFrom": [ + "order_line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "stock_expiry_lots_closed_by_users_id_fk": { + "name": "stock_expiry_lots_closed_by_users_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_expiry_lots_loss_id_stock_losses_id_fk": { + "name": "stock_expiry_lots_loss_id_stock_losses_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "stock_losses", + "columnsFrom": [ + "loss_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "stock_expiry_lots_created_by_users_id_fk": { + "name": "stock_expiry_lots_created_by_users_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_expiry_lots_kind_ck": { + "name": "stock_expiry_lots_kind_ck", + "value": "\"stock_expiry_lots\".\"kind\" IN ('dlc', 'ddm')" + }, + "stock_expiry_lots_qty_ck": { + "name": "stock_expiry_lots_qty_ck", + "value": "\"stock_expiry_lots\".\"quantity\" > 0" + }, + "stock_expiry_lots_close_ck": { + "name": "stock_expiry_lots_close_ck", + "value": "(\"stock_expiry_lots\".\"closed_at\" IS NULL) = (\"stock_expiry_lots\".\"closed_reason\" IS NULL) AND (\"stock_expiry_lots\".\"closed_reason\" IS NULL OR \"stock_expiry_lots\".\"closed_reason\" IN ('ecoule', 'perte', 'retour', 'erreur'))" + } + }, + "isRLSEnabled": false + }, + "public.stock_losses": { + "name": "stock_losses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "loss_date": { + "name": "loss_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credit_request_id": { + "name": "credit_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_losses_est_idx": { + "name": "stock_losses_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "loss_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_losses_organization_id_organizations_id_fk": { + "name": "stock_losses_organization_id_organizations_id_fk", + "tableFrom": "stock_losses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_losses_establishment_id_establishments_id_fk": { + "name": "stock_losses_establishment_id_establishments_id_fk", + "tableFrom": "stock_losses", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_losses_item_id_purchase_items_id_fk": { + "name": "stock_losses_item_id_purchase_items_id_fk", + "tableFrom": "stock_losses", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_losses_created_by_users_id_fk": { + "name": "stock_losses_created_by_users_id_fk", + "tableFrom": "stock_losses", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_losses_cancelled_by_users_id_fk": { + "name": "stock_losses_cancelled_by_users_id_fk", + "tableFrom": "stock_losses", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_losses_credit_request_id_credit_requests_id_fk": { + "name": "stock_losses_credit_request_id_credit_requests_id_fk", + "tableFrom": "stock_losses", + "tableTo": "credit_requests", + "columnsFrom": [ + "credit_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_losses_qty_ck": { + "name": "stock_losses_qty_ck", + "value": "\"stock_losses\".\"quantity\" > 0" + }, + "stock_losses_reason_ck": { + "name": "stock_losses_reason_ck", + "value": "\"stock_losses\".\"reason\" IN ('peremption', 'casse', 'erreur_production', 'retour_client', 'repas_personnel', 'offert', 'vol', 'retour_fournisseur', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.stock_rotation_settings": { + "name": "stock_rotation_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "overstock_days": { + "name": "overstock_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "lookback_days": { + "name": "lookback_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 28 + }, + "level_basis": { + "name": "level_basis", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'compte'" + }, + "expiry_alert_days": { + "name": "expiry_alert_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_rotation_settings_est_uq": { + "name": "stock_rotation_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_rotation_settings_organization_id_organizations_id_fk": { + "name": "stock_rotation_settings_organization_id_organizations_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_rotation_settings_establishment_id_establishments_id_fk": { + "name": "stock_rotation_settings_establishment_id_establishments_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_rotation_settings_updated_by_users_id_fk": { + "name": "stock_rotation_settings_updated_by_users_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_rotation_overstock_ck": { + "name": "stock_rotation_overstock_ck", + "value": "\"stock_rotation_settings\".\"overstock_days\" IS NULL OR \"stock_rotation_settings\".\"overstock_days\" BETWEEN 1 AND 365" + }, + "stock_rotation_lookback_ck": { + "name": "stock_rotation_lookback_ck", + "value": "\"stock_rotation_settings\".\"lookback_days\" BETWEEN 7 AND 365" + }, + "stock_rotation_basis_ck": { + "name": "stock_rotation_basis_ck", + "value": "\"stock_rotation_settings\".\"level_basis\" IN ('compte', 'theorique')" + }, + "stock_rotation_expiry_ck": { + "name": "stock_rotation_expiry_ck", + "value": "\"stock_rotation_settings\".\"expiry_alert_days\" BETWEEN 0 AND 30" + } + }, + "isRLSEnabled": false + }, + "public.stock_transfer_lines": { + "name": "stock_transfer_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "transfer_id": { + "name": "transfer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_transfer_lines_item_uq": { + "name": "stock_transfer_lines_item_uq", + "columns": [ + { + "expression": "transfer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfer_lines_item_idx": { + "name": "stock_transfer_lines_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_transfer_lines_organization_id_organizations_id_fk": { + "name": "stock_transfer_lines_organization_id_organizations_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfer_lines_transfer_id_stock_transfers_id_fk": { + "name": "stock_transfer_lines_transfer_id_stock_transfers_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "stock_transfers", + "columnsFrom": [ + "transfer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfer_lines_item_id_purchase_items_id_fk": { + "name": "stock_transfer_lines_item_id_purchase_items_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_transfer_lines_ck": { + "name": "stock_transfer_lines_ck", + "value": "\"stock_transfer_lines\".\"quantity\" > 0 AND \"stock_transfer_lines\".\"unit_cost\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.stock_transfers": { + "name": "stock_transfers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "from_establishment_id": { + "name": "from_establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_establishment_id": { + "name": "to_establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "transfer_date": { + "name": "transfer_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_value": { + "name": "total_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_transfers_number_uq": { + "name": "stock_transfers_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfers_from_idx": { + "name": "stock_transfers_from_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "transfer_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfers_to_idx": { + "name": "stock_transfers_to_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "transfer_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_transfers_organization_id_organizations_id_fk": { + "name": "stock_transfers_organization_id_organizations_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfers_from_establishment_id_establishments_id_fk": { + "name": "stock_transfers_from_establishment_id_establishments_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "establishments", + "columnsFrom": [ + "from_establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_transfers_to_establishment_id_establishments_id_fk": { + "name": "stock_transfers_to_establishment_id_establishments_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "establishments", + "columnsFrom": [ + "to_establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_transfers_created_by_users_id_fk": { + "name": "stock_transfers_created_by_users_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_transfers_cancelled_by_users_id_fk": { + "name": "stock_transfers_cancelled_by_users_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_transfers_distinct_ck": { + "name": "stock_transfers_distinct_ck", + "value": "\"stock_transfers\".\"from_establishment_id\" <> \"stock_transfers\".\"to_establishment_id\"" + } + }, + "isRLSEnabled": false + }, + "public.studio_brands": { + "name": "studio_brands", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "handle": { + "name": "handle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "background": { + "name": "background", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#1f2a24'" + }, + "primary": { + "name": "primary", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#d9a441'" + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#fbf7ee'" + }, + "font": { + "name": "font", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'classique'" + }, + "logo_mime": { + "name": "logo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo": { + "name": "logo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "studio_brands_org_idx": { + "name": "studio_brands_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "studio_brands_establishment_id_establishments_id_fk": { + "name": "studio_brands_establishment_id_establishments_id_fk", + "tableFrom": "studio_brands", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_brands_organization_id_organizations_id_fk": { + "name": "studio_brands_organization_id_organizations_id_fk", + "tableFrom": "studio_brands", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_brands_updated_by_users_id_fk": { + "name": "studio_brands_updated_by_users_id_fk", + "tableFrom": "studio_brands", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "studio_brands_colors_ck": { + "name": "studio_brands_colors_ck", + "value": "\"studio_brands\".\"background\" ~ '^#[0-9a-f]{6}$' AND \"studio_brands\".\"primary\" ~ '^#[0-9a-f]{6}$' AND \"studio_brands\".\"text\" ~ '^#[0-9a-f]{6}$'" + }, + "studio_brands_font_ck": { + "name": "studio_brands_font_ck", + "value": "\"studio_brands\".\"font\" IN ('classique', 'moderne', 'elegant')" + }, + "studio_brands_logo_ck": { + "name": "studio_brands_logo_ck", + "value": "(\"studio_brands\".\"logo\" IS NULL) = (\"studio_brands\".\"logo_mime\" IS NULL) AND (\"studio_brands\".\"logo_mime\" IS NULL OR \"studio_brands\".\"logo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + } + }, + "isRLSEnabled": false + }, + "public.studio_visuals": { + "name": "studio_visuals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "studio_visuals_est_idx": { + "name": "studio_visuals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "studio_visuals_organization_id_organizations_id_fk": { + "name": "studio_visuals_organization_id_organizations_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_visuals_establishment_id_establishments_id_fk": { + "name": "studio_visuals_establishment_id_establishments_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_visuals_created_by_users_id_fk": { + "name": "studio_visuals_created_by_users_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "studio_visuals_template_ck": { + "name": "studio_visuals_template_ck", + "value": "\"studio_visuals\".\"template\" IN ('menu_du_jour', 'plat', 'evenement', 'avis')" + }, + "studio_visuals_format_ck": { + "name": "studio_visuals_format_ck", + "value": "\"studio_visuals\".\"format\" IN ('carre', 'portrait', 'story', 'facebook')" + }, + "studio_visuals_photo_ck": { + "name": "studio_visuals_photo_ck", + "value": "(\"studio_visuals\".\"photo\" IS NULL) = (\"studio_visuals\".\"photo_mime\" IS NULL) AND (\"studio_visuals\".\"photo_mime\" IS NULL OR \"studio_visuals\".\"photo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + } + }, + "isRLSEnabled": false + }, + "public.supplier_offer_prices": { + "name": "supplier_offer_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "offer_id": { + "name": "offer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "price_ht": { + "name": "price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "content_quantity": { + "name": "content_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "content_unit": { + "name": "content_unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_offer_prices_offer_idx": { + "name": "supplier_offer_prices_offer_idx", + "columns": [ + { + "expression": "offer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_offer_prices_organization_id_organizations_id_fk": { + "name": "supplier_offer_prices_organization_id_organizations_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offer_prices_offer_id_supplier_offers_id_fk": { + "name": "supplier_offer_prices_offer_id_supplier_offers_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "supplier_offers", + "columnsFrom": [ + "offer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offer_prices_created_by_users_id_fk": { + "name": "supplier_offer_prices_created_by_users_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "supplier_offer_prices_source_ck": { + "name": "supplier_offer_prices_source_ck", + "value": "\"supplier_offer_prices\".\"source\" IN ('manual', 'import', 'migration', 'demande_prix')" + }, + "supplier_offer_prices_price_ck": { + "name": "supplier_offer_prices_price_ck", + "value": "\"supplier_offer_prices\".\"price_ht\" >= 0 AND \"supplier_offer_prices\".\"content_quantity\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.supplier_offers": { + "name": "supplier_offers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_ref": { + "name": "supplier_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_ht": { + "name": "price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "content_quantity": { + "name": "content_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "content_unit": { + "name": "content_unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price_date": { + "name": "price_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_offers_item_idx": { + "name": "supplier_offers_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "supplier_offers_supplier_idx": { + "name": "supplier_offers_supplier_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "supplier_offers_active_uq": { + "name": "supplier_offers_active_uq", + "columns": [ + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(coalesce(\"supplier_ref\", ''))", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"supplier_offers\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_offers_organization_id_organizations_id_fk": { + "name": "supplier_offers_organization_id_organizations_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offers_item_id_purchase_items_id_fk": { + "name": "supplier_offers_item_id_purchase_items_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offers_supplier_id_suppliers_id_fk": { + "name": "supplier_offers_supplier_id_suppliers_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "supplier_offers_created_by_users_id_fk": { + "name": "supplier_offers_created_by_users_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "supplier_offers_updated_by_users_id_fk": { + "name": "supplier_offers_updated_by_users_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "supplier_offers_price_ck": { + "name": "supplier_offers_price_ck", + "value": "\"supplier_offers\".\"price_ht\" >= 0 AND \"supplier_offers\".\"content_quantity\" > 0" + }, + "supplier_offers_unit_ck": { + "name": "supplier_offers_unit_ck", + "value": "\"supplier_offers\".\"content_unit\" IN ('kg', 'g', 'L', 'cl', 'pi\u00e8ce', 'botte', 'carton', 'colis', 'bouteille', 'f\u00fbt', 'lot', 'heure', 'forfait')" + }, + "supplier_offers_source_ck": { + "name": "supplier_offers_source_ck", + "value": "\"supplier_offers\".\"source\" IN ('manual', 'import', 'migration', 'demande_prix')" + } + }, + "isRLSEnabled": false + }, + "public.suppliers": { + "name": "suppliers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_number": { + "name": "vat_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_terms_days": { + "name": "payment_terms_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "default_category": { + "name": "default_category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'food'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "min_order_ht": { + "name": "min_order_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "order_cutoff": { + "name": "order_cutoff", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lead_time_days": { + "name": "lead_time_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_mode": { + "name": "delivery_fee_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "delivery_fee_fixed": { + "name": "delivery_fee_fixed", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_percent": { + "name": "delivery_fee_percent", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_tiers": { + "name": "delivery_fee_tiers", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "suppliers_org_idx": { + "name": "suppliers_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "suppliers_org_name_uq": { + "name": "suppliers_org_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "suppliers_organization_id_organizations_id_fk": { + "name": "suppliers_organization_id_organizations_id_fk", + "tableFrom": "suppliers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "suppliers_created_by_users_id_fk": { + "name": "suppliers_created_by_users_id_fk", + "tableFrom": "suppliers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "suppliers_fee_mode_ck": { + "name": "suppliers_fee_mode_ck", + "value": "\"suppliers\".\"delivery_fee_mode\" IN ('none', 'fixed', 'tiers', 'percent')" + }, + "suppliers_cutoff_ck": { + "name": "suppliers_cutoff_ck", + "value": "\"suppliers\".\"order_cutoff\" IS NULL OR \"suppliers\".\"order_cutoff\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "suppliers_siret_ck": { + "name": "suppliers_siret_ck", + "value": "\"suppliers\".\"siret\" IS NULL OR \"suppliers\".\"siret\" ~ '^[0-9]{14}$'" + }, + "suppliers_terms_ck": { + "name": "suppliers_terms_ck", + "value": "\"suppliers\".\"payment_terms_days\" IS NULL OR (\"suppliers\".\"payment_terms_days\" >= 0 AND \"suppliers\".\"payment_terms_days\" <= 365)" + } + }, + "isRLSEnabled": false + }, + "public.tablet_devices": { + "name": "tablet_devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo_on_punch": { + "name": "photo_on_punch", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pairing_code_hash": { + "name": "pairing_code_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pairing_expires_at": { + "name": "pairing_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paired_at": { + "name": "paired_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "operator_employee_id": { + "name": "operator_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "operator_token_hash": { + "name": "operator_token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "operator_until": { + "name": "operator_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tablet_devices_org_idx": { + "name": "tablet_devices_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tablet_devices_token_uq": { + "name": "tablet_devices_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tablet_devices_pairing_uq": { + "name": "tablet_devices_pairing_uq", + "columns": [ + { + "expression": "pairing_code_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tablet_devices_organization_id_organizations_id_fk": { + "name": "tablet_devices_organization_id_organizations_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tablet_devices_establishment_id_establishments_id_fk": { + "name": "tablet_devices_establishment_id_establishments_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tablet_devices_operator_employee_id_employees_id_fk": { + "name": "tablet_devices_operator_employee_id_employees_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "employees", + "columnsFrom": [ + "operator_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tablet_devices_created_by_users_id_fk": { + "name": "tablet_devices_created_by_users_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "tablet_devices_mode_ck": { + "name": "tablet_devices_mode_ck", + "value": "\"tablet_devices\".\"mode\" IN ('pointeuse', 'haccp')" + } + }, + "isRLSEnabled": false + }, + "public.task_completions": { + "name": "task_completions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "occurrence": { + "name": "occurrence", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "task_completions_est_idx": { + "name": "task_completions_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "task_completions_once_uq": { + "name": "task_completions_once_uq", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"task_completions\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_completions_organization_id_organizations_id_fk": { + "name": "task_completions_organization_id_organizations_id_fk", + "tableFrom": "task_completions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_completions_establishment_id_establishments_id_fk": { + "name": "task_completions_establishment_id_establishments_id_fk", + "tableFrom": "task_completions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_completions_task_id_task_definitions_id_fk": { + "name": "task_completions_task_id_task_definitions_id_fk", + "tableFrom": "task_completions", + "tableTo": "task_definitions", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_completions_done_by_users_id_fk": { + "name": "task_completions_done_by_users_id_fk", + "tableFrom": "task_completions", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "task_completions_cancelled_by_users_id_fk": { + "name": "task_completions_cancelled_by_users_id_fk", + "tableFrom": "task_completions", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_definitions": { + "name": "task_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "instructions": { + "name": "instructions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "month_day": { + "name": "month_day", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "once_date": { + "name": "once_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "due_time": { + "name": "due_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_required": { + "name": "photo_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "starts_on": { + "name": "starts_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "task_definitions_est_idx": { + "name": "task_definitions_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_definitions_organization_id_organizations_id_fk": { + "name": "task_definitions_organization_id_organizations_id_fk", + "tableFrom": "task_definitions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_definitions_establishment_id_establishments_id_fk": { + "name": "task_definitions_establishment_id_establishments_id_fk", + "tableFrom": "task_definitions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_definitions_assignee_user_id_users_id_fk": { + "name": "task_definitions_assignee_user_id_users_id_fk", + "tableFrom": "task_definitions", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "task_definitions_created_by_users_id_fk": { + "name": "task_definitions_created_by_users_id_fk", + "tableFrom": "task_definitions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "task_definitions_freq_ck": { + "name": "task_definitions_freq_ck", + "value": "\"task_definitions\".\"frequency\" IN ('once', 'daily', 'weekly', 'monthly')" + }, + "task_definitions_due_ck": { + "name": "task_definitions_due_ck", + "value": "\"task_definitions\".\"due_time\" IS NULL OR \"task_definitions\".\"due_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "task_definitions_month_ck": { + "name": "task_definitions_month_ck", + "value": "\"task_definitions\".\"month_day\" IS NULL OR \"task_definitions\".\"month_day\" BETWEEN 1 AND 31" + } + }, + "isRLSEnabled": false + }, + "public.temperature_readings": { + "name": "temperature_readings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": true + }, + "temp_min": { + "name": "temp_min", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sensor_id": { + "name": "sensor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "temperature_readings_est_idx": { + "name": "temperature_readings_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_readings_eq_idx": { + "name": "temperature_readings_eq_idx", + "columns": [ + { + "expression": "equipment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_readings_sensor_idx": { + "name": "temperature_readings_sensor_idx", + "columns": [ + { + "expression": "sensor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "temperature_readings_organization_id_organizations_id_fk": { + "name": "temperature_readings_organization_id_organizations_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "temperature_readings_establishment_id_establishments_id_fk": { + "name": "temperature_readings_establishment_id_establishments_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_equipment_id_equipment_id_fk": { + "name": "temperature_readings_equipment_id_equipment_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_recorded_by_users_id_fk": { + "name": "temperature_readings_recorded_by_users_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "temperature_readings_sensor_id_temperature_sensors_id_fk": { + "name": "temperature_readings_sensor_id_temperature_sensors_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "temperature_sensors", + "columnsFrom": [ + "sensor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_cancelled_by_users_id_fk": { + "name": "temperature_readings_cancelled_by_users_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "temperature_readings_action_ck": { + "name": "temperature_readings_action_ck", + "value": "\"temperature_readings\".\"conform\" OR \"temperature_readings\".\"corrective_action\" IS NOT NULL OR \"temperature_readings\".\"sensor_id\" IS NOT NULL" + }, + "temperature_readings_author_ck": { + "name": "temperature_readings_author_ck", + "value": "\"temperature_readings\".\"recorded_by\" IS NOT NULL OR \"temperature_readings\".\"sensor_id\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.temperature_sensors": { + "name": "temperature_sensors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hint": { + "name": "token_hint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keep_every_minutes": { + "name": "keep_every_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 15 + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_temperature": { + "name": "last_temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "temperature_sensors_token_uq": { + "name": "temperature_sensors_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_sensors_est_idx": { + "name": "temperature_sensors_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "temperature_sensors_organization_id_organizations_id_fk": { + "name": "temperature_sensors_organization_id_organizations_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "temperature_sensors_establishment_id_establishments_id_fk": { + "name": "temperature_sensors_establishment_id_establishments_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_sensors_equipment_id_equipment_id_fk": { + "name": "temperature_sensors_equipment_id_equipment_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_sensors_created_by_users_id_fk": { + "name": "temperature_sensors_created_by_users_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "temperature_sensors_keep_ck": { + "name": "temperature_sensors_keep_ck", + "value": "\"temperature_sensors\".\"keep_every_minutes\" BETWEEN 1 AND 240" + } + }, + "isRLSEnabled": false + }, + "public.trace_labels": { + "name": "trace_labels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "taken_at": { + "name": "taken_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_size": { + "name": "photo_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "usage": { + "name": "usage", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "production_name": { + "name": "production_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "trace_labels_est_idx": { + "name": "trace_labels_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "taken_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "trace_labels_organization_id_organizations_id_fk": { + "name": "trace_labels_organization_id_organizations_id_fk", + "tableFrom": "trace_labels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "trace_labels_establishment_id_establishments_id_fk": { + "name": "trace_labels_establishment_id_establishments_id_fk", + "tableFrom": "trace_labels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "trace_labels_item_id_purchase_items_id_fk": { + "name": "trace_labels_item_id_purchase_items_id_fk", + "tableFrom": "trace_labels", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "trace_labels_recorded_by_users_id_fk": { + "name": "trace_labels_recorded_by_users_id_fk", + "tableFrom": "trace_labels", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "trace_labels_cancelled_by_users_id_fk": { + "name": "trace_labels_cancelled_by_users_id_fk", + "tableFrom": "trace_labels", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "trace_labels_usage_ck": { + "name": "trace_labels_usage_ck", + "value": "\"trace_labels\".\"usage\" IN ('reception', 'ouverture', 'production')" + }, + "trace_labels_size_ck": { + "name": "trace_labels_size_ck", + "value": "\"trace_labels\".\"photo_size\" IS NULL OR \"trace_labels\".\"photo_size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.treasury_settings": { + "name": "treasury_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "vat_regime": { + "name": "vat_regime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_due_day": { + "name": "vat_due_day", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "alert_threshold": { + "name": "alert_threshold", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "treasury_settings_est_uq": { + "name": "treasury_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "treasury_settings_organization_id_organizations_id_fk": { + "name": "treasury_settings_organization_id_organizations_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "treasury_settings_establishment_id_establishments_id_fk": { + "name": "treasury_settings_establishment_id_establishments_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "treasury_settings_updated_by_users_id_fk": { + "name": "treasury_settings_updated_by_users_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "treasury_settings_vat_ck": { + "name": "treasury_settings_vat_ck", + "value": "(\"treasury_settings\".\"vat_regime\" IS NULL OR \"treasury_settings\".\"vat_regime\" IN ('monthly', 'quarterly')) AND (\"treasury_settings\".\"vat_due_day\" IS NULL OR \"treasury_settings\".\"vat_due_day\" BETWEEN 1 AND 31)" + } + }, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "totp_secret_enc": { + "name": "totp_secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "totp_enabled_at": { + "name": "totp_enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "totp_last_step": { + "name": "totp_last_step", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "password_changed_at": { + "name": "password_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "failed_login_count": { + "name": "failed_login_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "disabled_at": { + "name": "disabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "message_emails": { + "name": "message_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notification_phone": { + "name": "notification_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seen_release": { + "name": "seen_release", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_login_at": { + "name": "last_login_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "platform_admin": { + "name": "platform_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "email_verification_pending": { + "name": "email_verification_pending", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by_organization_id": { + "name": "created_by_organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_lower_uq": { + "name": "users_email_lower_uq", + "columns": [ + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_created_by_organization_id_organizations_id_fk": { + "name": "users_created_by_organization_id_organizations_id_fk", + "tableFrom": "users", + "tableTo": "organizations", + "columnsFrom": [ + "created_by_organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.waiter_closings": { + "name": "waiter_closings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "waiter_label": { + "name": "waiter_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "waiter_key": { + "name": "waiter_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "groupe": { + "name": "groupe", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "cb": { + "name": "cb", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "especes": { + "name": "especes", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "autre": { + "name": "autre", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recorded_at": { + "name": "recorded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "waiter_closings_est_idx": { + "name": "waiter_closings_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "waiter_closings_organization_id_organizations_id_fk": { + "name": "waiter_closings_organization_id_organizations_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "waiter_closings_establishment_id_establishments_id_fk": { + "name": "waiter_closings_establishment_id_establishments_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "waiter_closings_recorded_by_users_id_fk": { + "name": "waiter_closings_recorded_by_users_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "waiter_closings_cancelled_by_users_id_fk": { + "name": "waiter_closings_cancelled_by_users_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "waiter_closings_amounts_ck": { + "name": "waiter_closings_amounts_ck", + "value": "\"waiter_closings\".\"groupe\" >= 0 AND \"waiter_closings\".\"cb\" >= 0 AND \"waiter_closings\".\"especes\" >= 0 AND \"waiter_closings\".\"autre\" >= 0" + }, + "waiter_closings_key_ck": { + "name": "waiter_closings_key_ck", + "value": "length(\"waiter_closings\".\"waiter_key\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + } + }, + "enums": { + "public.connection_status": { + "name": "connection_status", + "schema": "public", + "values": [ + "not_configured", + "pending_verification", + "connected", + "error", + "disabled" + ] + }, + "public.data_status": { + "name": "data_status", + "schema": "public", + "values": [ + "real_validated", + "real_unvalidated", + "provisional", + "estimated", + "forecast", + "missing" + ] + }, + "public.import_status": { + "name": "import_status", + "schema": "public", + "values": [ + "completed", + "rejected", + "reverted" + ] + }, + "public.member_role": { + "name": "member_role", + "schema": "public", + "values": [ + "owner", + "admin", + "director", + "manager", + "accountant", + "chef", + "staff", + "cuisine", + "viewer", + "rh", + "controller", + "purchasing" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/0125_snapshot.json b/drizzle/meta/0125_snapshot.json new file mode 100644 index 00000000..f7a44df3 --- /dev/null +++ b/drizzle/meta/0125_snapshot.json @@ -0,0 +1,40718 @@ +{ + "id": "0416a0c1-b430-4ac9-8475-d9e6bc09da02", + "prevId": "ad83bcf3-8333-41a4-960b-baee3b9282a9", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.absence_requests": { + "name": "absence_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "part": { + "name": "part", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'journee'" + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "absence_requests_emp_idx": { + "name": "absence_requests_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "absence_requests_organization_id_organizations_id_fk": { + "name": "absence_requests_organization_id_organizations_id_fk", + "tableFrom": "absence_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "absence_requests_employee_id_employees_id_fk": { + "name": "absence_requests_employee_id_employees_id_fk", + "tableFrom": "absence_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "absence_requests_decided_by_users_id_fk": { + "name": "absence_requests_decided_by_users_id_fk", + "tableFrom": "absence_requests", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "absence_requests_created_by_users_id_fk": { + "name": "absence_requests_created_by_users_id_fk", + "tableFrom": "absence_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "absence_requests_status_ck": { + "name": "absence_requests_status_ck", + "value": "\"absence_requests\".\"status\" IN ('en_attente', 'acceptee', 'refusee', 'annulee')" + }, + "absence_requests_dates_ck": { + "name": "absence_requests_dates_ck", + "value": "\"absence_requests\".\"end_date\" >= \"absence_requests\".\"start_date\"" + } + }, + "isRLSEnabled": false + }, + "public.account_invites": { + "name": "account_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'invite'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "account_invites_token_uq": { + "name": "account_invites_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "account_invites_user_idx": { + "name": "account_invites_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_invites_organization_id_organizations_id_fk": { + "name": "account_invites_organization_id_organizations_id_fk", + "tableFrom": "account_invites", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_invites_user_id_users_id_fk": { + "name": "account_invites_user_id_users_id_fk", + "tableFrom": "account_invites", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_invites_created_by_users_id_fk": { + "name": "account_invites_created_by_users_id_fk", + "tableFrom": "account_invites", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "account_invites_purpose_ck": { + "name": "account_invites_purpose_ck", + "value": "\"account_invites\".\"purpose\" IN ('invite', 'reset', 'verify')" + } + }, + "isRLSEnabled": false + }, + "public.ai_actions": { + "name": "ai_actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "source_href": { + "name": "source_href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "discard_reason": { + "name": "discard_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_actions_org_idx": { + "name": "ai_actions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_actions_pending_uq": { + "name": "ai_actions_pending_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_actions\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_actions_organization_id_organizations_id_fk": { + "name": "ai_actions_organization_id_organizations_id_fk", + "tableFrom": "ai_actions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_actions_created_by_users_id_fk": { + "name": "ai_actions_created_by_users_id_fk", + "tableFrom": "ai_actions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "ai_actions_decided_by_users_id_fk": { + "name": "ai_actions_decided_by_users_id_fk", + "tableFrom": "ai_actions", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_actions_kind_ck": { + "name": "ai_actions_kind_ck", + "value": "\"ai_actions\".\"kind\" IN ('negotiation_email', 'price_change')" + }, + "ai_actions_status_ck": { + "name": "ai_actions_status_ck", + "value": "\"ai_actions\".\"status\" IN ('pending', 'sent', 'applied', 'done_manual', 'discarded')" + }, + "ai_actions_decided_ck": { + "name": "ai_actions_decided_ck", + "value": "\"ai_actions\".\"status\" = 'pending' OR \"ai_actions\".\"decided_at\" IS NOT NULL" + }, + "ai_actions_discarded_ck": { + "name": "ai_actions_discarded_ck", + "value": "\"ai_actions\".\"status\" <> 'discarded' OR \"ai_actions\".\"discard_reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.ai_conversations": { + "name": "ai_conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_conversations_user_idx": { + "name": "ai_conversations_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_conversations_organization_id_organizations_id_fk": { + "name": "ai_conversations_organization_id_organizations_id_fk", + "tableFrom": "ai_conversations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_conversations_user_id_users_id_fk": { + "name": "ai_conversations_user_id_users_id_fk", + "tableFrom": "ai_conversations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_messages": { + "name": "ai_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tools": { + "name": "tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_messages_conv_idx": { + "name": "ai_messages_conv_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_messages_org_idx": { + "name": "ai_messages_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_messages_organization_id_organizations_id_fk": { + "name": "ai_messages_organization_id_organizations_id_fk", + "tableFrom": "ai_messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_messages_conversation_id_ai_conversations_id_fk": { + "name": "ai_messages_conversation_id_ai_conversations_id_fk", + "tableFrom": "ai_messages", + "tableTo": "ai_conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_messages_role_ck": { + "name": "ai_messages_role_ck", + "value": "\"ai_messages\".\"role\" IN ('user', 'assistant')" + } + }, + "isRLSEnabled": false + }, + "public.ai_reco_dismissals": { + "name": "ai_reco_dismissals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reco_id": { + "name": "reco_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "until": { + "name": "until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "dismissed_by": { + "name": "dismissed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_reco_dismissals_uq": { + "name": "ai_reco_dismissals_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reco_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_reco_dismissals_organization_id_organizations_id_fk": { + "name": "ai_reco_dismissals_organization_id_organizations_id_fk", + "tableFrom": "ai_reco_dismissals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_reco_dismissals_dismissed_by_users_id_fk": { + "name": "ai_reco_dismissals_dismissed_by_users_id_fk", + "tableFrom": "ai_reco_dismissals", + "tableTo": "users", + "columnsFrom": [ + "dismissed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_reco_dismissals_reason_ck": { + "name": "ai_reco_dismissals_reason_ck", + "value": "length(trim(\"ai_reco_dismissals\".\"reason\")) >= 3" + } + }, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "before": { + "name": "before", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "after": { + "name": "after", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_org_idx": { + "name": "audit_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_log_organization_id_organizations_id_fk": { + "name": "audit_log_organization_id_organizations_id_fk", + "tableFrom": "audit_log", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "audit_log_user_id_users_id_fk": { + "name": "audit_log_user_id_users_id_fk", + "tableFrom": "audit_log", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_throttle": { + "name": "auth_throttle", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_throttle_ip_idx": { + "name": "auth_throttle_ip_idx", + "columns": [ + { + "expression": "ip", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "approver_id": { + "name": "approver_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "delivered": { + "name": "delivered", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_approvals_once_uq": { + "name": "automation_approvals_once_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_approvals_org_idx": { + "name": "automation_approvals_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_approvals_organization_id_organizations_id_fk": { + "name": "automation_approvals_organization_id_organizations_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_approvals_rule_id_automation_rules_id_fk": { + "name": "automation_approvals_rule_id_automation_rules_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_approvals_approver_id_users_id_fk": { + "name": "automation_approvals_approver_id_users_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "users", + "columnsFrom": [ + "approver_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "automation_approvals_decided_by_users_id_fk": { + "name": "automation_approvals_decided_by_users_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_approvals_status_ck": { + "name": "automation_approvals_status_ck", + "value": "\"automation_approvals\".\"status\" IN ('pending', 'approved', 'rejected')" + }, + "automation_approvals_reason_ck": { + "name": "automation_approvals_reason_ck", + "value": "\"automation_approvals\".\"status\" <> 'rejected' OR \"automation_approvals\".\"reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.automation_drafts": { + "name": "automation_drafts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rule_name": { + "name": "rule_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "source_href": { + "name": "source_href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prepared_for": { + "name": "prepared_for", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "discard_reason": { + "name": "discard_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_entity_type": { + "name": "result_entity_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_entity_id": { + "name": "result_entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_drafts_org_idx": { + "name": "automation_drafts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_drafts_est_idx": { + "name": "automation_drafts_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_drafts_organization_id_organizations_id_fk": { + "name": "automation_drafts_organization_id_organizations_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_drafts_establishment_id_establishments_id_fk": { + "name": "automation_drafts_establishment_id_establishments_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_drafts_rule_id_automation_rules_id_fk": { + "name": "automation_drafts_rule_id_automation_rules_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "automation_drafts_prepared_for_users_id_fk": { + "name": "automation_drafts_prepared_for_users_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "users", + "columnsFrom": [ + "prepared_for" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "automation_drafts_decided_by_users_id_fk": { + "name": "automation_drafts_decided_by_users_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_drafts_kind_ck": { + "name": "automation_drafts_kind_ck", + "value": "\"automation_drafts\".\"kind\" IN ('purchase_order', 'credit_request', 'maintenance_request')" + }, + "automation_drafts_status_ck": { + "name": "automation_drafts_status_ck", + "value": "\"automation_drafts\".\"status\" IN ('pending', 'validated', 'discarded', 'expired')" + }, + "automation_drafts_validated_ck": { + "name": "automation_drafts_validated_ck", + "value": "\"automation_drafts\".\"status\" <> 'validated' OR (\"automation_drafts\".\"decided_by\" IS NOT NULL AND \"automation_drafts\".\"result_entity_type\" IS NOT NULL)" + }, + "automation_drafts_discarded_ck": { + "name": "automation_drafts_discarded_ck", + "value": "\"automation_drafts\".\"status\" <> 'discarded' OR \"automation_drafts\".\"discard_reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.automation_occurrences": { + "name": "automation_occurrences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "occurrence_key": { + "name": "occurrence_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "draft_id": { + "name": "draft_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_occurrences_uq": { + "name": "automation_occurrences_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_occurrences_org_key_idx": { + "name": "automation_occurrences_org_key_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_occurrences_organization_id_organizations_id_fk": { + "name": "automation_occurrences_organization_id_organizations_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_occurrences_rule_id_automation_rules_id_fk": { + "name": "automation_occurrences_rule_id_automation_rules_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_occurrences_draft_id_automation_drafts_id_fk": { + "name": "automation_occurrences_draft_id_automation_drafts_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "automation_drafts", + "columnsFrom": [ + "draft_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_pending": { + "name": "automation_pending", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_pending_org_idx": { + "name": "automation_pending_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_pending_organization_id_organizations_id_fk": { + "name": "automation_pending_organization_id_organizations_id_fk", + "tableFrom": "automation_pending", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_pending_rule_id_automation_rules_id_fk": { + "name": "automation_pending_rule_id_automation_rules_id_fk", + "tableFrom": "automation_pending", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_pending_user_id_users_id_fk": { + "name": "automation_pending_user_id_users_id_fk", + "tableFrom": "automation_pending", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "automation_pending_rule_id_user_id_item_key_pk": { + "name": "automation_pending_rule_id_user_id_item_key_pk", + "columns": [ + "rule_id", + "user_id", + "item_key" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_rules": { + "name": "automation_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "min_severity": { + "name": "min_severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'warning'" + }, + "recipient_ids": { + "name": "recipient_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "by_email": { + "name": "by_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'notify'" + }, + "params": { + "name": "params", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conditions": { + "name": "conditions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "delay_minutes": { + "name": "delay_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "approver_id": { + "name": "approver_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_triggered_at": { + "name": "last_triggered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_rules_org_idx": { + "name": "automation_rules_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_rules_organization_id_organizations_id_fk": { + "name": "automation_rules_organization_id_organizations_id_fk", + "tableFrom": "automation_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_rules_establishment_id_establishments_id_fk": { + "name": "automation_rules_establishment_id_establishments_id_fk", + "tableFrom": "automation_rules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_rules_approver_id_users_id_fk": { + "name": "automation_rules_approver_id_users_id_fk", + "tableFrom": "automation_rules", + "tableTo": "users", + "columnsFrom": [ + "approver_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "automation_rules_created_by_users_id_fk": { + "name": "automation_rules_created_by_users_id_fk", + "tableFrom": "automation_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_rules_severity_ck": { + "name": "automation_rules_severity_ck", + "value": "\"automation_rules\".\"min_severity\" IN ('warning', 'danger')" + }, + "automation_rules_action_ck": { + "name": "automation_rules_action_ck", + "value": "\"automation_rules\".\"action\" IN ('notify', 'draft_purchase_order', 'draft_credit_request', 'draft_maintenance_request')" + }, + "automation_rules_delay_ck": { + "name": "automation_rules_delay_ck", + "value": "\"automation_rules\".\"delay_minutes\" >= 0 AND \"automation_rules\".\"delay_minutes\" <= 10080" + } + }, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emailed": { + "name": "emailed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_runs_once_uq": { + "name": "automation_runs_once_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_runs_org_idx": { + "name": "automation_runs_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_runs_organization_id_organizations_id_fk": { + "name": "automation_runs_organization_id_organizations_id_fk", + "tableFrom": "automation_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_runs_rule_id_automation_rules_id_fk": { + "name": "automation_runs_rule_id_automation_rules_id_fk", + "tableFrom": "automation_runs", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_runs_user_id_users_id_fk": { + "name": "automation_runs_user_id_users_id_fk", + "tableFrom": "automation_runs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_settings": { + "name": "automation_settings", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "paused": { + "name": "paused", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_by": { + "name": "paused_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "paused_at": { + "name": "paused_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "automation_settings_organization_id_organizations_id_fk": { + "name": "automation_settings_organization_id_organizations_id_fk", + "tableFrom": "automation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_settings_paused_by_users_id_fk": { + "name": "automation_settings_paused_by_users_id_fk", + "tableFrom": "automation_settings", + "tableTo": "users", + "columnsFrom": [ + "paused_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bank_accounts": { + "name": "bank_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bank_name": { + "name": "bank_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban_last4": { + "name": "iban_last4", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "opening_balance": { + "name": "opening_balance", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "opening_date": { + "name": "opening_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "alert_threshold": { + "name": "alert_threshold", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_accounts_org_idx": { + "name": "bank_accounts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_accounts_organization_id_organizations_id_fk": { + "name": "bank_accounts_organization_id_organizations_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_accounts_establishment_id_establishments_id_fk": { + "name": "bank_accounts_establishment_id_establishments_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_accounts_created_by_users_id_fk": { + "name": "bank_accounts_created_by_users_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_accounts_iban_ck": { + "name": "bank_accounts_iban_ck", + "value": "\"bank_accounts\".\"iban_last4\" IS NULL OR \"bank_accounts\".\"iban_last4\" ~ '^[0-9A-Z]{4}$'" + } + }, + "isRLSEnabled": false + }, + "public.bank_imports": { + "name": "bank_imports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_sha256": { + "name": "file_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rows_total": { + "name": "rows_total", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "rows_inserted": { + "name": "rows_inserted", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "period_from": { + "name": "period_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "period_to": { + "name": "period_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_imports_account_idx": { + "name": "bank_imports_account_idx", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_imports_organization_id_organizations_id_fk": { + "name": "bank_imports_organization_id_organizations_id_fk", + "tableFrom": "bank_imports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_imports_account_id_bank_accounts_id_fk": { + "name": "bank_imports_account_id_bank_accounts_id_fk", + "tableFrom": "bank_imports", + "tableTo": "bank_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_imports_created_by_users_id_fk": { + "name": "bank_imports_created_by_users_id_fk", + "tableFrom": "bank_imports", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bank_rules": { + "name": "bank_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'any'" + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_rules_uq": { + "name": "bank_rules_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"keyword\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "direction", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_rules_organization_id_organizations_id_fk": { + "name": "bank_rules_organization_id_organizations_id_fk", + "tableFrom": "bank_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_rules_created_by_users_id_fk": { + "name": "bank_rules_created_by_users_id_fk", + "tableFrom": "bank_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_rules_direction_ck": { + "name": "bank_rules_direction_ck", + "value": "\"bank_rules\".\"direction\" IN ('in', 'out', 'any')" + } + }, + "isRLSEnabled": false + }, + "public.bank_transactions": { + "name": "bank_transactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "import_id": { + "name": "import_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "booking_date": { + "name": "booking_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "value_date": { + "name": "value_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "balance_after": { + "name": "balance_after", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category_source": { + "name": "category_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_tx_row_uq": { + "name": "bank_tx_row_uq", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "bank_tx_invoice_uq": { + "name": "bank_tx_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"bank_transactions\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "bank_tx_period_idx": { + "name": "bank_tx_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "booking_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_transactions_organization_id_organizations_id_fk": { + "name": "bank_transactions_organization_id_organizations_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_transactions_establishment_id_establishments_id_fk": { + "name": "bank_transactions_establishment_id_establishments_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_account_id_bank_accounts_id_fk": { + "name": "bank_transactions_account_id_bank_accounts_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "bank_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_import_id_bank_imports_id_fk": { + "name": "bank_transactions_import_id_bank_imports_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "bank_imports", + "columnsFrom": [ + "import_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "bank_transactions_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_tx_amount_ck": { + "name": "bank_tx_amount_ck", + "value": "\"bank_transactions\".\"amount\" <> 0" + } + }, + "isRLSEnabled": false + }, + "public.booking_button_clicks": { + "name": "booking_button_clicks", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "placement": { + "name": "placement", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "clicks": { + "name": "clicks", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "booking_button_clicks_establishment_id_establishments_id_fk": { + "name": "booking_button_clicks_establishment_id_establishments_id_fk", + "tableFrom": "booking_button_clicks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_button_clicks_organization_id_organizations_id_fk": { + "name": "booking_button_clicks_organization_id_organizations_id_fk", + "tableFrom": "booking_button_clicks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "booking_button_clicks_establishment_id_day_placement_target_pk": { + "name": "booking_button_clicks_establishment_id_day_placement_target_pk", + "columns": [ + "establishment_id", + "day", + "placement", + "target" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "booking_button_clicks_placement_ck": { + "name": "booking_button_clicks_placement_ck", + "value": "\"booking_button_clicks\".\"placement\" IN ('instagram', 'google', 'site')" + }, + "booking_button_clicks_target_ck": { + "name": "booking_button_clicks_target_ck", + "value": "\"booking_button_clicks\".\"target\" IN ('altair', 'thefork', 'opentable', 'zenchef')" + } + }, + "isRLSEnabled": false + }, + "public.booking_channels": { + "name": "booking_channels", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "instagram_target": { + "name": "instagram_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "google_target": { + "name": "google_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "site_target": { + "name": "site_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "thefork_url": { + "name": "thefork_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "opentable_url": { + "name": "opentable_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "zenchef_url": { + "name": "zenchef_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "booking_channels_establishment_id_establishments_id_fk": { + "name": "booking_channels_establishment_id_establishments_id_fk", + "tableFrom": "booking_channels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_channels_organization_id_organizations_id_fk": { + "name": "booking_channels_organization_id_organizations_id_fk", + "tableFrom": "booking_channels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_channels_updated_by_users_id_fk": { + "name": "booking_channels_updated_by_users_id_fk", + "tableFrom": "booking_channels", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "booking_channels_targets_ck": { + "name": "booking_channels_targets_ck", + "value": "\"booking_channels\".\"instagram_target\" IN ('altair', 'thefork', 'opentable', 'zenchef') AND \"booking_channels\".\"google_target\" IN ('altair', 'thefork', 'opentable', 'zenchef') AND \"booking_channels\".\"site_target\" IN ('altair', 'thefork', 'opentable', 'zenchef')" + }, + "booking_channels_urls_ck": { + "name": "booking_channels_urls_ck", + "value": "(\"booking_channels\".\"thefork_url\" IS NULL OR \"booking_channels\".\"thefork_url\" LIKE 'https://%') AND (\"booking_channels\".\"opentable_url\" IS NULL OR \"booking_channels\".\"opentable_url\" LIKE 'https://%') AND (\"booking_channels\".\"zenchef_url\" IS NULL OR \"booking_channels\".\"zenchef_url\" LIKE 'https://%')" + } + }, + "isRLSEnabled": false + }, + "public.business_document_versions": { + "name": "business_document_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version_no": { + "name": "version_no", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "replaced_by": { + "name": "replaced_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "replaced_at": { + "name": "replaced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "business_document_versions_uq": { + "name": "business_document_versions_uq", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version_no", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_document_versions_sha_idx": { + "name": "business_document_versions_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "business_document_versions_organization_id_organizations_id_fk": { + "name": "business_document_versions_organization_id_organizations_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "business_document_versions_document_id_business_documents_id_fk": { + "name": "business_document_versions_document_id_business_documents_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "business_document_versions_replaced_by_users_id_fk": { + "name": "business_document_versions_replaced_by_users_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "users", + "columnsFrom": [ + "replaced_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "business_document_versions_size_ck": { + "name": "business_document_versions_size_ck", + "value": "\"business_document_versions\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.business_documents": { + "name": "business_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "party": { + "name": "party", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference": { + "name": "reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "issued_on": { + "name": "issued_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "expires_on": { + "name": "expires_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reminder_days": { + "name": "reminder_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "annual_cost": { + "name": "annual_cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_version": { + "name": "file_version", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notice_on": { + "name": "notice_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "sensitivity": { + "name": "sensitivity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'normal'" + }, + "duplicate_of_id": { + "name": "duplicate_of_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "replaced_by_id": { + "name": "replaced_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "checklist_code": { + "name": "checklist_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "business_documents_org_idx": { + "name": "business_documents_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_documents_checklist_uq": { + "name": "business_documents_checklist_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checklist_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"business_documents\".\"checklist_code\" IS NOT NULL AND \"business_documents\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_documents_sha_idx": { + "name": "business_documents_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "business_documents_organization_id_organizations_id_fk": { + "name": "business_documents_organization_id_organizations_id_fk", + "tableFrom": "business_documents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "business_documents_establishment_id_establishments_id_fk": { + "name": "business_documents_establishment_id_establishments_id_fk", + "tableFrom": "business_documents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "business_documents_duplicate_of_id_business_documents_id_fk": { + "name": "business_documents_duplicate_of_id_business_documents_id_fk", + "tableFrom": "business_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "duplicate_of_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "business_documents_replaced_by_id_business_documents_id_fk": { + "name": "business_documents_replaced_by_id_business_documents_id_fk", + "tableFrom": "business_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "replaced_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "business_documents_created_by_users_id_fk": { + "name": "business_documents_created_by_users_id_fk", + "tableFrom": "business_documents", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "business_documents_size_ck": { + "name": "business_documents_size_ck", + "value": "\"business_documents\".\"size\" IS NULL OR \"business_documents\".\"size\" <= 5242880" + }, + "business_documents_reminder_ck": { + "name": "business_documents_reminder_ck", + "value": "\"business_documents\".\"reminder_days\" BETWEEN 0 AND 365" + }, + "business_documents_sensitivity_ck": { + "name": "business_documents_sensitivity_ck", + "value": "\"business_documents\".\"sensitivity\" IN ('normal', 'confidentiel', 'restreint')" + }, + "business_documents_notice_ck": { + "name": "business_documents_notice_ck", + "value": "\"business_documents\".\"notice_on\" IS NULL OR \"business_documents\".\"expires_on\" IS NULL OR \"business_documents\".\"notice_on\" <= \"business_documents\".\"expires_on\"" + } + }, + "isRLSEnabled": false + }, + "public.campaign_recipients": { + "name": "campaign_recipients", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "campaign_id": { + "name": "campaign_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unsubscribe_token_hash": { + "name": "unsubscribe_token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unsubscribed_at": { + "name": "unsubscribed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "campaign_recipients_token_uq": { + "name": "campaign_recipients_token_uq", + "columns": [ + { + "expression": "unsubscribe_token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "campaign_recipients_campaign_customer_uq": { + "name": "campaign_recipients_campaign_customer_uq", + "columns": [ + { + "expression": "campaign_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "campaign_recipients_customer_idx": { + "name": "campaign_recipients_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "campaign_recipients_organization_id_organizations_id_fk": { + "name": "campaign_recipients_organization_id_organizations_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "campaign_recipients_campaign_id_marketing_campaigns_id_fk": { + "name": "campaign_recipients_campaign_id_marketing_campaigns_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "marketing_campaigns", + "columnsFrom": [ + "campaign_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "campaign_recipients_customer_id_customers_id_fk": { + "name": "campaign_recipients_customer_id_customers_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidates": { + "name": "candidates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "job_opening_id": { + "name": "job_opening_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'nouveau'" + }, + "stage_changed_at": { + "name": "stage_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "interview_at": { + "name": "interview_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "rating": { + "name": "rating", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refusal_reason": { + "name": "refusal_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_contact_at": { + "name": "last_contact_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidates_org_idx": { + "name": "candidates_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stage", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidates_opening_idx": { + "name": "candidates_opening_idx", + "columns": [ + { + "expression": "job_opening_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidates_organization_id_organizations_id_fk": { + "name": "candidates_organization_id_organizations_id_fk", + "tableFrom": "candidates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidates_establishment_id_establishments_id_fk": { + "name": "candidates_establishment_id_establishments_id_fk", + "tableFrom": "candidates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidates_job_opening_id_job_openings_id_fk": { + "name": "candidates_job_opening_id_job_openings_id_fk", + "tableFrom": "candidates", + "tableTo": "job_openings", + "columnsFrom": [ + "job_opening_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidates_employee_id_employees_id_fk": { + "name": "candidates_employee_id_employees_id_fk", + "tableFrom": "candidates", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidates_created_by_users_id_fk": { + "name": "candidates_created_by_users_id_fk", + "tableFrom": "candidates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "candidates_stage_ck": { + "name": "candidates_stage_ck", + "value": "\"candidates\".\"stage\" IN ('nouveau', 'preselection', 'entretien', 'essai', 'offre', 'embauche', 'refuse', 'desiste')" + }, + "candidates_rating_ck": { + "name": "candidates_rating_ck", + "value": "\"candidates\".\"rating\" IS NULL OR \"candidates\".\"rating\" BETWEEN 1 AND 5" + } + }, + "isRLSEnabled": false + }, + "public.cash_counts": { + "name": "cash_counts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "denominations": { + "name": "denominations", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "counted_total": { + "name": "counted_total", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "counted_by": { + "name": "counted_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counted_at": { + "name": "counted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_counts_est_idx": { + "name": "cash_counts_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_counts_organization_id_organizations_id_fk": { + "name": "cash_counts_organization_id_organizations_id_fk", + "tableFrom": "cash_counts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_counts_establishment_id_establishments_id_fk": { + "name": "cash_counts_establishment_id_establishments_id_fk", + "tableFrom": "cash_counts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_counts_counted_by_users_id_fk": { + "name": "cash_counts_counted_by_users_id_fk", + "tableFrom": "cash_counts", + "tableTo": "users", + "columnsFrom": [ + "counted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cash_counts_cancelled_by_users_id_fk": { + "name": "cash_counts_cancelled_by_users_id_fk", + "tableFrom": "cash_counts", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_counts_kind_ck": { + "name": "cash_counts_kind_ck", + "value": "\"cash_counts\".\"kind\" IN ('fermeture', 'ouverture')" + }, + "cash_counts_amounts_ck": { + "name": "cash_counts_amounts_ck", + "value": "\"cash_counts\".\"counted_total\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.cash_plan_items": { + "name": "cash_plan_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "recurrence": { + "name": "recurrence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'once'" + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_plan_org_idx": { + "name": "cash_plan_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_plan_items_organization_id_organizations_id_fk": { + "name": "cash_plan_items_organization_id_organizations_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_plan_items_establishment_id_establishments_id_fk": { + "name": "cash_plan_items_establishment_id_establishments_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_plan_items_created_by_users_id_fk": { + "name": "cash_plan_items_created_by_users_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_plan_recurrence_ck": { + "name": "cash_plan_recurrence_ck", + "value": "\"cash_plan_items\".\"recurrence\" IN ('once', 'weekly', 'monthly', 'quarterly')" + }, + "cash_plan_amount_ck": { + "name": "cash_plan_amount_ck", + "value": "\"cash_plan_items\".\"amount\" <> 0" + }, + "cash_plan_end_ck": { + "name": "cash_plan_end_ck", + "value": "\"cash_plan_items\".\"end_date\" IS NULL OR \"cash_plan_items\".\"end_date\" >= \"cash_plan_items\".\"start_date\"" + } + }, + "isRLSEnabled": false + }, + "public.cash_withdrawals": { + "name": "cash_withdrawals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recorded_at": { + "name": "recorded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_withdrawals_est_idx": { + "name": "cash_withdrawals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_withdrawals_organization_id_organizations_id_fk": { + "name": "cash_withdrawals_organization_id_organizations_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_withdrawals_establishment_id_establishments_id_fk": { + "name": "cash_withdrawals_establishment_id_establishments_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_withdrawals_recorded_by_users_id_fk": { + "name": "cash_withdrawals_recorded_by_users_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cash_withdrawals_cancelled_by_users_id_fk": { + "name": "cash_withdrawals_cancelled_by_users_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_withdrawals_kind_ck": { + "name": "cash_withdrawals_kind_ck", + "value": "\"cash_withdrawals\".\"kind\" IN ('fournisseur', 'banque', 'pourboires', 'avance', 'autre')" + }, + "cash_withdrawals_amount_ck": { + "name": "cash_withdrawals_amount_ck", + "value": "\"cash_withdrawals\".\"amount\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.catalog_price_changes": { + "name": "catalog_price_changes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "old_price_ht": { + "name": "old_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "new_price_ht": { + "name": "new_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "catalog_price_changes_org_idx": { + "name": "catalog_price_changes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "catalog_price_changes_organization_id_organizations_id_fk": { + "name": "catalog_price_changes_organization_id_organizations_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "catalog_price_changes_item_id_purchase_items_id_fk": { + "name": "catalog_price_changes_item_id_purchase_items_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "catalog_price_changes_supplier_id_suppliers_id_fk": { + "name": "catalog_price_changes_supplier_id_suppliers_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "catalog_price_changes_created_by_users_id_fk": { + "name": "catalog_price_changes_created_by_users_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "catalog_price_changes_source_ck": { + "name": "catalog_price_changes_source_ck", + "value": "\"catalog_price_changes\".\"source\" IN ('import', 'manual')" + }, + "catalog_price_changes_price_ck": { + "name": "catalog_price_changes_price_ck", + "value": "\"catalog_price_changes\".\"new_price_ht\" >= 0 AND (\"catalog_price_changes\".\"old_price_ht\" IS NULL OR \"catalog_price_changes\".\"old_price_ht\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.checklist_run_photos": { + "name": "checklist_run_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_index": { + "name": "item_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_run_photos_uq": { + "name": "checklist_run_photos_uq", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_run_photos_organization_id_organizations_id_fk": { + "name": "checklist_run_photos_organization_id_organizations_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_run_photos_establishment_id_establishments_id_fk": { + "name": "checklist_run_photos_establishment_id_establishments_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_run_photos_run_id_checklist_runs_id_fk": { + "name": "checklist_run_photos_run_id_checklist_runs_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "checklist_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checklist_runs": { + "name": "checklist_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "answers": { + "name": "answers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "yes_count": { + "name": "yes_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "no_count": { + "name": "no_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "na_count": { + "name": "na_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moment": { + "name": "moment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_count": { + "name": "photo_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_runs_est_idx": { + "name": "checklist_runs_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_runs_organization_id_organizations_id_fk": { + "name": "checklist_runs_organization_id_organizations_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_runs_establishment_id_establishments_id_fk": { + "name": "checklist_runs_establishment_id_establishments_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_runs_template_id_checklist_templates_id_fk": { + "name": "checklist_runs_template_id_checklist_templates_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "checklist_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_runs_recorded_by_users_id_fk": { + "name": "checklist_runs_recorded_by_users_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checklist_runs_cancelled_by_users_id_fk": { + "name": "checklist_runs_cancelled_by_users_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checklist_templates": { + "name": "checklist_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "items": { + "name": "items", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "due_by": { + "name": "due_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moment": { + "name": "moment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_items": { + "name": "photo_items", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_templates_est_idx": { + "name": "checklist_templates_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_templates_organization_id_organizations_id_fk": { + "name": "checklist_templates_organization_id_organizations_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_templates_establishment_id_establishments_id_fk": { + "name": "checklist_templates_establishment_id_establishments_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_templates_created_by_users_id_fk": { + "name": "checklist_templates_created_by_users_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "checklist_templates_moment_ck": { + "name": "checklist_templates_moment_ck", + "value": "\"checklist_templates\".\"moment\" IS NULL OR \"checklist_templates\".\"moment\" IN ('ouverture', 'service', 'fermeture')" + } + }, + "isRLSEnabled": false + }, + "public.cleaning_records": { + "name": "cleaning_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_records_est_idx": { + "name": "cleaning_records_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cleaning_records_task_idx": { + "name": "cleaning_records_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_records_organization_id_organizations_id_fk": { + "name": "cleaning_records_organization_id_organizations_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_records_establishment_id_establishments_id_fk": { + "name": "cleaning_records_establishment_id_establishments_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cleaning_records_task_id_cleaning_tasks_id_fk": { + "name": "cleaning_records_task_id_cleaning_tasks_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "cleaning_tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cleaning_records_recorded_by_users_id_fk": { + "name": "cleaning_records_recorded_by_users_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cleaning_records_cancelled_by_users_id_fk": { + "name": "cleaning_records_cancelled_by_users_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cleaning_tasks": { + "name": "cleaning_tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "due_by": { + "name": "due_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_tasks_zone_idx": { + "name": "cleaning_tasks_zone_idx", + "columns": [ + { + "expression": "zone_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_tasks_organization_id_organizations_id_fk": { + "name": "cleaning_tasks_organization_id_organizations_id_fk", + "tableFrom": "cleaning_tasks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_tasks_zone_id_cleaning_zones_id_fk": { + "name": "cleaning_tasks_zone_id_cleaning_zones_id_fk", + "tableFrom": "cleaning_tasks", + "tableTo": "cleaning_zones", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cleaning_tasks_freq_ck": { + "name": "cleaning_tasks_freq_ck", + "value": "\"cleaning_tasks\".\"frequency\" IN ('service', 'jour', 'semaine', 'mois')" + } + }, + "isRLSEnabled": false + }, + "public.cleaning_zones": { + "name": "cleaning_zones", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_zones_est_idx": { + "name": "cleaning_zones_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_zones_organization_id_organizations_id_fk": { + "name": "cleaning_zones_organization_id_organizations_id_fk", + "tableFrom": "cleaning_zones", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_zones_establishment_id_establishments_id_fk": { + "name": "cleaning_zones_establishment_id_establishments_id_fk", + "tableFrom": "cleaning_zones", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.clock_event_photos": { + "name": "clock_event_photos", + "schema": "", + "columns": { + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "clock_event_photos_org_idx": { + "name": "clock_event_photos_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "clock_event_photos_event_id_clock_events_id_fk": { + "name": "clock_event_photos_event_id_clock_events_id_fk", + "tableFrom": "clock_event_photos", + "tableTo": "clock_events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_event_photos_organization_id_organizations_id_fk": { + "name": "clock_event_photos_organization_id_organizations_id_fk", + "tableFrom": "clock_event_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "clock_event_photos_size_ck": { + "name": "clock_event_photos_size_ck", + "value": "octet_length(\"clock_event_photos\".\"data\") <= 307200" + } + }, + "isRLSEnabled": false + }, + "public.clock_events": { + "name": "clock_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ok'" + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geo_distance_m": { + "name": "geo_distance_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "geo_accuracy_m": { + "name": "geo_accuracy_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "clock_events_est_day_idx": { + "name": "clock_events_est_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "clock_events_emp_day_idx": { + "name": "clock_events_emp_day_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "clock_events_organization_id_organizations_id_fk": { + "name": "clock_events_organization_id_organizations_id_fk", + "tableFrom": "clock_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_establishment_id_establishments_id_fk": { + "name": "clock_events_establishment_id_establishments_id_fk", + "tableFrom": "clock_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_employee_id_employees_id_fk": { + "name": "clock_events_employee_id_employees_id_fk", + "tableFrom": "clock_events", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_created_by_users_id_fk": { + "name": "clock_events_created_by_users_id_fk", + "tableFrom": "clock_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "clock_events_reviewed_by_users_id_fk": { + "name": "clock_events_reviewed_by_users_id_fk", + "tableFrom": "clock_events", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "clock_events_kind_ck": { + "name": "clock_events_kind_ck", + "value": "\"clock_events\".\"kind\" IN ('in', 'break_start', 'break_end', 'out')" + }, + "clock_events_source_ck": { + "name": "clock_events_source_ck", + "value": "\"clock_events\".\"source\" IN ('borne', 'manuel', 'hors_ligne', 'qr', 'telephone')" + }, + "clock_events_status_ck": { + "name": "clock_events_status_ck", + "value": "\"clock_events\".\"status\" IN ('ok', 'a_valider', 'annule')" + } + }, + "isRLSEnabled": false + }, + "public.clock_pins": { + "name": "clock_pins", + "schema": "", + "columns": { + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pin_hash": { + "name": "pin_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "failed_attempts": { + "name": "failed_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "clock_pins_employee_id_employees_id_fk": { + "name": "clock_pins_employee_id_employees_id_fk", + "tableFrom": "clock_pins", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_pins_organization_id_organizations_id_fk": { + "name": "clock_pins_organization_id_organizations_id_fk", + "tableFrom": "clock_pins", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_pins_updated_by_users_id_fk": { + "name": "clock_pins_updated_by_users_id_fk", + "tableFrom": "clock_pins", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.clock_qr_settings": { + "name": "clock_qr_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone_enabled": { + "name": "phone_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "geo_lat": { + "name": "geo_lat", + "type": "numeric(9, 6)", + "primaryKey": false, + "notNull": false + }, + "geo_lng": { + "name": "geo_lng", + "type": "numeric(9, 6)", + "primaryKey": false, + "notNull": false + }, + "geo_radius_m": { + "name": "geo_radius_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "auto_apply": { + "name": "auto_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_apply_by": { + "name": "auto_apply_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "auto_applied_day": { + "name": "auto_applied_day", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "pin_by_employee": { + "name": "pin_by_employee", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "clock_qr_settings_establishment_id_establishments_id_fk": { + "name": "clock_qr_settings_establishment_id_establishments_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_qr_settings_organization_id_organizations_id_fk": { + "name": "clock_qr_settings_organization_id_organizations_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_qr_settings_auto_apply_by_users_id_fk": { + "name": "clock_qr_settings_auto_apply_by_users_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "users", + "columnsFrom": [ + "auto_apply_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "clock_qr_settings_updated_by_users_id_fk": { + "name": "clock_qr_settings_updated_by_users_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.companies": { + "name": "companies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "legal_name": { + "name": "legal_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "legal_form": { + "name": "legal_form", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siren": { + "name": "siren", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_number": { + "name": "vat_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_holding": { + "name": "is_holding", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hr_settings": { + "name": "hr_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "calendar_settings": { + "name": "calendar_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tax_settings": { + "name": "tax_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "companies_org_idx": { + "name": "companies_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "companies_organization_id_organizations_id_fk": { + "name": "companies_organization_id_organizations_id_fk", + "tableFrom": "companies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "companies_siren_ck": { + "name": "companies_siren_ck", + "value": "\"companies\".\"siren\" IS NULL OR \"companies\".\"siren\" ~ '^[0-9]{9}$'" + } + }, + "isRLSEnabled": false + }, + "public.company_holdings": { + "name": "company_holdings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "parent_company_id": { + "name": "parent_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "child_company_id": { + "name": "child_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "ownership_pct": { + "name": "ownership_pct", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": true + }, + "since": { + "name": "since", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "holdings_pair_uq": { + "name": "holdings_pair_uq", + "columns": [ + { + "expression": "parent_company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "child_company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "company_holdings_organization_id_organizations_id_fk": { + "name": "company_holdings_organization_id_organizations_id_fk", + "tableFrom": "company_holdings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "company_holdings_parent_company_id_companies_id_fk": { + "name": "company_holdings_parent_company_id_companies_id_fk", + "tableFrom": "company_holdings", + "tableTo": "companies", + "columnsFrom": [ + "parent_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "company_holdings_child_company_id_companies_id_fk": { + "name": "company_holdings_child_company_id_companies_id_fk", + "tableFrom": "company_holdings", + "tableTo": "companies", + "columnsFrom": [ + "child_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "holdings_pct_ck": { + "name": "holdings_pct_ck", + "value": "\"company_holdings\".\"ownership_pct\" > 0 AND \"company_holdings\".\"ownership_pct\" <= 100" + }, + "holdings_self_ck": { + "name": "holdings_self_ck", + "value": "\"company_holdings\".\"parent_company_id\" <> \"company_holdings\".\"child_company_id\"" + } + }, + "isRLSEnabled": false + }, + "public.compliance_items": { + "name": "compliance_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "obligation_id": { + "name": "obligation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "verified_by": { + "name": "verified_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "compliance_items_uq": { + "name": "compliance_items_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "obligation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "compliance_items_document_idx": { + "name": "compliance_items_document_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "compliance_items_organization_id_organizations_id_fk": { + "name": "compliance_items_organization_id_organizations_id_fk", + "tableFrom": "compliance_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "compliance_items_establishment_id_establishments_id_fk": { + "name": "compliance_items_establishment_id_establishments_id_fk", + "tableFrom": "compliance_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "compliance_items_obligation_id_regulatory_obligations_id_fk": { + "name": "compliance_items_obligation_id_regulatory_obligations_id_fk", + "tableFrom": "compliance_items", + "tableTo": "regulatory_obligations", + "columnsFrom": [ + "obligation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "compliance_items_document_id_business_documents_id_fk": { + "name": "compliance_items_document_id_business_documents_id_fk", + "tableFrom": "compliance_items", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "compliance_items_verified_by_users_id_fk": { + "name": "compliance_items_verified_by_users_id_fk", + "tableFrom": "compliance_items", + "tableTo": "users", + "columnsFrom": [ + "verified_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "compliance_items_status_ck": { + "name": "compliance_items_status_ck", + "value": "\"compliance_items\".\"status\" IN ('verifie', 'non_applicable_declare', 'en_cours')" + }, + "compliance_items_in_progress_ck": { + "name": "compliance_items_in_progress_ck", + "value": "\"compliance_items\".\"status\" <> 'en_cours' OR \"compliance_items\".\"note\" IS NOT NULL" + }, + "compliance_items_proof_ck": { + "name": "compliance_items_proof_ck", + "value": "(\"compliance_items\".\"status\" <> 'verifie' OR \"compliance_items\".\"document_id\" IS NOT NULL) AND (\"compliance_items\".\"status\" <> 'non_applicable_declare' OR \"compliance_items\".\"reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.context_observations": { + "name": "context_observations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "series": { + "name": "series", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "numeric(12, 3)", + "primaryKey": false, + "notNull": false + }, + "extra": { + "name": "extra", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "context_observations_uq": { + "name": "context_observations_uq", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "series", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "context_observations_source_ck": { + "name": "context_observations_source_ck", + "value": "\"context_observations\".\"source\" IN ('meteo_france', 'insee')" + } + }, + "isRLSEnabled": false + }, + "public.context_sources": { + "name": "context_sources", + "schema": "", + "columns": { + "source": { + "name": "source", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "last_attempt_at": { + "name": "last_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rows": { + "name": "rows", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_members": { + "name": "conversation_members", + "schema": "", + "columns": { + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_read_at": { + "name": "last_read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "notified_at": { + "name": "notified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversation_members_user_idx": { + "name": "conversation_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversation_members_conversation_id_conversations_id_fk": { + "name": "conversation_members_conversation_id_conversations_id_fk", + "tableFrom": "conversation_members", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversation_members_user_id_users_id_fk": { + "name": "conversation_members_user_id_users_id_fk", + "tableFrom": "conversation_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversation_members_conversation_id_user_id_pk": { + "name": "conversation_members_conversation_id_user_id_pk", + "columns": [ + "conversation_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_group": { + "name": "is_group", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversations_org_idx": { + "name": "conversations_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversations_organization_id_organizations_id_fk": { + "name": "conversations_organization_id_organizations_id_fk", + "tableFrom": "conversations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversations_created_by_users_id_fk": { + "name": "conversations_created_by_users_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credit_request_lines": { + "name": "credit_request_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_request_lines_req_idx": { + "name": "credit_request_lines_req_idx", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_request_lines_organization_id_organizations_id_fk": { + "name": "credit_request_lines_organization_id_organizations_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_lines_request_id_credit_requests_id_fk": { + "name": "credit_request_lines_request_id_credit_requests_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "credit_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_lines_item_id_purchase_items_id_fk": { + "name": "credit_request_lines_item_id_purchase_items_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_request_lines_amount_ck": { + "name": "credit_request_lines_amount_ck", + "value": "\"credit_request_lines\".\"quantity\" > 0 AND \"credit_request_lines\".\"unit_price_ht\" > 0 AND \"credit_request_lines\".\"amount_ht\" > 0" + }, + "credit_request_lines_reason_ck": { + "name": "credit_request_lines_reason_ck", + "value": "\"credit_request_lines\".\"reason\" IN ('manquant', 'abime', 'non_conforme', 'erreur_prix', 'erreur_quantite', 'dlc_courte', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.credit_request_photos": { + "name": "credit_request_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_request_photos_req_idx": { + "name": "credit_request_photos_req_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_request_photos_organization_id_organizations_id_fk": { + "name": "credit_request_photos_organization_id_organizations_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_photos_request_id_credit_requests_id_fk": { + "name": "credit_request_photos_request_id_credit_requests_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "credit_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_photos_created_by_users_id_fk": { + "name": "credit_request_photos_created_by_users_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_request_photos_size_ck": { + "name": "credit_request_photos_size_ck", + "value": "\"credit_request_photos\".\"size\" <= 5242880" + }, + "credit_request_photos_mime_ck": { + "name": "credit_request_photos_mime_ck", + "value": "\"credit_request_photos\".\"mime\" IN ('image/jpeg', 'image/png', 'image/webp')" + } + }, + "isRLSEnabled": false + }, + "public.credit_requests": { + "name": "credit_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "request_date": { + "name": "request_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "credited_ht": { + "name": "credited_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "close_reason": { + "name": "close_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_requests_est_idx": { + "name": "credit_requests_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_requests_number_uq": { + "name": "credit_requests_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_requests_organization_id_organizations_id_fk": { + "name": "credit_requests_organization_id_organizations_id_fk", + "tableFrom": "credit_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_requests_establishment_id_establishments_id_fk": { + "name": "credit_requests_establishment_id_establishments_id_fk", + "tableFrom": "credit_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_supplier_id_suppliers_id_fk": { + "name": "credit_requests_supplier_id_suppliers_id_fk", + "tableFrom": "credit_requests", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_purchase_order_id_purchase_orders_id_fk": { + "name": "credit_requests_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "credit_requests", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_invoice_id_purchase_invoices_id_fk": { + "name": "credit_requests_invoice_id_purchase_invoices_id_fk", + "tableFrom": "credit_requests", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_closed_by_users_id_fk": { + "name": "credit_requests_closed_by_users_id_fk", + "tableFrom": "credit_requests", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "credit_requests_created_by_users_id_fk": { + "name": "credit_requests_created_by_users_id_fk", + "tableFrom": "credit_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_requests_status_ck": { + "name": "credit_requests_status_ck", + "value": "\"credit_requests\".\"status\" IN ('open', 'sent', 'accepted', 'refused', 'cancelled')" + }, + "credit_requests_total_ck": { + "name": "credit_requests_total_ck", + "value": "\"credit_requests\".\"total_ht\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.customers": { + "name": "customers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergies": { + "name": "allergies", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preferences": { + "name": "preferences", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birthday": { + "name": "birthday", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "vip": { + "name": "vip", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "consent_email": { + "name": "consent_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "consent_sms": { + "name": "consent_sms", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "consent_at": { + "name": "consent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consent_source": { + "name": "consent_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "anonymized_at": { + "name": "anonymized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "customers_org_idx": { + "name": "customers_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "customers_phone_idx": { + "name": "customers_phone_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "phone", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "customers_email_idx": { + "name": "customers_email_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "customers_organization_id_organizations_id_fk": { + "name": "customers_organization_id_organizations_id_fk", + "tableFrom": "customers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.dashboard_layouts": { + "name": "dashboard_layouts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blocks": { + "name": "blocks", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "dashboard_layouts_user_id_users_id_fk": { + "name": "dashboard_layouts_user_id_users_id_fk", + "tableFrom": "dashboard_layouts", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dashboard_layouts_organization_id_organizations_id_fk": { + "name": "dashboard_layouts_organization_id_organizations_id_fk", + "tableFrom": "dashboard_layouts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "dashboard_layouts_user_id_organization_id_pk": { + "name": "dashboard_layouts_user_id_organization_id_pk", + "columns": [ + "user_id", + "organization_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.delivery_note_scans": { + "name": "delivery_note_scans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "delivery_note_scans_order_idx": { + "name": "delivery_note_scans_order_idx", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "delivery_note_scans_org_idx": { + "name": "delivery_note_scans_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "delivery_note_scans_organization_id_organizations_id_fk": { + "name": "delivery_note_scans_organization_id_organizations_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_establishment_id_establishments_id_fk": { + "name": "delivery_note_scans_establishment_id_establishments_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_order_id_purchase_orders_id_fk": { + "name": "delivery_note_scans_order_id_purchase_orders_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "purchase_orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_created_by_users_id_fk": { + "name": "delivery_note_scans_created_by_users_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "delivery_note_scans_status_ck": { + "name": "delivery_note_scans_status_ck", + "value": "\"delivery_note_scans\".\"status\" IN ('lu', 'echec')" + }, + "delivery_note_scans_size_ck": { + "name": "delivery_note_scans_size_ck", + "value": "\"delivery_note_scans\".\"size\" > 0 AND \"delivery_note_scans\".\"size\" <= 10485760" + } + }, + "isRLSEnabled": false + }, + "public.dish_quality_checks": { + "name": "dish_quality_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "checked_by": { + "name": "checked_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "weight_g": { + "name": "weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "target_weight_g": { + "name": "target_weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tolerance_pct": { + "name": "tolerance_pct", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "plating_ok": { + "name": "plating_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "temperature_ok": { + "name": "temperature_ok", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "dish_quality_checks_est_idx": { + "name": "dish_quality_checks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "dish_quality_checks_recipe_idx": { + "name": "dish_quality_checks_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "dish_quality_checks_organization_id_organizations_id_fk": { + "name": "dish_quality_checks_organization_id_organizations_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_establishment_id_establishments_id_fk": { + "name": "dish_quality_checks_establishment_id_establishments_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_recipe_id_recipes_id_fk": { + "name": "dish_quality_checks_recipe_id_recipes_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_checked_by_users_id_fk": { + "name": "dish_quality_checks_checked_by_users_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "users", + "columnsFrom": [ + "checked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "dish_quality_checks_weight_ck": { + "name": "dish_quality_checks_weight_ck", + "value": "(\"dish_quality_checks\".\"weight_g\" IS NULL OR \"dish_quality_checks\".\"weight_g\" BETWEEN 1 AND 20000) AND (\"dish_quality_checks\".\"target_weight_g\" IS NULL OR \"dish_quality_checks\".\"target_weight_g\" BETWEEN 1 AND 20000)" + } + }, + "isRLSEnabled": false + }, + "public.duerp_risks": { + "name": "duerp_risks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "unit_id": { + "name": "unit_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "hazard": { + "name": "hazard", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "situation": { + "name": "situation", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "existing_measures": { + "name": "existing_measures", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gravity": { + "name": "gravity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "probability": { + "name": "probability", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "planned_action": { + "name": "planned_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action_owner": { + "name": "action_owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action_due": { + "name": "action_due", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "action_status": { + "name": "action_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_template": { + "name": "from_template", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_risks_unit_idx": { + "name": "duerp_risks_unit_idx", + "columns": [ + { + "expression": "unit_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_risks_est_idx": { + "name": "duerp_risks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_risks_organization_id_organizations_id_fk": { + "name": "duerp_risks_organization_id_organizations_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_risks_establishment_id_establishments_id_fk": { + "name": "duerp_risks_establishment_id_establishments_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_risks_unit_id_duerp_units_id_fk": { + "name": "duerp_risks_unit_id_duerp_units_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "duerp_units", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "duerp_risks_scale_ck": { + "name": "duerp_risks_scale_ck", + "value": "(\"duerp_risks\".\"gravity\" IS NULL OR \"duerp_risks\".\"gravity\" BETWEEN 1 AND 4) AND (\"duerp_risks\".\"probability\" IS NULL OR \"duerp_risks\".\"probability\" BETWEEN 1 AND 4)" + }, + "duerp_risks_action_ck": { + "name": "duerp_risks_action_ck", + "value": "\"duerp_risks\".\"action_status\" IS NULL OR (\"duerp_risks\".\"action_status\" IN ('a_faire', 'en_cours', 'faite') AND \"duerp_risks\".\"planned_action\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.duerp_units": { + "name": "duerp_units", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headcount": { + "name": "headcount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_units_est_idx": { + "name": "duerp_units_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_units_name_uq": { + "name": "duerp_units_name_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"duerp_units\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_units_organization_id_organizations_id_fk": { + "name": "duerp_units_organization_id_organizations_id_fk", + "tableFrom": "duerp_units", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_units_establishment_id_establishments_id_fk": { + "name": "duerp_units_establishment_id_establishments_id_fk", + "tableFrom": "duerp_units", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "duerp_units_headcount_ck": { + "name": "duerp_units_headcount_ck", + "value": "\"duerp_units\".\"headcount\" IS NULL OR \"duerp_units\".\"headcount\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.duerp_versions": { + "name": "duerp_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version_no": { + "name": "version_no", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "snapshot": { + "name": "snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "published_by_name": { + "name": "published_by_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_versions_no_uq": { + "name": "duerp_versions_no_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version_no", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_versions_org_idx": { + "name": "duerp_versions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_versions_organization_id_organizations_id_fk": { + "name": "duerp_versions_organization_id_organizations_id_fk", + "tableFrom": "duerp_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_versions_establishment_id_establishments_id_fk": { + "name": "duerp_versions_establishment_id_establishments_id_fk", + "tableFrom": "duerp_versions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_attachments": { + "name": "email_attachments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'application/pdf'" + }, + "content": { + "name": "content", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_attachments_org_idx": { + "name": "email_attachments_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_attachments_organization_id_organizations_id_fk": { + "name": "email_attachments_organization_id_organizations_id_fk", + "tableFrom": "email_attachments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "email_attachments_mime_ck": { + "name": "email_attachments_mime_ck", + "value": "\"email_attachments\".\"mime\" = 'application/pdf'" + }, + "email_attachments_size_ck": { + "name": "email_attachments_size_ck", + "value": "\"email_attachments\".\"size\" >= 0 AND \"email_attachments\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.email_outbox": { + "name": "email_outbox", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "signature_request_id": { + "name": "signature_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "attachment_id": { + "name": "attachment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "list_unsubscribe": { + "name": "list_unsubscribe", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_outbox_pending_idx": { + "name": "email_outbox_pending_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_outbox_organization_id_organizations_id_fk": { + "name": "email_outbox_organization_id_organizations_id_fk", + "tableFrom": "email_outbox", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "email_outbox_attachment_id_email_attachments_id_fk": { + "name": "email_outbox_attachment_id_email_attachments_id_fk", + "tableFrom": "email_outbox", + "tableTo": "email_attachments", + "columnsFrom": [ + "attachment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "email_outbox_status_ck": { + "name": "email_outbox_status_ck", + "value": "\"email_outbox\".\"status\" IN ('en_attente', 'envoye', 'echec')" + } + }, + "isRLSEnabled": false + }, + "public.employee_contracts": { + "name": "employee_contracts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "amends_id": { + "name": "amends_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "trial_end_date": { + "name": "trial_end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "step": { + "name": "step", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'employe'" + }, + "weekly_hours": { + "name": "weekly_hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "hourly_rate_gross": { + "name": "hourly_rate_gross", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": false + }, + "monthly_gross": { + "name": "monthly_gross", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "cdd_reason": { + "name": "cdd_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "replaced_person": { + "name": "replaced_person", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "meal_benefit": { + "name": "meal_benefit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "end_reason": { + "name": "end_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hire_time": { + "name": "hire_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_status": { + "name": "dpae_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_declared_on": { + "name": "dpae_declared_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "dpae_reference": { + "name": "dpae_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_note": { + "name": "dpae_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_contracts_emp_idx": { + "name": "employee_contracts_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "start_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_contracts_organization_id_organizations_id_fk": { + "name": "employee_contracts_organization_id_organizations_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_contracts_employee_id_employees_id_fk": { + "name": "employee_contracts_employee_id_employees_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_contracts_amends_id_employee_contracts_id_fk": { + "name": "employee_contracts_amends_id_employee_contracts_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "employee_contracts", + "columnsFrom": [ + "amends_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "employee_contracts_created_by_users_id_fk": { + "name": "employee_contracts_created_by_users_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_contracts_dpae_ck": { + "name": "employee_contracts_dpae_ck", + "value": "(\"employee_contracts\".\"dpae_status\" IS NULL OR \"employee_contracts\".\"dpae_status\" IN ('enregistree', 'non_concernee_declaree')) AND (\"employee_contracts\".\"dpae_status\" IS DISTINCT FROM 'enregistree' OR \"employee_contracts\".\"dpae_declared_on\" IS NOT NULL) AND (\"employee_contracts\".\"dpae_status\" IS DISTINCT FROM 'non_concernee_declaree' OR \"employee_contracts\".\"dpae_note\" IS NOT NULL)" + }, + "employee_contracts_kind_ck": { + "name": "employee_contracts_kind_ck", + "value": "\"employee_contracts\".\"kind\" IN ('cdi', 'cdd', 'extra', 'saisonnier', 'apprentissage', 'professionnalisation', 'stage', 'dirigeant')" + }, + "employee_contracts_dates_ck": { + "name": "employee_contracts_dates_ck", + "value": "\"employee_contracts\".\"end_date\" IS NULL OR \"employee_contracts\".\"end_date\" >= \"employee_contracts\".\"start_date\"" + }, + "employee_contracts_category_ck": { + "name": "employee_contracts_category_ck", + "value": "\"employee_contracts\".\"category\" IN ('employe', 'agent_maitrise', 'cadre')" + }, + "employee_contracts_hours_ck": { + "name": "employee_contracts_hours_ck", + "value": "\"employee_contracts\".\"weekly_hours\" IS NULL OR (\"employee_contracts\".\"weekly_hours\" > 0 AND \"employee_contracts\".\"weekly_hours\" <= 48)" + }, + "employee_contracts_rate_ck": { + "name": "employee_contracts_rate_ck", + "value": "(\"employee_contracts\".\"hourly_rate_gross\" IS NULL OR \"employee_contracts\".\"hourly_rate_gross\" >= 0) AND (\"employee_contracts\".\"monthly_gross\" IS NULL OR \"employee_contracts\".\"monthly_gross\" >= 0)" + }, + "employee_contracts_hire_time_ck": { + "name": "employee_contracts_hire_time_ck", + "value": "\"employee_contracts\".\"hire_time\" IS NULL OR \"employee_contracts\".\"hire_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "employee_contracts_meal_ck": { + "name": "employee_contracts_meal_ck", + "value": "\"employee_contracts\".\"meal_benefit\" IS NULL OR \"employee_contracts\".\"meal_benefit\" IN ('nature', 'indemnite', 'aucun')" + } + }, + "isRLSEnabled": false + }, + "public.employee_files": { + "name": "employee_files", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duplicate_of_id": { + "name": "duplicate_of_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "visible_to_employee": { + "name": "visible_to_employee", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_files_emp_idx": { + "name": "employee_files_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "employee_files_sha_idx": { + "name": "employee_files_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_files_organization_id_organizations_id_fk": { + "name": "employee_files_organization_id_organizations_id_fk", + "tableFrom": "employee_files", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_files_employee_id_employees_id_fk": { + "name": "employee_files_employee_id_employees_id_fk", + "tableFrom": "employee_files", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_files_duplicate_of_id_employee_files_id_fk": { + "name": "employee_files_duplicate_of_id_employee_files_id_fk", + "tableFrom": "employee_files", + "tableTo": "employee_files", + "columnsFrom": [ + "duplicate_of_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_files_uploaded_by_users_id_fk": { + "name": "employee_files_uploaded_by_users_id_fk", + "tableFrom": "employee_files", + "tableTo": "users", + "columnsFrom": [ + "uploaded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_files_size_ck": { + "name": "employee_files_size_ck", + "value": "\"employee_files\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.employee_reviews": { + "name": "employee_reviews", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'prevu'" + }, + "scheduled_on": { + "name": "scheduled_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "done_on": { + "name": "done_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reviewer_id": { + "name": "reviewer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "objectives": { + "name": "objectives", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "training_wishes": { + "name": "training_wishes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_comment": { + "name": "employee_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_reviews_emp_idx": { + "name": "employee_reviews_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_reviews_organization_id_organizations_id_fk": { + "name": "employee_reviews_organization_id_organizations_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_reviews_employee_id_employees_id_fk": { + "name": "employee_reviews_employee_id_employees_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_reviews_reviewer_id_users_id_fk": { + "name": "employee_reviews_reviewer_id_users_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "users", + "columnsFrom": [ + "reviewer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_reviews_file_id_employee_files_id_fk": { + "name": "employee_reviews_file_id_employee_files_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_reviews_created_by_users_id_fk": { + "name": "employee_reviews_created_by_users_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_reviews_kind_ck": { + "name": "employee_reviews_kind_ck", + "value": "\"employee_reviews\".\"kind\" IN ('annuel', 'professionnel', 'etat_des_lieux', 'fin_essai')" + }, + "employee_reviews_status_ck": { + "name": "employee_reviews_status_ck", + "value": "\"employee_reviews\".\"status\" IN ('prevu', 'realise', 'annule')" + }, + "employee_reviews_done_ck": { + "name": "employee_reviews_done_ck", + "value": "\"employee_reviews\".\"status\" <> 'realise' OR \"employee_reviews\".\"done_on\" IS NOT NULL" + }, + "employee_reviews_planned_ck": { + "name": "employee_reviews_planned_ck", + "value": "\"employee_reviews\".\"status\" <> 'prevu' OR \"employee_reviews\".\"scheduled_on\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.employee_skills": { + "name": "employee_skills", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "skill_id": { + "name": "skill_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "assessed_on": { + "name": "assessed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "assessed_by": { + "name": "assessed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "employee_skills_organization_id_organizations_id_fk": { + "name": "employee_skills_organization_id_organizations_id_fk", + "tableFrom": "employee_skills", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_employee_id_employees_id_fk": { + "name": "employee_skills_employee_id_employees_id_fk", + "tableFrom": "employee_skills", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_skill_id_skills_id_fk": { + "name": "employee_skills_skill_id_skills_id_fk", + "tableFrom": "employee_skills", + "tableTo": "skills", + "columnsFrom": [ + "skill_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_assessed_by_users_id_fk": { + "name": "employee_skills_assessed_by_users_id_fk", + "tableFrom": "employee_skills", + "tableTo": "users", + "columnsFrom": [ + "assessed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "employee_skills_employee_id_skill_id_pk": { + "name": "employee_skills_employee_id_skill_id_pk", + "columns": [ + "employee_id", + "skill_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_skills_level_ck": { + "name": "employee_skills_level_ck", + "value": "\"employee_skills\".\"level\" BETWEEN 0 AND 4" + } + }, + "isRLSEnabled": false + }, + "public.employee_trainings": { + "name": "employee_trainings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'realisee'" + }, + "planned_on": { + "name": "planned_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "done_on": { + "name": "done_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "hours": { + "name": "hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "funded_by": { + "name": "funded_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_trainings_emp_idx": { + "name": "employee_trainings_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_trainings_organization_id_organizations_id_fk": { + "name": "employee_trainings_organization_id_organizations_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_trainings_employee_id_employees_id_fk": { + "name": "employee_trainings_employee_id_employees_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_trainings_file_id_employee_files_id_fk": { + "name": "employee_trainings_file_id_employee_files_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_trainings_created_by_users_id_fk": { + "name": "employee_trainings_created_by_users_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_trainings_status_ck": { + "name": "employee_trainings_status_ck", + "value": "\"employee_trainings\".\"status\" IN ('prevue', 'realisee', 'annulee')" + }, + "employee_trainings_done_ck": { + "name": "employee_trainings_done_ck", + "value": "\"employee_trainings\".\"status\" <> 'realisee' OR \"employee_trainings\".\"done_on\" IS NOT NULL" + }, + "employee_trainings_valid_ck": { + "name": "employee_trainings_valid_ck", + "value": "\"employee_trainings\".\"valid_until\" IS NULL OR \"employee_trainings\".\"done_on\" IS NULL OR \"employee_trainings\".\"valid_until\" >= \"employee_trainings\".\"done_on\"" + }, + "employee_trainings_amounts_ck": { + "name": "employee_trainings_amounts_ck", + "value": "(\"employee_trainings\".\"hours\" IS NULL OR \"employee_trainings\".\"hours\" > 0) AND (\"employee_trainings\".\"cost\" IS NULL OR \"employee_trainings\".\"cost\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.employees": { + "name": "employees", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "registry_number": { + "name": "registry_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "birth_name": { + "name": "birth_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "birth_date": { + "name": "birth_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "birth_place": { + "name": "birth_place", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "nationality": { + "name": "nationality", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birth_country": { + "name": "birth_country", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birth_department": { + "name": "birth_department", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family_situation": { + "name": "family_situation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_type": { + "name": "work_permit_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_number": { + "name": "work_permit_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_expiry": { + "name": "work_permit_expiry", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "social_security_enc": { + "name": "social_security_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban_enc": { + "name": "iban_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bic": { + "name": "bic", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "account_holder": { + "name": "account_holder", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emergency_contact": { + "name": "emergency_contact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emergency_phone": { + "name": "emergency_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disability": { + "name": "disability", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "medical_visit_date": { + "name": "medical_visit_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "medical_visit_next_due": { + "name": "medical_visit_next_due", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reinforced_medical": { + "name": "reinforced_medical", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "planning_hidden": { + "name": "planning_hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employees_org_idx": { + "name": "employees_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "employees_registry_uq": { + "name": "employees_registry_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "registry_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employees_organization_id_organizations_id_fk": { + "name": "employees_organization_id_organizations_id_fk", + "tableFrom": "employees", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employees_establishment_id_establishments_id_fk": { + "name": "employees_establishment_id_establishments_id_fk", + "tableFrom": "employees", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "employees_user_id_users_id_fk": { + "name": "employees_user_id_users_id_fk", + "tableFrom": "employees", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employees_gender_ck": { + "name": "employees_gender_ck", + "value": "\"employees\".\"gender\" IS NULL OR \"employees\".\"gender\" IN ('F', 'M', 'X')" + }, + "employees_birth_department_ck": { + "name": "employees_birth_department_ck", + "value": "\"employees\".\"birth_department\" IS NULL OR \"employees\".\"birth_department\" ~ '^([0-9]{2}|2[AB]|9[78][0-9])$'" + } + }, + "isRLSEnabled": false + }, + "public.employer_signatures": { + "name": "employer_signatures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "png": { + "name": "png", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "signer_name": { + "name": "signer_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employer_signatures_company_uq": { + "name": "employer_signatures_company_uq", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employer_signatures_organization_id_organizations_id_fk": { + "name": "employer_signatures_organization_id_organizations_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employer_signatures_company_id_companies_id_fk": { + "name": "employer_signatures_company_id_companies_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employer_signatures_updated_by_users_id_fk": { + "name": "employer_signatures_updated_by_users_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employer_signatures_size_ck": { + "name": "employer_signatures_size_ck", + "value": "octet_length(\"employer_signatures\".\"png\") <= 102400" + } + }, + "isRLSEnabled": false + }, + "public.equipment": { + "name": "equipment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "temp_tracked": { + "name": "temp_tracked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "temp_min": { + "name": "temp_min", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "readings_per_day": { + "name": "readings_per_day", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "serial_number": { + "name": "serial_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installed_on": { + "name": "installed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "warranty_until": { + "name": "warranty_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "service_partner": { + "name": "service_partner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_phone": { + "name": "service_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_every_months": { + "name": "service_every_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "purchase_price_ht": { + "name": "purchase_price_ht", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "equipment_est_idx": { + "name": "equipment_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "equipment_organization_id_organizations_id_fk": { + "name": "equipment_organization_id_organizations_id_fk", + "tableFrom": "equipment", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "equipment_establishment_id_establishments_id_fk": { + "name": "equipment_establishment_id_establishments_id_fk", + "tableFrom": "equipment", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "equipment_created_by_users_id_fk": { + "name": "equipment_created_by_users_id_fk", + "tableFrom": "equipment", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "equipment_range_ck": { + "name": "equipment_range_ck", + "value": "\"equipment\".\"temp_min\" IS NULL OR \"equipment\".\"temp_max\" IS NULL OR \"equipment\".\"temp_min\" <= \"equipment\".\"temp_max\"" + }, + "equipment_rpd_ck": { + "name": "equipment_rpd_ck", + "value": "\"equipment\".\"readings_per_day\" BETWEEN 1 AND 4" + }, + "equipment_price_ck": { + "name": "equipment_price_ck", + "value": "\"equipment\".\"purchase_price_ht\" IS NULL OR \"equipment\".\"purchase_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.establishment_fee_rules": { + "name": "establishment_fee_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rate_pct": { + "name": "rate_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "basis": { + "name": "basis", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ttc'" + }, + "match_channel": { + "name": "match_channel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "match_payment": { + "name": "match_payment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fixed_monthly_ht": { + "name": "fixed_monthly_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "valid_from": { + "name": "valid_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "valid_to": { + "name": "valid_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishment_fee_rules_est_idx": { + "name": "establishment_fee_rules_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishment_fee_rules_organization_id_organizations_id_fk": { + "name": "establishment_fee_rules_organization_id_organizations_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_fee_rules_establishment_id_establishments_id_fk": { + "name": "establishment_fee_rules_establishment_id_establishments_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_fee_rules_created_by_users_id_fk": { + "name": "establishment_fee_rules_created_by_users_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "establishment_fee_rules_kind_ck": { + "name": "establishment_fee_rules_kind_ck", + "value": "\"establishment_fee_rules\".\"kind\" IN ('plateforme', 'franchise')" + }, + "establishment_fee_rules_basis_ck": { + "name": "establishment_fee_rules_basis_ck", + "value": "\"establishment_fee_rules\".\"basis\" IN ('ttc', 'ht')" + }, + "establishment_fee_rules_rate_ck": { + "name": "establishment_fee_rules_rate_ck", + "value": "\"establishment_fee_rules\".\"rate_pct\" >= 0 AND \"establishment_fee_rules\".\"rate_pct\" < 100" + }, + "establishment_fee_rules_fixed_ck": { + "name": "establishment_fee_rules_fixed_ck", + "value": "\"establishment_fee_rules\".\"fixed_monthly_ht\" IS NULL OR \"establishment_fee_rules\".\"fixed_monthly_ht\" >= 0" + }, + "establishment_fee_rules_channel_ck": { + "name": "establishment_fee_rules_channel_ck", + "value": "\"establishment_fee_rules\".\"match_channel\" IS NULL OR \"establishment_fee_rules\".\"match_channel\" IN ('sur_place', 'emporter', 'livraison', 'click_collect', 'autre')" + }, + "establishment_fee_rules_dates_ck": { + "name": "establishment_fee_rules_dates_ck", + "value": "\"establishment_fee_rules\".\"valid_to\" IS NULL OR \"establishment_fee_rules\".\"valid_to\" >= \"establishment_fee_rules\".\"valid_from\"" + }, + "establishment_fee_rules_label_ck": { + "name": "establishment_fee_rules_label_ck", + "value": "char_length(\"establishment_fee_rules\".\"label\") BETWEEN 1 AND 80" + } + }, + "isRLSEnabled": false + }, + "public.establishment_regulatory_profiles": { + "name": "establishment_regulatory_profiles", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "on_site": { + "name": "on_site", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "takeaway": { + "name": "takeaway", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "delivery": { + "name": "delivery", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "seating_capacity": { + "name": "seating_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "erp_category": { + "name": "erp_category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erp_type": { + "name": "erp_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headcount_declared": { + "name": "headcount_declared", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "alcohol_licence": { + "name": "alcohol_licence", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "terrace": { + "name": "terrace", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "music": { + "name": "music", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "cameras": { + "name": "cameras", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "fryer": { + "name": "fryer", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "minors_employed": { + "name": "minors_employed", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "foreign_workers": { + "name": "foreign_workers", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "franchise": { + "name": "franchise", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishment_regulatory_profiles_org_idx": { + "name": "establishment_regulatory_profiles_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishment_regulatory_profiles_establishment_id_establishments_id_fk": { + "name": "establishment_regulatory_profiles_establishment_id_establishments_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_regulatory_profiles_organization_id_organizations_id_fk": { + "name": "establishment_regulatory_profiles_organization_id_organizations_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_regulatory_profiles_updated_by_users_id_fk": { + "name": "establishment_regulatory_profiles_updated_by_users_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "establishment_regulatory_profiles_erp_ck": { + "name": "establishment_regulatory_profiles_erp_ck", + "value": "\"establishment_regulatory_profiles\".\"erp_category\" IS NULL OR \"establishment_regulatory_profiles\".\"erp_category\" IN ('1', '2', '3', '4', '5')" + }, + "establishment_regulatory_profiles_licence_ck": { + "name": "establishment_regulatory_profiles_licence_ck", + "value": "\"establishment_regulatory_profiles\".\"alcohol_licence\" IS NULL OR \"establishment_regulatory_profiles\".\"alcohol_licence\" IN ('aucune', 'petite_licence_restaurant', 'licence_restaurant', 'licence_3', 'licence_4', 'petite_licence_emporter', 'licence_emporter', 'inconnue')" + }, + "establishment_regulatory_profiles_counts_ck": { + "name": "establishment_regulatory_profiles_counts_ck", + "value": "(\"establishment_regulatory_profiles\".\"seating_capacity\" IS NULL OR \"establishment_regulatory_profiles\".\"seating_capacity\" >= 0) AND (\"establishment_regulatory_profiles\".\"headcount_declared\" IS NULL OR \"establishment_regulatory_profiles\".\"headcount_declared\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.establishments": { + "name": "establishments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'restaurant'" + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ape_code": { + "name": "ape_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idcc": { + "name": "idcc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "country": { + "name": "country", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'FR'" + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Europe/Paris'" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'EUR'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishments_org_idx": { + "name": "establishments_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishments_organization_id_organizations_id_fk": { + "name": "establishments_organization_id_organizations_id_fk", + "tableFrom": "establishments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishments_company_id_companies_id_fk": { + "name": "establishments_company_id_companies_id_fk", + "tableFrom": "establishments", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.expense_entries": { + "name": "expense_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier": { + "name": "supplier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "period_start": { + "name": "period_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_end": { + "name": "period_end", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "recurrence": { + "name": "recurrence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "recurrence_until": { + "name": "recurrence_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deleted_by": { + "name": "deleted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "deletion_reason": { + "name": "deletion_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "double_count_decision": { + "name": "double_count_decision", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "double_count_decided_by": { + "name": "double_count_decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "double_count_decided_at": { + "name": "double_count_decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "expenses_period_idx": { + "name": "expenses_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_start", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_end", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "expense_entries_organization_id_organizations_id_fk": { + "name": "expense_entries_organization_id_organizations_id_fk", + "tableFrom": "expense_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "expense_entries_establishment_id_establishments_id_fk": { + "name": "expense_entries_establishment_id_establishments_id_fk", + "tableFrom": "expense_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "expense_entries_created_by_users_id_fk": { + "name": "expense_entries_created_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "expense_entries_deleted_by_users_id_fk": { + "name": "expense_entries_deleted_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "deleted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "expense_entries_double_count_decided_by_users_id_fk": { + "name": "expense_entries_double_count_decided_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "double_count_decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "expenses_period_ck": { + "name": "expenses_period_ck", + "value": "\"expense_entries\".\"period_start\" <= \"expense_entries\".\"period_end\"" + }, + "expenses_recurrence_ck": { + "name": "expenses_recurrence_ck", + "value": "\"expense_entries\".\"recurrence\" IN ('none', 'monthly', 'quarterly', 'yearly')" + }, + "expenses_recurrence_until_ck": { + "name": "expenses_recurrence_until_ck", + "value": "\"expense_entries\".\"recurrence_until\" IS NULL OR (\"expense_entries\".\"recurrence\" <> 'none' AND \"expense_entries\".\"recurrence_until\" >= \"expense_entries\".\"period_start\")" + }, + "expenses_ttc_consistency_ck": { + "name": "expenses_ttc_consistency_ck", + "value": "\"expense_entries\".\"amount_ttc\" = \"expense_entries\".\"amount_ht\" + \"expense_entries\".\"vat_amount\"" + }, + "expense_double_count_ck": { + "name": "expense_double_count_ck", + "value": "\"expense_entries\".\"double_count_decision\" IS NULL OR \"expense_entries\".\"double_count_decision\" IN ('keep', 'exclude')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_ambassadors": { + "name": "feedback_ambassadors", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "appointed_by": { + "name": "appointed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_ambassadors_organization_id_organizations_id_fk": { + "name": "feedback_ambassadors_organization_id_organizations_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_ambassadors_user_id_users_id_fk": { + "name": "feedback_ambassadors_user_id_users_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_ambassadors_appointed_by_users_id_fk": { + "name": "feedback_ambassadors_appointed_by_users_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "users", + "columnsFrom": [ + "appointed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_ambassadors_organization_id_user_id_pk": { + "name": "feedback_ambassadors_organization_id_user_id_pk", + "columns": [ + "organization_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback_comments": { + "name": "feedback_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'commentaire'" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_status": { + "name": "from_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "to_status": { + "name": "to_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_comments_item_idx": { + "name": "feedback_comments_item_idx", + "columns": [ + { + "expression": "feedback_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_comments_organization_id_organizations_id_fk": { + "name": "feedback_comments_organization_id_organizations_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_comments_feedback_id_feedback_items_id_fk": { + "name": "feedback_comments_feedback_id_feedback_items_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "feedback_items", + "columnsFrom": [ + "feedback_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_comments_user_id_users_id_fk": { + "name": "feedback_comments_user_id_users_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_comments_kind_ck": { + "name": "feedback_comments_kind_ck", + "value": "\"feedback_comments\".\"kind\" IN ('commentaire', 'reponse', 'statut', 'fusion')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_items": { + "name": "feedback_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "page_path": { + "name": "page_path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_role": { + "name": "author_role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "screenshot": { + "name": "screenshot", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "screenshot_mime": { + "name": "screenshot_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'recue'" + }, + "status_note": { + "name": "status_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "release_version": { + "name": "release_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "merged_into_id": { + "name": "merged_into_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "first_response_at": { + "name": "first_response_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delivered_at": { + "name": "delivered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_items_number_uq": { + "name": "feedback_items_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "feedback_items_org_idx": { + "name": "feedback_items_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_items_organization_id_organizations_id_fk": { + "name": "feedback_items_organization_id_organizations_id_fk", + "tableFrom": "feedback_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_items_merged_into_id_feedback_items_id_fk": { + "name": "feedback_items_merged_into_id_feedback_items_id_fk", + "tableFrom": "feedback_items", + "tableTo": "feedback_items", + "columnsFrom": [ + "merged_into_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "feedback_items_author_id_users_id_fk": { + "name": "feedback_items_author_id_users_id_fk", + "tableFrom": "feedback_items", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_items_kind_ck": { + "name": "feedback_items_kind_ck", + "value": "\"feedback_items\".\"kind\" IN ('idee', 'probleme', 'question')" + }, + "feedback_items_status_ck": { + "name": "feedback_items_status_ck", + "value": "\"feedback_items\".\"status\" IN ('recue', 'etude', 'prevue', 'en_cours', 'livree', 'pas_maintenant')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_pulses": { + "name": "feedback_pulses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_pulses_once_uq": { + "name": "feedback_pulses_once_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "app_version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "feedback_pulses_org_idx": { + "name": "feedback_pulses_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_pulses_organization_id_organizations_id_fk": { + "name": "feedback_pulses_organization_id_organizations_id_fk", + "tableFrom": "feedback_pulses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_pulses_user_id_users_id_fk": { + "name": "feedback_pulses_user_id_users_id_fk", + "tableFrom": "feedback_pulses", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_pulses_answer_ck": { + "name": "feedback_pulses_answer_ck", + "value": "\"feedback_pulses\".\"answer\" IN ('oui', 'non')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_testers": { + "name": "feedback_testers", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_testers_organization_id_organizations_id_fk": { + "name": "feedback_testers_organization_id_organizations_id_fk", + "tableFrom": "feedback_testers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_testers_user_id_users_id_fk": { + "name": "feedback_testers_user_id_users_id_fk", + "tableFrom": "feedback_testers", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_testers_organization_id_user_id_pk": { + "name": "feedback_testers_organization_id_user_id_pk", + "columns": [ + "organization_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback_votes": { + "name": "feedback_votes", + "schema": "", + "columns": { + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_votes_feedback_id_feedback_items_id_fk": { + "name": "feedback_votes_feedback_id_feedback_items_id_fk", + "tableFrom": "feedback_votes", + "tableTo": "feedback_items", + "columnsFrom": [ + "feedback_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_votes_user_id_users_id_fk": { + "name": "feedback_votes_user_id_users_id_fk", + "tableFrom": "feedback_votes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_votes_feedback_id_user_id_pk": { + "name": "feedback_votes_feedback_id_user_id_pk", + "columns": [ + "feedback_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.file_downloads": { + "name": "file_downloads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sensitivity": { + "name": "sensitivity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disposition": { + "name": "disposition", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "file_downloads_entity_idx": { + "name": "file_downloads_entity_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "file_downloads_organization_id_organizations_id_fk": { + "name": "file_downloads_organization_id_organizations_id_fk", + "tableFrom": "file_downloads", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "file_downloads_user_id_users_id_fk": { + "name": "file_downloads_user_id_users_id_fk", + "tableFrom": "file_downloads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "file_downloads_source_ck": { + "name": "file_downloads_source_ck", + "value": "\"file_downloads\".\"source\" IN ('business_document', 'business_document_version', 'employee_file', 'vault_zip', 'privacy_export', 'signature_request', 'sos_zip', 'generated_report', 'generated_hr_document', 'data_export')" + }, + "file_downloads_disposition_ck": { + "name": "file_downloads_disposition_ck", + "value": "\"file_downloads\".\"disposition\" IN ('inline', 'attachment', 'zip')" + } + }, + "isRLSEnabled": false + }, + "public.fixed_assets": { + "name": "fixed_assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "financing": { + "name": "financing", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "acquired_on": { + "name": "acquired_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "useful_life_months": { + "name": "useful_life_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lease_monthly_ht": { + "name": "lease_monthly_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "lease_end_on": { + "name": "lease_end_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "lease_residual_ht": { + "name": "lease_residual_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "disposed_on": { + "name": "disposed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "disposal_reason": { + "name": "disposal_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "fixed_assets_est_idx": { + "name": "fixed_assets_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fixed_assets_invoice_uq": { + "name": "fixed_assets_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"fixed_assets\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "fixed_assets_pennylane_uq": { + "name": "fixed_assets_pennylane_uq", + "columns": [ + { + "expression": "pennylane_record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"fixed_assets\".\"pennylane_record_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "fixed_assets_organization_id_organizations_id_fk": { + "name": "fixed_assets_organization_id_organizations_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fixed_assets_establishment_id_establishments_id_fk": { + "name": "fixed_assets_establishment_id_establishments_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fixed_assets_supplier_id_suppliers_id_fk": { + "name": "fixed_assets_supplier_id_suppliers_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "fixed_assets_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_pennylane_record_id_pennylane_records_id_fk": { + "name": "fixed_assets_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_document_id_business_documents_id_fk": { + "name": "fixed_assets_document_id_business_documents_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_created_by_users_id_fk": { + "name": "fixed_assets_created_by_users_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "fixed_assets_category_ck": { + "name": "fixed_assets_category_ck", + "value": "\"fixed_assets\".\"category\" IN ('materiel_cuisine', 'mobilier', 'informatique', 'agencement', 'vehicule', 'autre')" + }, + "fixed_assets_financing_ck": { + "name": "fixed_assets_financing_ck", + "value": "\"fixed_assets\".\"financing\" IN ('achat', 'credit_bail', 'location_financiere')" + }, + "fixed_assets_purchase_ck": { + "name": "fixed_assets_purchase_ck", + "value": "\"fixed_assets\".\"financing\" <> 'achat' OR (\"fixed_assets\".\"amount_ht\" IS NOT NULL AND \"fixed_assets\".\"amount_ht\" > 0 AND \"fixed_assets\".\"useful_life_months\" IS NOT NULL)" + }, + "fixed_assets_lease_ck": { + "name": "fixed_assets_lease_ck", + "value": "\"fixed_assets\".\"financing\" = 'achat' OR (\"fixed_assets\".\"lease_monthly_ht\" IS NOT NULL AND \"fixed_assets\".\"lease_monthly_ht\" > 0 AND \"fixed_assets\".\"lease_end_on\" IS NOT NULL AND \"fixed_assets\".\"lease_end_on\" > \"fixed_assets\".\"acquired_on\")" + }, + "fixed_assets_life_ck": { + "name": "fixed_assets_life_ck", + "value": "\"fixed_assets\".\"useful_life_months\" IS NULL OR \"fixed_assets\".\"useful_life_months\" BETWEEN 1 AND 600" + }, + "fixed_assets_amounts_ck": { + "name": "fixed_assets_amounts_ck", + "value": "(\"fixed_assets\".\"amount_ht\" IS NULL OR \"fixed_assets\".\"amount_ht\" >= 0) AND (\"fixed_assets\".\"lease_residual_ht\" IS NULL OR \"fixed_assets\".\"lease_residual_ht\" >= 0)" + }, + "fixed_assets_disposal_ck": { + "name": "fixed_assets_disposal_ck", + "value": "\"fixed_assets\".\"disposed_on\" IS NULL OR (\"fixed_assets\".\"disposed_on\" >= \"fixed_assets\".\"acquired_on\" AND \"fixed_assets\".\"disposal_reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.floor_items": { + "name": "floor_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "shape": { + "name": "shape", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "w": { + "name": "w", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "h": { + "name": "h", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "rotation": { + "name": "rotation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "floor_items_room_idx": { + "name": "floor_items_room_idx", + "columns": [ + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "floor_items_table_label_uq": { + "name": "floor_items_table_label_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"label\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"floor_items\".\"kind\" = 'table' AND \"floor_items\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "floor_items_organization_id_organizations_id_fk": { + "name": "floor_items_organization_id_organizations_id_fk", + "tableFrom": "floor_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "floor_items_establishment_id_establishments_id_fk": { + "name": "floor_items_establishment_id_establishments_id_fk", + "tableFrom": "floor_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "floor_items_room_id_floor_rooms_id_fk": { + "name": "floor_items_room_id_floor_rooms_id_fk", + "tableFrom": "floor_items", + "tableTo": "floor_rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "floor_items_kind_ck": { + "name": "floor_items_kind_ck", + "value": "\"floor_items\".\"kind\" IN ('table', 'wall', 'bar', 'door', 'window', 'pillar', 'plant', 'zone', 'text')" + }, + "floor_items_table_ck": { + "name": "floor_items_table_ck", + "value": "\"floor_items\".\"kind\" <> 'table' OR (\"floor_items\".\"shape\" IN ('round', 'square', 'rect') AND \"floor_items\".\"label\" IS NOT NULL AND \"floor_items\".\"seats\" BETWEEN 1 AND 40)" + }, + "floor_items_size_ck": { + "name": "floor_items_size_ck", + "value": "\"floor_items\".\"w\" BETWEEN 5 AND 10000 AND \"floor_items\".\"h\" BETWEEN 5 AND 10000 AND \"floor_items\".\"rotation\" BETWEEN 0 AND 359" + } + }, + "isRLSEnabled": false + }, + "public.floor_rooms": { + "name": "floor_rooms", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width_cm": { + "name": "width_cm", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1200 + }, + "height_cm": { + "name": "height_cm", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 800 + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "floor_rooms_est_idx": { + "name": "floor_rooms_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "floor_rooms_organization_id_organizations_id_fk": { + "name": "floor_rooms_organization_id_organizations_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "floor_rooms_establishment_id_establishments_id_fk": { + "name": "floor_rooms_establishment_id_establishments_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "floor_rooms_created_by_users_id_fk": { + "name": "floor_rooms_created_by_users_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "floor_rooms_size_ck": { + "name": "floor_rooms_size_ck", + "value": "\"floor_rooms\".\"width_cm\" BETWEEN 200 AND 10000 AND \"floor_rooms\".\"height_cm\" BETWEEN 200 AND 10000" + } + }, + "isRLSEnabled": false + }, + "public.forecast_events": { + "name": "forecast_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_day": { + "name": "from_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "to_day": { + "name": "to_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "impact_pct": { + "name": "impact_pct", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forecast_events_org_idx": { + "name": "forecast_events_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forecast_events_organization_id_organizations_id_fk": { + "name": "forecast_events_organization_id_organizations_id_fk", + "tableFrom": "forecast_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forecast_events_establishment_id_establishments_id_fk": { + "name": "forecast_events_establishment_id_establishments_id_fk", + "tableFrom": "forecast_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forecast_events_created_by_users_id_fk": { + "name": "forecast_events_created_by_users_id_fk", + "tableFrom": "forecast_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "forecast_events_range_ck": { + "name": "forecast_events_range_ck", + "value": "\"forecast_events\".\"to_day\" >= \"forecast_events\".\"from_day\" AND \"forecast_events\".\"to_day\" - \"forecast_events\".\"from_day\" <= 92" + }, + "forecast_events_impact_ck": { + "name": "forecast_events_impact_ck", + "value": "\"forecast_events\".\"impact_pct\" IS NULL OR (\"forecast_events\".\"impact_pct\" >= -100 AND \"forecast_events\".\"impact_pct\" <= 500)" + } + }, + "isRLSEnabled": false + }, + "public.forum_replies": { + "name": "forum_replies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "topic_id": { + "name": "topic_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forum_replies_topic_idx": { + "name": "forum_replies_topic_idx", + "columns": [ + { + "expression": "topic_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forum_replies_organization_id_organizations_id_fk": { + "name": "forum_replies_organization_id_organizations_id_fk", + "tableFrom": "forum_replies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_replies_topic_id_forum_topics_id_fk": { + "name": "forum_replies_topic_id_forum_topics_id_fk", + "tableFrom": "forum_replies", + "tableTo": "forum_topics", + "columnsFrom": [ + "topic_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_replies_author_id_users_id_fk": { + "name": "forum_replies_author_id_users_id_fk", + "tableFrom": "forum_replies", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.forum_topics": { + "name": "forum_topics", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'question'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pinned": { + "name": "pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "solution_reply_id": { + "name": "solution_reply_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "idea_id": { + "name": "idea_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forum_topics_number_uq": { + "name": "forum_topics_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "forum_topics_org_idx": { + "name": "forum_topics_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "pinned", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_activity_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forum_topics_organization_id_organizations_id_fk": { + "name": "forum_topics_organization_id_organizations_id_fk", + "tableFrom": "forum_topics", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_topics_author_id_users_id_fk": { + "name": "forum_topics_author_id_users_id_fk", + "tableFrom": "forum_topics", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "forum_topics_idea_id_feedback_items_id_fk": { + "name": "forum_topics_idea_id_feedback_items_id_fk", + "tableFrom": "forum_topics", + "tableTo": "feedback_items", + "columnsFrom": [ + "idea_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "forum_topics_category_ck": { + "name": "forum_topics_category_ck", + "value": "\"forum_topics\".\"category\" IN ('question', 'astuce', 'discussion')" + } + }, + "isRLSEnabled": false + }, + "public.google_post_settings": { + "name": "google_post_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "schedule_mode": { + "name": "schedule_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'per_week'" + }, + "weekdays": { + "name": "weekdays", + "type": "integer[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[2,5]::integer[]" + }, + "per_week": { + "name": "per_week", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "post_time": { + "name": "post_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'10:00'" + }, + "lead_hours": { + "name": "lead_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 48 + }, + "src_menu": { + "name": "src_menu", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_events": { + "name": "src_events", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_hours": { + "name": "src_hours", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_best_sellers": { + "name": "src_best_sellers", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_seasonal": { + "name": "src_seasonal", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_reviews": { + "name": "src_reviews", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "review_min_rating": { + "name": "review_min_rating", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "default_cta_type": { + "name": "default_cta_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "default_cta_url": { + "name": "default_cta_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'fr'" + }, + "autopublish": { + "name": "autopublish", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enabled_by": { + "name": "enabled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "enabled_at": { + "name": "enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmation": { + "name": "confirmation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_generated_at": { + "name": "last_generated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "google_post_settings_org_idx": { + "name": "google_post_settings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "google_post_settings_establishment_id_establishments_id_fk": { + "name": "google_post_settings_establishment_id_establishments_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_post_settings_organization_id_organizations_id_fk": { + "name": "google_post_settings_organization_id_organizations_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_post_settings_enabled_by_users_id_fk": { + "name": "google_post_settings_enabled_by_users_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "users", + "columnsFrom": [ + "enabled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_post_settings_updated_by_users_id_fk": { + "name": "google_post_settings_updated_by_users_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "google_post_settings_mode_ck": { + "name": "google_post_settings_mode_ck", + "value": "\"google_post_settings\".\"schedule_mode\" IN ('weekdays', 'per_week')" + }, + "google_post_settings_weekdays_ck": { + "name": "google_post_settings_weekdays_ck", + "value": "cardinality(\"google_post_settings\".\"weekdays\") BETWEEN 1 AND 7 AND \"google_post_settings\".\"weekdays\" <@ ARRAY[1,2,3,4,5,6,7]::integer[]" + }, + "google_post_settings_per_week_ck": { + "name": "google_post_settings_per_week_ck", + "value": "\"google_post_settings\".\"per_week\" BETWEEN 1 AND 7" + }, + "google_post_settings_time_ck": { + "name": "google_post_settings_time_ck", + "value": "\"google_post_settings\".\"post_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "google_post_settings_lead_ck": { + "name": "google_post_settings_lead_ck", + "value": "\"google_post_settings\".\"lead_hours\" BETWEEN 12 AND 168" + }, + "google_post_settings_rating_ck": { + "name": "google_post_settings_rating_ck", + "value": "\"google_post_settings\".\"review_min_rating\" BETWEEN 4 AND 5" + }, + "google_post_settings_cta_ck": { + "name": "google_post_settings_cta_ck", + "value": "\"google_post_settings\".\"default_cta_type\" IS NULL OR \"google_post_settings\".\"default_cta_type\" IN ('BOOK', 'ORDER', 'SHOP', 'LEARN_MORE', 'SIGN_UP', 'CALL')" + }, + "google_post_settings_autopublish_ck": { + "name": "google_post_settings_autopublish_ck", + "value": "NOT \"google_post_settings\".\"autopublish\" OR \"google_post_settings\".\"confirmation\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.google_posts": { + "name": "google_posts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "generator": { + "name": "generator", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "facts": { + "name": "facts", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "topic_type": { + "name": "topic_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'STANDARD'" + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cta_type": { + "name": "cta_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cta_url": { + "name": "cta_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_title": { + "name": "event_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_start_date": { + "name": "event_start_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_start_time": { + "name": "event_start_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_end_date": { + "name": "event_end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_end_time": { + "name": "event_end_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_coupon": { + "name": "offer_coupon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_url": { + "name": "offer_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_terms": { + "name": "offer_terms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "visual_id": { + "name": "visual_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "image_mime": { + "name": "image_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blocked_words": { + "name": "blocked_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "google_name": { + "name": "google_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_state": { + "name": "google_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "search_url": { + "name": "search_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "ai_cost_usd": { + "name": "ai_cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "google_posts_due_idx": { + "name": "google_posts_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_cal_idx": { + "name": "google_posts_cal_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_for", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_source_uq": { + "name": "google_posts_source_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"google_posts\".\"source_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_token_uq": { + "name": "google_posts_token_uq", + "columns": [ + { + "expression": "public_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "google_posts_organization_id_organizations_id_fk": { + "name": "google_posts_organization_id_organizations_id_fk", + "tableFrom": "google_posts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_posts_establishment_id_establishments_id_fk": { + "name": "google_posts_establishment_id_establishments_id_fk", + "tableFrom": "google_posts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_posts_visual_id_studio_visuals_id_fk": { + "name": "google_posts_visual_id_studio_visuals_id_fk", + "tableFrom": "google_posts", + "tableTo": "studio_visuals", + "columnsFrom": [ + "visual_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_posts_approved_by_users_id_fk": { + "name": "google_posts_approved_by_users_id_fk", + "tableFrom": "google_posts", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_posts_created_by_users_id_fk": { + "name": "google_posts_created_by_users_id_fk", + "tableFrom": "google_posts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "google_posts_source_ck": { + "name": "google_posts_source_ck", + "value": "\"google_posts\".\"source\" IN ('manuel', 'menu_du_jour', 'evenement', 'horaires', 'meilleures_ventes', 'saison', 'avis')" + }, + "google_posts_generator_ck": { + "name": "google_posts_generator_ck", + "value": "\"google_posts\".\"generator\" IN ('ia', 'modele', 'humain')" + }, + "google_posts_topic_ck": { + "name": "google_posts_topic_ck", + "value": "\"google_posts\".\"topic_type\" IN ('STANDARD', 'EVENT', 'OFFER')" + }, + "google_posts_status_ck": { + "name": "google_posts_status_ck", + "value": "\"google_posts\".\"status\" IN ('brouillon', 'planifie', 'publishing', 'publie', 'echec', 'bloque', 'annule', 'expire', 'retire')" + }, + "google_posts_summary_ck": { + "name": "google_posts_summary_ck", + "value": "char_length(\"google_posts\".\"summary\") BETWEEN 1 AND 1500" + }, + "google_posts_cta_ck": { + "name": "google_posts_cta_ck", + "value": "\"google_posts\".\"cta_type\" IS NULL OR \"google_posts\".\"cta_type\" IN ('BOOK', 'ORDER', 'SHOP', 'LEARN_MORE', 'SIGN_UP', 'CALL')" + }, + "google_posts_image_ck": { + "name": "google_posts_image_ck", + "value": "(\"google_posts\".\"image\" IS NULL) = (\"google_posts\".\"image_mime\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.haccp_corrective_actions": { + "name": "haccp_corrective_actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_id": { + "name": "source_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dedup_key": { + "name": "dedup_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "detected_at": { + "name": "detected_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "action_taken": { + "name": "action_taken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "haccp_corrective_actions_dedup_uq": { + "name": "haccp_corrective_actions_dedup_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedup_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "haccp_corrective_actions_open_idx": { + "name": "haccp_corrective_actions_open_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "detected_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"haccp_corrective_actions\".\"closed_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "haccp_corrective_actions_organization_id_organizations_id_fk": { + "name": "haccp_corrective_actions_organization_id_organizations_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_corrective_actions_establishment_id_establishments_id_fk": { + "name": "haccp_corrective_actions_establishment_id_establishments_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_corrective_actions_closed_by_users_id_fk": { + "name": "haccp_corrective_actions_closed_by_users_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "haccp_corrective_actions_created_by_users_id_fk": { + "name": "haccp_corrective_actions_created_by_users_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "haccp_corrective_actions_source_ck": { + "name": "haccp_corrective_actions_source_ck", + "value": "\"haccp_corrective_actions\".\"source\" IN ('sonde_hors_plage', 'sonde_muette', 'releves_manquants', 'nettoyage_manquant', 'date_limite', 'manuel')" + }, + "haccp_corrective_actions_close_ck": { + "name": "haccp_corrective_actions_close_ck", + "value": "(\"haccp_corrective_actions\".\"closed_at\" IS NULL) = (\"haccp_corrective_actions\".\"action_taken\" IS NULL) AND (\"haccp_corrective_actions\".\"closed_at\" IS NULL) = (\"haccp_corrective_actions\".\"closed_by\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.incidents": { + "name": "incidents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actions_taken": { + "name": "actions_taken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "reported_by": { + "name": "reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reported_at": { + "name": "reported_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "incidents_est_idx": { + "name": "incidents_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurred_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "incidents_organization_id_organizations_id_fk": { + "name": "incidents_organization_id_organizations_id_fk", + "tableFrom": "incidents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "incidents_establishment_id_establishments_id_fk": { + "name": "incidents_establishment_id_establishments_id_fk", + "tableFrom": "incidents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "incidents_reported_by_users_id_fk": { + "name": "incidents_reported_by_users_id_fk", + "tableFrom": "incidents", + "tableTo": "users", + "columnsFrom": [ + "reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "incidents_closed_by_users_id_fk": { + "name": "incidents_closed_by_users_id_fk", + "tableFrom": "incidents", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "incidents_kind_ck": { + "name": "incidents_kind_ck", + "value": "\"incidents\".\"kind\" IN ('client', 'accident', 'casse', 'vol', 'securite', 'hygiene', 'livraison', 'autre')" + }, + "incidents_severity_ck": { + "name": "incidents_severity_ck", + "value": "\"incidents\".\"severity\" IN ('mineur', 'important', 'grave')" + }, + "incidents_status_ck": { + "name": "incidents_status_ck", + "value": "\"incidents\".\"status\" IN ('ouvert', 'clos')" + }, + "incidents_closed_ck": { + "name": "incidents_closed_ck", + "value": "\"incidents\".\"status\" = 'ouvert' OR (\"incidents\".\"closed_at\" IS NOT NULL AND \"incidents\".\"follow_up\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.inspection_shares": { + "name": "inspection_shares", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inspector_code": { + "name": "inspector_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_name": { + "name": "created_by_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "access_count": { + "name": "access_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_access_at": { + "name": "last_access_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inspection_shares_token_uq": { + "name": "inspection_shares_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inspection_shares_est_idx": { + "name": "inspection_shares_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inspection_shares_organization_id_organizations_id_fk": { + "name": "inspection_shares_organization_id_organizations_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inspection_shares_establishment_id_establishments_id_fk": { + "name": "inspection_shares_establishment_id_establishments_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inspection_shares_created_by_users_id_fk": { + "name": "inspection_shares_created_by_users_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_connections": { + "name": "integration_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "connection_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'not_configured'" + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_config": { + "name": "public_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_sync": { + "name": "auto_sync", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sync_interval_hours": { + "name": "sync_interval_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 24 + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integration_conn_uq": { + "name": "integration_conn_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_connections_organization_id_organizations_id_fk": { + "name": "integration_connections_organization_id_organizations_id_fk", + "tableFrom": "integration_connections", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_connections_establishment_id_establishments_id_fk": { + "name": "integration_connections_establishment_id_establishments_id_fk", + "tableFrom": "integration_connections", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "integration_conn_interval_ck": { + "name": "integration_conn_interval_ck", + "value": "\"integration_connections\".\"sync_interval_hours\" BETWEEN 1 AND 168" + }, + "integration_conn_failures_ck": { + "name": "integration_conn_failures_ck", + "value": "\"integration_connections\".\"consecutive_failures\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.integration_sync_runs": { + "name": "integration_sync_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "counts": { + "name": "counts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "errors": { + "name": "errors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "integration_sync_runs_idx": { + "name": "integration_sync_runs_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_sync_runs_organization_id_organizations_id_fk": { + "name": "integration_sync_runs_organization_id_organizations_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_sync_runs_establishment_id_establishments_id_fk": { + "name": "integration_sync_runs_establishment_id_establishments_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_sync_runs_user_id_users_id_fk": { + "name": "integration_sync_runs_user_id_users_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "integration_sync_runs_trigger_ck": { + "name": "integration_sync_runs_trigger_ck", + "value": "\"integration_sync_runs\".\"trigger\" IN ('manual', 'auto')" + }, + "integration_sync_runs_outcome_ck": { + "name": "integration_sync_runs_outcome_ck", + "value": "\"integration_sync_runs\".\"outcome\" IN ('success', 'partial', 'error')" + } + }, + "isRLSEnabled": false + }, + "public.intercompany_flows": { + "name": "intercompany_flows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payer_company_id": { + "name": "payer_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payee_company_id": { + "name": "payee_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "flow_date": { + "name": "flow_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "agreement_ref": { + "name": "agreement_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'saisie'" + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "bank_transaction_id": { + "name": "bank_transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "intercompany_flows_org_idx": { + "name": "intercompany_flows_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "flow_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "intercompany_flows_invoice_uq": { + "name": "intercompany_flows_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"intercompany_flows\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "intercompany_flows_bank_uq": { + "name": "intercompany_flows_bank_uq", + "columns": [ + { + "expression": "bank_transaction_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"intercompany_flows\".\"bank_transaction_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "intercompany_flows_organization_id_organizations_id_fk": { + "name": "intercompany_flows_organization_id_organizations_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_payer_company_id_companies_id_fk": { + "name": "intercompany_flows_payer_company_id_companies_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "companies", + "columnsFrom": [ + "payer_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_payee_company_id_companies_id_fk": { + "name": "intercompany_flows_payee_company_id_companies_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "companies", + "columnsFrom": [ + "payee_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "intercompany_flows_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "intercompany_flows_bank_transaction_id_bank_transactions_id_fk": { + "name": "intercompany_flows_bank_transaction_id_bank_transactions_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "bank_transactions", + "columnsFrom": [ + "bank_transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "intercompany_flows_created_by_users_id_fk": { + "name": "intercompany_flows_created_by_users_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "intercompany_flows_cancelled_by_users_id_fk": { + "name": "intercompany_flows_cancelled_by_users_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "intercompany_flows_pair_ck": { + "name": "intercompany_flows_pair_ck", + "value": "\"intercompany_flows\".\"payer_company_id\" <> \"intercompany_flows\".\"payee_company_id\"" + }, + "intercompany_flows_amount_ck": { + "name": "intercompany_flows_amount_ck", + "value": "\"intercompany_flows\".\"amount_ht\" > 0 AND (\"intercompany_flows\".\"vat_amount\" IS NULL OR \"intercompany_flows\".\"vat_amount\" >= 0)" + }, + "intercompany_flows_source_ck": { + "name": "intercompany_flows_source_ck", + "value": "\"intercompany_flows\".\"source\" IN ('saisie', 'facture', 'banque')" + }, + "intercompany_flows_kind_ck": { + "name": "intercompany_flows_kind_ck", + "value": "\"intercompany_flows\".\"kind\" IN ('refacturation', 'management_fees', 'loyer', 'vente', 'interets', 'dividendes', 'pret', 'remboursement_pret', 'apport_compte_courant', 'remboursement_compte_courant', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.inventories": { + "name": "inventories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "count_date": { + "name": "count_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "total_value": { + "name": "total_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inventories_est_idx": { + "name": "inventories_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "count_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inventories_validated_day_uq": { + "name": "inventories_validated_day_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "count_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"inventories\".\"status\" = 'validated'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inventories_organization_id_organizations_id_fk": { + "name": "inventories_organization_id_organizations_id_fk", + "tableFrom": "inventories", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventories_establishment_id_establishments_id_fk": { + "name": "inventories_establishment_id_establishments_id_fk", + "tableFrom": "inventories", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "inventories_created_by_users_id_fk": { + "name": "inventories_created_by_users_id_fk", + "tableFrom": "inventories", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventories_validated_by_users_id_fk": { + "name": "inventories_validated_by_users_id_fk", + "tableFrom": "inventories", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "inventories_status_ck": { + "name": "inventories_status_ck", + "value": "\"inventories\".\"status\" IN ('draft', 'validated')" + } + }, + "isRLSEnabled": false + }, + "public.inventory_lines": { + "name": "inventory_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inventory_id": { + "name": "inventory_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inventory_lines_item_uq": { + "name": "inventory_lines_item_uq", + "columns": [ + { + "expression": "inventory_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inventory_lines_organization_id_organizations_id_fk": { + "name": "inventory_lines_organization_id_organizations_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventory_lines_inventory_id_inventories_id_fk": { + "name": "inventory_lines_inventory_id_inventories_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "inventories", + "columnsFrom": [ + "inventory_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventory_lines_item_id_purchase_items_id_fk": { + "name": "inventory_lines_item_id_purchase_items_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "inventory_lines_qty_ck": { + "name": "inventory_lines_qty_ck", + "value": "\"inventory_lines\".\"quantity\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.investment_scenarios": { + "name": "investment_scenarios", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'etude'" + }, + "price": { + "name": "price", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "fees": { + "name": "fees", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "works": { + "name": "works", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "working_capital": { + "name": "working_capital", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "equity": { + "name": "equity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "loan_rate_pct": { + "name": "loan_rate_pct", + "type": "numeric(6, 3)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "loan_years": { + "name": "loan_years", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 7 + }, + "revenue_ht": { + "name": "revenue_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "ebe": { + "name": "ebe", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "adjustments": { + "name": "adjustments", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "owner_pay": { + "name": "owner_pay", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "maintenance_capex": { + "name": "maintenance_capex", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "investment_scenarios_org_idx": { + "name": "investment_scenarios_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "investment_scenarios_organization_id_organizations_id_fk": { + "name": "investment_scenarios_organization_id_organizations_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "investment_scenarios_establishment_id_establishments_id_fk": { + "name": "investment_scenarios_establishment_id_establishments_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "investment_scenarios_created_by_users_id_fk": { + "name": "investment_scenarios_created_by_users_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "investment_scenarios_updated_by_users_id_fk": { + "name": "investment_scenarios_updated_by_users_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "investment_scenarios_kind_ck": { + "name": "investment_scenarios_kind_ck", + "value": "\"investment_scenarios\".\"kind\" IN ('rachat_fonds', 'rachat_parts', 'travaux', 'equipement', 'ouverture', 'autre')" + }, + "investment_scenarios_status_ck": { + "name": "investment_scenarios_status_ck", + "value": "\"investment_scenarios\".\"status\" IN ('etude', 'retenu', 'abandonne', 'realise')" + }, + "investment_scenarios_years_ck": { + "name": "investment_scenarios_years_ck", + "value": "\"investment_scenarios\".\"loan_years\" BETWEEN 1 AND 30" + }, + "investment_scenarios_rate_ck": { + "name": "investment_scenarios_rate_ck", + "value": "\"investment_scenarios\".\"loan_rate_pct\" >= 0 AND \"investment_scenarios\".\"loan_rate_pct\" <= 20" + }, + "investment_scenarios_amounts_ck": { + "name": "investment_scenarios_amounts_ck", + "value": "\"investment_scenarios\".\"price\" >= 0 AND \"investment_scenarios\".\"fees\" >= 0 AND \"investment_scenarios\".\"works\" >= 0 AND \"investment_scenarios\".\"working_capital\" >= 0 AND \"investment_scenarios\".\"equity\" >= 0 AND \"investment_scenarios\".\"owner_pay\" >= 0 AND \"investment_scenarios\".\"maintenance_capex\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.invoice_label_links": { + "name": "invoice_label_links", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "link_key": { + "name": "link_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invoice_label_links_key_uq": { + "name": "invoice_label_links_key_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "link_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invoice_label_links_organization_id_organizations_id_fk": { + "name": "invoice_label_links_organization_id_organizations_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoice_label_links_item_id_purchase_items_id_fk": { + "name": "invoice_label_links_item_id_purchase_items_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoice_label_links_created_by_users_id_fk": { + "name": "invoice_label_links_created_by_users_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.item_stock_settings": { + "name": "item_stock_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "min_stock": { + "name": "min_stock", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "target_stock": { + "name": "target_stock", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "overstock_days": { + "name": "overstock_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "item_stock_settings_uq": { + "name": "item_stock_settings_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "item_stock_settings_organization_id_organizations_id_fk": { + "name": "item_stock_settings_organization_id_organizations_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "item_stock_settings_establishment_id_establishments_id_fk": { + "name": "item_stock_settings_establishment_id_establishments_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "item_stock_settings_item_id_purchase_items_id_fk": { + "name": "item_stock_settings_item_id_purchase_items_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "item_stock_settings_ck": { + "name": "item_stock_settings_ck", + "value": "(\"item_stock_settings\".\"min_stock\" IS NULL OR \"item_stock_settings\".\"min_stock\" >= 0) AND (\"item_stock_settings\".\"target_stock\" IS NULL OR \"item_stock_settings\".\"target_stock\" >= 0) AND (\"item_stock_settings\".\"overstock_days\" IS NULL OR \"item_stock_settings\".\"overstock_days\" BETWEEN 1 AND 365)" + } + }, + "isRLSEnabled": false + }, + "public.job_openings": { + "name": "job_openings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_kind": { + "name": "contract_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'cdi'" + }, + "weekly_hours": { + "name": "weekly_hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "start_wanted": { + "name": "start_wanted", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_openings_org_idx": { + "name": "job_openings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_openings_organization_id_organizations_id_fk": { + "name": "job_openings_organization_id_organizations_id_fk", + "tableFrom": "job_openings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_openings_establishment_id_establishments_id_fk": { + "name": "job_openings_establishment_id_establishments_id_fk", + "tableFrom": "job_openings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_openings_created_by_users_id_fk": { + "name": "job_openings_created_by_users_id_fk", + "tableFrom": "job_openings", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "job_openings_status_ck": { + "name": "job_openings_status_ck", + "value": "\"job_openings\".\"status\" IN ('ouvert', 'pourvu', 'ferme')" + }, + "job_openings_hours_ck": { + "name": "job_openings_hours_ck", + "value": "\"job_openings\".\"weekly_hours\" IS NULL OR (\"job_openings\".\"weekly_hours\" > 0 AND \"job_openings\".\"weekly_hours\" <= 48)" + } + }, + "isRLSEnabled": false + }, + "public.kitchen_labels": { + "name": "kitchen_labels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier_lot": { + "name": "supplier_lot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "produced_at": { + "name": "produced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "original_dlc": { + "name": "original_dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "shelf_life_days": { + "name": "shelf_life_days", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "ingredients": { + "name": "ingredients", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "storage_note": { + "name": "storage_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "copies": { + "name": "copies", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "trace_label_id": { + "name": "trace_label_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "printed_by": { + "name": "printed_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "kitchen_labels_est_idx": { + "name": "kitchen_labels_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "produced_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kitchen_labels_lot_uq": { + "name": "kitchen_labels_lot_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lot_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "kitchen_labels_organization_id_organizations_id_fk": { + "name": "kitchen_labels_organization_id_organizations_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "kitchen_labels_establishment_id_establishments_id_fk": { + "name": "kitchen_labels_establishment_id_establishments_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "kitchen_labels_recipe_id_recipes_id_fk": { + "name": "kitchen_labels_recipe_id_recipes_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "kitchen_labels_item_id_purchase_items_id_fk": { + "name": "kitchen_labels_item_id_purchase_items_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "kitchen_labels_trace_label_id_trace_labels_id_fk": { + "name": "kitchen_labels_trace_label_id_trace_labels_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "trace_labels", + "columnsFrom": [ + "trace_label_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "kitchen_labels_printed_by_users_id_fk": { + "name": "kitchen_labels_printed_by_users_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "users", + "columnsFrom": [ + "printed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "kitchen_labels_cancelled_by_users_id_fk": { + "name": "kitchen_labels_cancelled_by_users_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "kitchen_labels_kind_ck": { + "name": "kitchen_labels_kind_ck", + "value": "\"kitchen_labels\".\"kind\" IN ('production', 'ouverture', 'temoin')" + }, + "kitchen_labels_format_ck": { + "name": "kitchen_labels_format_ck", + "value": "\"kitchen_labels\".\"format\" IN ('62x29', '62x100', '102x152')" + }, + "kitchen_labels_copies_ck": { + "name": "kitchen_labels_copies_ck", + "value": "\"kitchen_labels\".\"copies\" BETWEEN 1 AND 50 AND \"kitchen_labels\".\"shelf_life_days\" BETWEEN 0 AND 90" + }, + "kitchen_labels_service_ck": { + "name": "kitchen_labels_service_ck", + "value": "\"kitchen_labels\".\"service\" IS NULL OR \"kitchen_labels\".\"service\" IN ('midi', 'soir')" + } + }, + "isRLSEnabled": false + }, + "public.known_devices": { + "name": "known_devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_ip": { + "name": "last_ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "alerted_at": { + "name": "alerted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "known_devices_uq": { + "name": "known_devices_uq", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "known_devices_user_idx": { + "name": "known_devices_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_seen_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "known_devices_user_id_users_id_fk": { + "name": "known_devices_user_id_users_id_fk", + "tableFrom": "known_devices", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lead_activities": { + "name": "lead_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "lead_id": { + "name": "lead_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "lead_activities_lead_idx": { + "name": "lead_activities_lead_idx", + "columns": [ + { + "expression": "lead_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "lead_activities_organization_id_organizations_id_fk": { + "name": "lead_activities_organization_id_organizations_id_fk", + "tableFrom": "lead_activities", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lead_activities_lead_id_leads_id_fk": { + "name": "lead_activities_lead_id_leads_id_fk", + "tableFrom": "lead_activities", + "tableTo": "leads", + "columnsFrom": [ + "lead_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lead_activities_created_by_users_id_fk": { + "name": "lead_activities_created_by_users_id_fk", + "tableFrom": "lead_activities", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.leads": { + "name": "leads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_kind": { + "name": "event_kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "guests": { + "name": "guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "budget_ttc": { + "name": "budget_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "company": { + "name": "company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'nouveau'" + }, + "lost_reason": { + "name": "lost_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_action_on": { + "name": "next_action_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "next_action": { + "name": "next_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "set_menu_id": { + "name": "set_menu_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "leads_org_stage_idx": { + "name": "leads_org_stage_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stage", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_action_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "leads_est_idx": { + "name": "leads_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "leads_organization_id_organizations_id_fk": { + "name": "leads_organization_id_organizations_id_fk", + "tableFrom": "leads", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leads_establishment_id_establishments_id_fk": { + "name": "leads_establishment_id_establishments_id_fk", + "tableFrom": "leads", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "leads_customer_id_customers_id_fk": { + "name": "leads_customer_id_customers_id_fk", + "tableFrom": "leads", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_owner_user_id_users_id_fk": { + "name": "leads_owner_user_id_users_id_fk", + "tableFrom": "leads", + "tableTo": "users", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_set_menu_id_set_menus_id_fk": { + "name": "leads_set_menu_id_set_menus_id_fk", + "tableFrom": "leads", + "tableTo": "set_menus", + "columnsFrom": [ + "set_menu_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_created_by_users_id_fk": { + "name": "leads_created_by_users_id_fk", + "tableFrom": "leads", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leads_stage_ck": { + "name": "leads_stage_ck", + "value": "\"leads\".\"stage\" IN ('nouveau', 'contacte', 'devis', 'negociation', 'gagne', 'perdu')" + }, + "leads_guests_ck": { + "name": "leads_guests_ck", + "value": "\"leads\".\"guests\" IS NULL OR (\"leads\".\"guests\" > 0 AND \"leads\".\"guests\" <= 5000)" + }, + "leads_budget_ck": { + "name": "leads_budget_ck", + "value": "\"leads\".\"budget_ttc\" IS NULL OR \"leads\".\"budget_ttc\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.leave_adjustments": { + "name": "leave_adjustments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counter": { + "name": "counter", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "leave_adjustments_emp_idx": { + "name": "leave_adjustments_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "leave_adjustments_organization_id_organizations_id_fk": { + "name": "leave_adjustments_organization_id_organizations_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_adjustments_employee_id_employees_id_fk": { + "name": "leave_adjustments_employee_id_employees_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_adjustments_created_by_users_id_fk": { + "name": "leave_adjustments_created_by_users_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leave_adjustments_counter_ck": { + "name": "leave_adjustments_counter_ck", + "value": "\"leave_adjustments\".\"counter\" IN ('cp_n1', 'cp_n', 'rc')" + }, + "leave_adjustments_amount_ck": { + "name": "leave_adjustments_amount_ck", + "value": "\"leave_adjustments\".\"amount\" <> 0 AND abs(\"leave_adjustments\".\"amount\") <= 500" + } + }, + "isRLSEnabled": false + }, + "public.leave_settings": { + "name": "leave_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cp_unit": { + "name": "cp_unit", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvrables'" + }, + "overtime_as_rest": { + "name": "overtime_as_rest", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "leave_settings_establishment_id_establishments_id_fk": { + "name": "leave_settings_establishment_id_establishments_id_fk", + "tableFrom": "leave_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_settings_organization_id_organizations_id_fk": { + "name": "leave_settings_organization_id_organizations_id_fk", + "tableFrom": "leave_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_settings_updated_by_users_id_fk": { + "name": "leave_settings_updated_by_users_id_fk", + "tableFrom": "leave_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leave_settings_unit_ck": { + "name": "leave_settings_unit_ck", + "value": "\"leave_settings\".\"cp_unit\" IN ('ouvrables', 'ouvres')" + } + }, + "isRLSEnabled": false + }, + "public.logbook_entries": { + "name": "logbook_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "important": { + "name": "important", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "done_note": { + "name": "done_note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "logbook_entries_est_idx": { + "name": "logbook_entries_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "logbook_entries_organization_id_organizations_id_fk": { + "name": "logbook_entries_organization_id_organizations_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "logbook_entries_establishment_id_establishments_id_fk": { + "name": "logbook_entries_establishment_id_establishments_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "logbook_entries_author_id_users_id_fk": { + "name": "logbook_entries_author_id_users_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "logbook_entries_done_by_users_id_fk": { + "name": "logbook_entries_done_by_users_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "logbook_entries_category_ck": { + "name": "logbook_entries_category_ck", + "value": "\"logbook_entries\".\"category\" IN ('info', 'a_traiter', 'client', 'livraison', 'equipe')" + } + }, + "isRLSEnabled": false + }, + "public.logbook_reads": { + "name": "logbook_reads", + "schema": "", + "columns": { + "entry_id": { + "name": "entry_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "logbook_reads_entry_id_logbook_entries_id_fk": { + "name": "logbook_reads_entry_id_logbook_entries_id_fk", + "tableFrom": "logbook_reads", + "tableTo": "logbook_entries", + "columnsFrom": [ + "entry_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "logbook_reads_user_id_users_id_fk": { + "name": "logbook_reads_user_id_users_id_fk", + "tableFrom": "logbook_reads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "logbook_reads_entry_id_user_id_pk": { + "name": "logbook_reads_entry_id_user_id_pk", + "columns": [ + "entry_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.loyalty_events": { + "name": "loyalty_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visits": { + "name": "visits", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "loyalty_events_customer_idx": { + "name": "loyalty_events_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "loyalty_events_est_idx": { + "name": "loyalty_events_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "loyalty_events_organization_id_organizations_id_fk": { + "name": "loyalty_events_organization_id_organizations_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_establishment_id_establishments_id_fk": { + "name": "loyalty_events_establishment_id_establishments_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_customer_id_customers_id_fk": { + "name": "loyalty_events_customer_id_customers_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_created_by_users_id_fk": { + "name": "loyalty_events_created_by_users_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "loyalty_events_kind_ck": { + "name": "loyalty_events_kind_ck", + "value": "\"loyalty_events\".\"kind\" IN ('ajustement', 'recompense')" + }, + "loyalty_events_visits_ck": { + "name": "loyalty_events_visits_ck", + "value": "\"loyalty_events\".\"visits\" <> 0 AND (\"loyalty_events\".\"kind\" <> 'recompense' OR \"loyalty_events\".\"visits\" < 0)" + } + }, + "isRLSEnabled": false + }, + "public.loyalty_programs": { + "name": "loyalty_programs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "visits_per_reward": { + "name": "visits_per_reward", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reward_label": { + "name": "reward_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starts_on": { + "name": "starts_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "loyalty_programs_est_uq": { + "name": "loyalty_programs_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "loyalty_programs_org_idx": { + "name": "loyalty_programs_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "loyalty_programs_organization_id_organizations_id_fk": { + "name": "loyalty_programs_organization_id_organizations_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_programs_establishment_id_establishments_id_fk": { + "name": "loyalty_programs_establishment_id_establishments_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_programs_updated_by_users_id_fk": { + "name": "loyalty_programs_updated_by_users_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "loyalty_programs_visits_ck": { + "name": "loyalty_programs_visits_ck", + "value": "\"loyalty_programs\".\"visits_per_reward\" BETWEEN 2 AND 50" + } + }, + "isRLSEnabled": false + }, + "public.mail_accounts": { + "name": "mail_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gmail'" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'connected'" + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "cursor_ms": { + "name": "cursor_ms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_by": { + "name": "connected_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_accounts_email_uq": { + "name": "mail_accounts_email_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_accounts_organization_id_organizations_id_fk": { + "name": "mail_accounts_organization_id_organizations_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_accounts_establishment_id_establishments_id_fk": { + "name": "mail_accounts_establishment_id_establishments_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_accounts_connected_by_users_id_fk": { + "name": "mail_accounts_connected_by_users_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "users", + "columnsFrom": [ + "connected_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_accounts_provider_ck": { + "name": "mail_accounts_provider_ck", + "value": "\"mail_accounts\".\"provider\" IN ('gmail', 'outlook')" + }, + "mail_accounts_status_ck": { + "name": "mail_accounts_status_ck", + "value": "\"mail_accounts\".\"status\" IN ('connected', 'error', 'disabled')" + }, + "mail_accounts_failures_ck": { + "name": "mail_accounts_failures_ck", + "value": "\"mail_accounts\".\"consecutive_failures\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.mail_documents": { + "name": "mail_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "part_id": { + "name": "part_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_verifier'" + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "suggested_issue_id": { + "name": "suggested_issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "match_reason": { + "name": "match_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "business_document_id": { + "name": "business_document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "maintenance_invoice_id": { + "name": "maintenance_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_documents_part_uq": { + "name": "mail_documents_part_uq", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "part_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_documents_org_idx": { + "name": "mail_documents_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_documents_organization_id_organizations_id_fk": { + "name": "mail_documents_organization_id_organizations_id_fk", + "tableFrom": "mail_documents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_documents_message_id_mail_messages_id_fk": { + "name": "mail_documents_message_id_mail_messages_id_fk", + "tableFrom": "mail_documents", + "tableTo": "mail_messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_documents_establishment_id_establishments_id_fk": { + "name": "mail_documents_establishment_id_establishments_id_fk", + "tableFrom": "mail_documents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_supplier_id_suppliers_id_fk": { + "name": "mail_documents_supplier_id_suppliers_id_fk", + "tableFrom": "mail_documents", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_pennylane_record_id_pennylane_records_id_fk": { + "name": "mail_documents_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "mail_documents", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_suggested_issue_id_maintenance_issues_id_fk": { + "name": "mail_documents_suggested_issue_id_maintenance_issues_id_fk", + "tableFrom": "mail_documents", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "suggested_issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_business_document_id_business_documents_id_fk": { + "name": "mail_documents_business_document_id_business_documents_id_fk", + "tableFrom": "mail_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "business_document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_maintenance_invoice_id_maintenance_invoices_id_fk": { + "name": "mail_documents_maintenance_invoice_id_maintenance_invoices_id_fk", + "tableFrom": "mail_documents", + "tableTo": "maintenance_invoices", + "columnsFrom": [ + "maintenance_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_decided_by_users_id_fk": { + "name": "mail_documents_decided_by_users_id_fk", + "tableFrom": "mail_documents", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_documents_kind_ck": { + "name": "mail_documents_kind_ck", + "value": "\"mail_documents\".\"kind\" IN ('facture', 'devis', 'attestation', 'autre')" + }, + "mail_documents_status_ck": { + "name": "mail_documents_status_ck", + "value": "\"mail_documents\".\"status\" IN ('a_verifier', 'verifiee', 'classee', 'ignoree')" + }, + "mail_documents_size_ck": { + "name": "mail_documents_size_ck", + "value": "\"mail_documents\".\"size\" <= 4718592" + } + }, + "isRLSEnabled": false + }, + "public.mail_messages": { + "name": "mail_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_id": { + "name": "thread_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_email": { + "name": "from_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "to_text": { + "name": "to_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "attachment_count": { + "name": "attachment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_messages_ext_uq": { + "name": "mail_messages_ext_uq", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_messages_org_idx": { + "name": "mail_messages_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_messages_organization_id_organizations_id_fk": { + "name": "mail_messages_organization_id_organizations_id_fk", + "tableFrom": "mail_messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_messages_account_id_mail_accounts_id_fk": { + "name": "mail_messages_account_id_mail_accounts_id_fk", + "tableFrom": "mail_messages", + "tableTo": "mail_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_messages_category_ck": { + "name": "mail_messages_category_ck", + "value": "\"mail_messages\".\"category\" IN ('facture', 'devis', 'attestation', 'reservation', 'commande', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.mail_reply_drafts": { + "name": "mail_reply_drafts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_valider'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "outbox_id": { + "name": "outbox_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_reply_drafts_message_uq": { + "name": "mail_reply_drafts_message_uq", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_reply_drafts_org_idx": { + "name": "mail_reply_drafts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_reply_drafts_organization_id_organizations_id_fk": { + "name": "mail_reply_drafts_organization_id_organizations_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_account_id_mail_accounts_id_fk": { + "name": "mail_reply_drafts_account_id_mail_accounts_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_message_id_mail_messages_id_fk": { + "name": "mail_reply_drafts_message_id_mail_messages_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_template_id_mail_reply_templates_id_fk": { + "name": "mail_reply_drafts_template_id_mail_reply_templates_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_reply_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_reply_drafts_decided_by_users_id_fk": { + "name": "mail_reply_drafts_decided_by_users_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_reply_drafts_status_ck": { + "name": "mail_reply_drafts_status_ck", + "value": "\"mail_reply_drafts\".\"status\" IN ('a_valider', 'envoye', 'ecarte')" + } + }, + "isRLSEnabled": false + }, + "public.mail_reply_templates": { + "name": "mail_reply_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "mail_reply_templates_org_idx": { + "name": "mail_reply_templates_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_reply_templates_organization_id_organizations_id_fk": { + "name": "mail_reply_templates_organization_id_organizations_id_fk", + "tableFrom": "mail_reply_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_templates_created_by_users_id_fk": { + "name": "mail_reply_templates_created_by_users_id_fk", + "tableFrom": "mail_reply_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_reply_templates_category_ck": { + "name": "mail_reply_templates_category_ck", + "value": "\"mail_reply_templates\".\"category\" IN ('facture', 'devis', 'attestation', 'reservation', 'commande', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_interventions": { + "name": "maintenance_interventions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "performed_on": { + "name": "performed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cost_ht": { + "name": "cost_ht", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": false + }, + "invoice_ref": { + "name": "invoice_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_due_on": { + "name": "next_due_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_interventions_eq_idx": { + "name": "maintenance_interventions_eq_idx", + "columns": [ + { + "expression": "equipment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "performed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_interventions_organization_id_organizations_id_fk": { + "name": "maintenance_interventions_organization_id_organizations_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_interventions_establishment_id_establishments_id_fk": { + "name": "maintenance_interventions_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_equipment_id_equipment_id_fk": { + "name": "maintenance_interventions_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_interventions_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_recorded_by_users_id_fk": { + "name": "maintenance_interventions_recorded_by_users_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_interventions_cancelled_by_users_id_fk": { + "name": "maintenance_interventions_cancelled_by_users_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_interventions_kind_ck": { + "name": "maintenance_interventions_kind_ck", + "value": "\"maintenance_interventions\".\"kind\" IN ('preventive', 'curative', 'reglementaire')" + }, + "maintenance_interventions_cost_ck": { + "name": "maintenance_interventions_cost_ck", + "value": "\"maintenance_interventions\".\"cost_ht\" IS NULL OR \"maintenance_interventions\".\"cost_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_invoices": { + "name": "maintenance_invoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quote_id": { + "name": "quote_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'reparation'" + }, + "repairer": { + "name": "repairer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "document_mime": { + "name": "document_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_name": { + "name": "document_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "match_reason": { + "name": "match_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "linked_by": { + "name": "linked_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_invoices_est_idx": { + "name": "maintenance_invoices_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_invoices_issue_idx": { + "name": "maintenance_invoices_issue_idx", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_invoices_pennylane_uq": { + "name": "maintenance_invoices_pennylane_uq", + "columns": [ + { + "expression": "pennylane_record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"maintenance_invoices\".\"pennylane_record_id\" IS NOT NULL AND \"maintenance_invoices\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_invoices_organization_id_organizations_id_fk": { + "name": "maintenance_invoices_organization_id_organizations_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_invoices_establishment_id_establishments_id_fk": { + "name": "maintenance_invoices_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_equipment_id_equipment_id_fk": { + "name": "maintenance_invoices_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_invoices_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_quote_id_maintenance_quotes_id_fk": { + "name": "maintenance_invoices_quote_id_maintenance_quotes_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "maintenance_quotes", + "columnsFrom": [ + "quote_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_pennylane_record_id_pennylane_records_id_fk": { + "name": "maintenance_invoices_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_invoices_linked_by_users_id_fk": { + "name": "maintenance_invoices_linked_by_users_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "users", + "columnsFrom": [ + "linked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_invoices_cancelled_by_users_id_fk": { + "name": "maintenance_invoices_cancelled_by_users_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_invoices_source_ck": { + "name": "maintenance_invoices_source_ck", + "value": "\"maintenance_invoices\".\"source\" IN ('pennylane', 'document', 'saisie')" + }, + "maintenance_invoices_kind_ck": { + "name": "maintenance_invoices_kind_ck", + "value": "\"maintenance_invoices\".\"kind\" IN ('entretien', 'reparation', 'controle')" + }, + "maintenance_invoices_amount_ck": { + "name": "maintenance_invoices_amount_ck", + "value": "(\"maintenance_invoices\".\"amount_ht\" IS NOT NULL OR \"maintenance_invoices\".\"amount_ttc\" IS NOT NULL) AND (\"maintenance_invoices\".\"amount_ht\" IS NULL OR \"maintenance_invoices\".\"amount_ht\" >= 0) AND (\"maintenance_invoices\".\"amount_ttc\" IS NULL OR \"maintenance_invoices\".\"amount_ttc\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_issues": { + "name": "maintenance_issues", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "reported_by": { + "name": "reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reported_at": { + "name": "reported_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "resolved_at": { + "name": "resolved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "resolution": { + "name": "resolution", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_issues_est_idx": { + "name": "maintenance_issues_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_issues_organization_id_organizations_id_fk": { + "name": "maintenance_issues_organization_id_organizations_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_issues_establishment_id_establishments_id_fk": { + "name": "maintenance_issues_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_issues_equipment_id_equipment_id_fk": { + "name": "maintenance_issues_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_issues_reported_by_users_id_fk": { + "name": "maintenance_issues_reported_by_users_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "users", + "columnsFrom": [ + "reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_issues_resolved_by_users_id_fk": { + "name": "maintenance_issues_resolved_by_users_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "users", + "columnsFrom": [ + "resolved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_issues_severity_ck": { + "name": "maintenance_issues_severity_ck", + "value": "\"maintenance_issues\".\"severity\" IN ('bloquant', 'genant', 'mineur')" + }, + "maintenance_issues_status_ck": { + "name": "maintenance_issues_status_ck", + "value": "\"maintenance_issues\".\"status\" IN ('ouvert', 'en_cours', 'resolu')" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_quotes": { + "name": "maintenance_quotes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "repairer": { + "name": "repairer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quote_ref": { + "name": "quote_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "document_mime": { + "name": "document_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_name": { + "name": "document_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_valider'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_quotes_issue_idx": { + "name": "maintenance_quotes_issue_idx", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_quotes_est_idx": { + "name": "maintenance_quotes_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_quotes_one_valid_uq": { + "name": "maintenance_quotes_one_valid_uq", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"maintenance_quotes\".\"status\" = 'valide'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_quotes_organization_id_organizations_id_fk": { + "name": "maintenance_quotes_organization_id_organizations_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_quotes_establishment_id_establishments_id_fk": { + "name": "maintenance_quotes_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_quotes_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_quotes_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_quotes_decided_by_users_id_fk": { + "name": "maintenance_quotes_decided_by_users_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_quotes_created_by_users_id_fk": { + "name": "maintenance_quotes_created_by_users_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_quotes_status_ck": { + "name": "maintenance_quotes_status_ck", + "value": "\"maintenance_quotes\".\"status\" IN ('a_valider', 'valide', 'refuse')" + }, + "maintenance_quotes_amount_ck": { + "name": "maintenance_quotes_amount_ck", + "value": "(\"maintenance_quotes\".\"amount_ht\" IS NOT NULL OR \"maintenance_quotes\".\"amount_ttc\" IS NOT NULL) AND (\"maintenance_quotes\".\"amount_ht\" IS NULL OR \"maintenance_quotes\".\"amount_ht\" >= 0) AND (\"maintenance_quotes\".\"amount_ttc\" IS NULL OR \"maintenance_quotes\".\"amount_ttc\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.marketing_campaigns": { + "name": "marketing_campaigns", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "segment": { + "name": "segment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sms_text": { + "name": "sms_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "recipients_count": { + "name": "recipients_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "marketing_campaigns_org_idx": { + "name": "marketing_campaigns_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "marketing_campaigns_organization_id_organizations_id_fk": { + "name": "marketing_campaigns_organization_id_organizations_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "marketing_campaigns_establishment_id_establishments_id_fk": { + "name": "marketing_campaigns_establishment_id_establishments_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "marketing_campaigns_created_by_users_id_fk": { + "name": "marketing_campaigns_created_by_users_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "marketing_campaigns_status_ck": { + "name": "marketing_campaigns_status_ck", + "value": "\"marketing_campaigns\".\"status\" IN ('brouillon', 'envoyee')" + } + }, + "isRLSEnabled": false + }, + "public.media_assets": { + "name": "media_assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'upload'" + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_count": { + "name": "used_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "media_assets_org_idx": { + "name": "media_assets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_assets_recipe_idx": { + "name": "media_assets_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_assets_hash_uq": { + "name": "media_assets_hash_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "media_assets_organization_id_organizations_id_fk": { + "name": "media_assets_organization_id_organizations_id_fk", + "tableFrom": "media_assets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "media_assets_establishment_id_establishments_id_fk": { + "name": "media_assets_establishment_id_establishments_id_fk", + "tableFrom": "media_assets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "media_assets_recipe_id_recipes_id_fk": { + "name": "media_assets_recipe_id_recipes_id_fk", + "tableFrom": "media_assets", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "media_assets_created_by_users_id_fk": { + "name": "media_assets_created_by_users_id_fk", + "tableFrom": "media_assets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "media_assets_source_ck": { + "name": "media_assets_source_ck", + "value": "\"media_assets\".\"source\" IN ('upload', 'fiche', 'studio')" + }, + "media_assets_mime_ck": { + "name": "media_assets_mime_ck", + "value": "\"media_assets\".\"mime\" IN ('image/jpeg', 'image/png', 'image/webp')" + }, + "media_assets_size_ck": { + "name": "media_assets_size_ck", + "value": "\"media_assets\".\"size\" BETWEEN 1 AND 5242880" + }, + "media_assets_title_ck": { + "name": "media_assets_title_ck", + "value": "char_length(\"media_assets\".\"title\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + }, + "public.membership_establishments": { + "name": "membership_establishments", + "schema": "", + "columns": { + "membership_id": { + "name": "membership_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "membership_establishments_membership_id_memberships_id_fk": { + "name": "membership_establishments_membership_id_memberships_id_fk", + "tableFrom": "membership_establishments", + "tableTo": "memberships", + "columnsFrom": [ + "membership_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "membership_establishments_establishment_id_establishments_id_fk": { + "name": "membership_establishments_establishment_id_establishments_id_fk", + "tableFrom": "membership_establishments", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "membership_establishments_membership_id_establishment_id_pk": { + "name": "membership_establishments_membership_id_establishment_id_pk", + "columns": [ + "membership_id", + "establishment_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memberships": { + "name": "memberships", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "all_establishments": { + "name": "all_establishments", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "permissions_added": { + "name": "permissions_added", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "permissions_removed": { + "name": "permissions_removed", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "memberships_user_org_uq": { + "name": "memberships_user_org_uq", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memberships_user_id_users_id_fk": { + "name": "memberships_user_id_users_id_fk", + "tableFrom": "memberships", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memberships_organization_id_organizations_id_fk": { + "name": "memberships_organization_id_organizations_id_fk", + "tableFrom": "memberships", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "messages_conv_idx": { + "name": "messages_conv_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "messages_organization_id_organizations_id_fk": { + "name": "messages_organization_id_organizations_id_fk", + "tableFrom": "messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_conversation_id_conversations_id_fk": { + "name": "messages_conversation_id_conversations_id_fk", + "tableFrom": "messages", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_user_id_users_id_fk": { + "name": "messages_user_id_users_id_fk", + "tableFrom": "messages", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mfa_challenges": { + "name": "mfa_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mfa_challenges_user_idx": { + "name": "mfa_challenges_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mfa_challenges_user_id_users_id_fk": { + "name": "mfa_challenges_user_id_users_id_fk", + "tableFrom": "mfa_challenges", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.monthly_budgets": { + "name": "monthly_budgets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "month": { + "name": "month", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "revenue_ht": { + "name": "revenue_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "charges_ht": { + "name": "charges_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "food_cost_pct": { + "name": "food_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "beverage_cost_pct": { + "name": "beverage_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "labor_cost_pct": { + "name": "labor_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "monthly_budgets_est_month_uq": { + "name": "monthly_budgets_est_month_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "monthly_budgets_org_idx": { + "name": "monthly_budgets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "monthly_budgets_organization_id_organizations_id_fk": { + "name": "monthly_budgets_organization_id_organizations_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "monthly_budgets_establishment_id_establishments_id_fk": { + "name": "monthly_budgets_establishment_id_establishments_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "monthly_budgets_updated_by_users_id_fk": { + "name": "monthly_budgets_updated_by_users_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "monthly_budgets_month_ck": { + "name": "monthly_budgets_month_ck", + "value": "extract(day from \"monthly_budgets\".\"month\") = 1" + }, + "monthly_budgets_values_ck": { + "name": "monthly_budgets_values_ck", + "value": "(\"monthly_budgets\".\"revenue_ht\" IS NULL OR \"monthly_budgets\".\"revenue_ht\" >= 0) AND (\"monthly_budgets\".\"charges_ht\" IS NULL OR \"monthly_budgets\".\"charges_ht\" >= 0) AND (\"monthly_budgets\".\"covers\" IS NULL OR \"monthly_budgets\".\"covers\" >= 0)\n AND (\"monthly_budgets\".\"food_cost_pct\" IS NULL OR \"monthly_budgets\".\"food_cost_pct\" BETWEEN 0 AND 100) AND (\"monthly_budgets\".\"beverage_cost_pct\" IS NULL OR \"monthly_budgets\".\"beverage_cost_pct\" BETWEEN 0 AND 100) AND (\"monthly_budgets\".\"labor_cost_pct\" IS NULL OR \"monthly_budgets\".\"labor_cost_pct\" BETWEEN 0 AND 100)" + } + }, + "isRLSEnabled": false + }, + "public.notification_deliveries": { + "name": "notification_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "notification_id": { + "name": "notification_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_outbox_id": { + "name": "email_outbox_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "push_subscription_id": { + "name": "push_subscription_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_deliveries_org_idx": { + "name": "notification_deliveries_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_deliveries_user_idx": { + "name": "notification_deliveries_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_deliveries_pending_idx": { + "name": "notification_deliveries_pending_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_deliveries_organization_id_organizations_id_fk": { + "name": "notification_deliveries_organization_id_organizations_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_deliveries_user_id_users_id_fk": { + "name": "notification_deliveries_user_id_users_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_deliveries_notification_id_notifications_id_fk": { + "name": "notification_deliveries_notification_id_notifications_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "notifications", + "columnsFrom": [ + "notification_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "notification_deliveries_email_outbox_id_email_outbox_id_fk": { + "name": "notification_deliveries_email_outbox_id_email_outbox_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "email_outbox", + "columnsFrom": [ + "email_outbox_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "notification_deliveries_push_subscription_id_push_subscriptions_id_fk": { + "name": "notification_deliveries_push_subscription_id_push_subscriptions_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "push_subscriptions", + "columnsFrom": [ + "push_subscription_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_deliveries_channel_ck": { + "name": "notification_deliveries_channel_ck", + "value": "\"notification_deliveries\".\"channel\" IN ('in_app', 'email', 'push', 'sms')" + }, + "notification_deliveries_status_ck": { + "name": "notification_deliveries_status_ck", + "value": "\"notification_deliveries\".\"status\" IN ('envoye', 'en_attente', 'echec', 'simule', 'desactive', 'indisponible')" + } + }, + "isRLSEnabled": false + }, + "public.notification_preferences": { + "name": "notification_preferences", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notification_preferences_organization_id_organizations_id_fk": { + "name": "notification_preferences_organization_id_organizations_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_preferences_user_id_users_id_fk": { + "name": "notification_preferences_user_id_users_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "notification_preferences_organization_id_user_id_category_channel_pk": { + "name": "notification_preferences_organization_id_user_id_category_channel_pk", + "columns": [ + "organization_id", + "user_id", + "category", + "channel" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_preferences_channel_ck": { + "name": "notification_preferences_channel_ck", + "value": "\"notification_preferences\".\"channel\" IN ('in_app', 'email', 'push', 'sms')" + } + }, + "isRLSEnabled": false + }, + "public.notification_templates": { + "name": "notification_templates", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notification_templates_organization_id_organizations_id_fk": { + "name": "notification_templates_organization_id_organizations_id_fk", + "tableFrom": "notification_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_templates_updated_by_users_id_fk": { + "name": "notification_templates_updated_by_users_id_fk", + "tableFrom": "notification_templates", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "notification_templates_organization_id_category_channel_pk": { + "name": "notification_templates_organization_id_category_channel_pk", + "columns": [ + "organization_id", + "category", + "channel" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_templates_channel_ck": { + "name": "notification_templates_channel_ck", + "value": "\"notification_templates\".\"channel\" IN ('email', 'push', 'sms')" + } + }, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_user_idx": { + "name": "notifications_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_organization_id_organizations_id_fk": { + "name": "notifications_organization_id_organizations_id_fk", + "tableFrom": "notifications", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oil_checks": { + "name": "oil_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "polar_pct": { + "name": "polar_pct", + "type": "numeric(4, 1)", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "oil_checks_est_idx": { + "name": "oil_checks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oil_checks_organization_id_organizations_id_fk": { + "name": "oil_checks_organization_id_organizations_id_fk", + "tableFrom": "oil_checks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oil_checks_establishment_id_establishments_id_fk": { + "name": "oil_checks_establishment_id_establishments_id_fk", + "tableFrom": "oil_checks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "oil_checks_equipment_id_equipment_id_fk": { + "name": "oil_checks_equipment_id_equipment_id_fk", + "tableFrom": "oil_checks", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "oil_checks_recorded_by_users_id_fk": { + "name": "oil_checks_recorded_by_users_id_fk", + "tableFrom": "oil_checks", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "oil_checks_cancelled_by_users_id_fk": { + "name": "oil_checks_cancelled_by_users_id_fk", + "tableFrom": "oil_checks", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "oil_checks_kind_ck": { + "name": "oil_checks_kind_ck", + "value": "\"oil_checks\".\"kind\" IN ('controle', 'filtrage', 'changement')" + }, + "oil_checks_action_ck": { + "name": "oil_checks_action_ck", + "value": "\"oil_checks\".\"conform\" OR \"oil_checks\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.onboarding_items": { + "name": "onboarding_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "step_id": { + "name": "step_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "due_on": { + "name": "due_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "auto_check": { + "name": "auto_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "done_how": { + "name": "done_how", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_items_emp_idx": { + "name": "onboarding_items_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "onboarding_items_step_uq": { + "name": "onboarding_items_step_uq", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "step_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"onboarding_items\".\"step_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_items_organization_id_organizations_id_fk": { + "name": "onboarding_items_organization_id_organizations_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_items_employee_id_employees_id_fk": { + "name": "onboarding_items_employee_id_employees_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_items_step_id_onboarding_steps_id_fk": { + "name": "onboarding_items_step_id_onboarding_steps_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "onboarding_steps", + "columnsFrom": [ + "step_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "onboarding_items_done_by_users_id_fk": { + "name": "onboarding_items_done_by_users_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "onboarding_items_how_ck": { + "name": "onboarding_items_how_ck", + "value": "\"onboarding_items\".\"done_how\" IS NULL OR \"onboarding_items\".\"done_how\" IN ('manuel', 'auto')" + } + }, + "isRLSEnabled": false + }, + "public.onboarding_steps": { + "name": "onboarding_steps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "day_offset": { + "name": "day_offset", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "auto_check": { + "name": "auto_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_steps_org_idx": { + "name": "onboarding_steps_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_steps_organization_id_organizations_id_fk": { + "name": "onboarding_steps_organization_id_organizations_id_fk", + "tableFrom": "onboarding_steps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "onboarding_steps_offset_ck": { + "name": "onboarding_steps_offset_ck", + "value": "\"onboarding_steps\".\"day_offset\" BETWEEN -60 AND 365" + } + }, + "isRLSEnabled": false + }, + "public.organizations": { + "name": "organizations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_demo": { + "name": "is_demo", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "stock_valuation": { + "name": "stock_valuation", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'dernier_prix'" + }, + "require_mfa": { + "name": "require_mfa", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_via": { + "name": "created_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "onboarding_dismissed_at": { + "name": "onboarding_dismissed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "onboarding_skipped": { + "name": "onboarding_skipped", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "is_test": { + "name": "is_test", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "suspended_at": { + "name": "suspended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organizations_slug_unique": { + "name": "organizations_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": { + "organizations_stock_valuation_ck": { + "name": "organizations_stock_valuation_ck", + "value": "\"organizations\".\"stock_valuation\" IN ('dernier_prix', 'cump', 'fifo')" + }, + "organizations_demo_or_test_ck": { + "name": "organizations_demo_or_test_ck", + "value": "NOT (\"organizations\".\"is_demo\" AND \"organizations\".\"is_test\")" + } + }, + "isRLSEnabled": false + }, + "public.partner_booking_imports": { + "name": "partner_booking_imports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "partner": { + "name": "partner", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created": { + "name": "created", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated": { + "name": "updated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cancelled": { + "name": "cancelled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "unchanged": { + "name": "unchanged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skipped": { + "name": "skipped", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "notes": { + "name": "notes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "partner_booking_imports_est_idx": { + "name": "partner_booking_imports_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "partner_booking_imports_organization_id_organizations_id_fk": { + "name": "partner_booking_imports_organization_id_organizations_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "partner_booking_imports_establishment_id_establishments_id_fk": { + "name": "partner_booking_imports_establishment_id_establishments_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "partner_booking_imports_created_by_users_id_fk": { + "name": "partner_booking_imports_created_by_users_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "partner_booking_imports_partner_ck": { + "name": "partner_booking_imports_partner_ck", + "value": "\"partner_booking_imports\".\"partner\" IN ('thefork', 'opentable', 'google')" + }, + "partner_booking_imports_origin_ck": { + "name": "partner_booking_imports_origin_ck", + "value": "\"partner_booking_imports\".\"origin\" IN ('api', 'fichier', 'demo')" + } + }, + "isRLSEnabled": false + }, + "public.payroll_bonuses": { + "name": "payroll_bonuses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount_gross": { + "name": "amount_gross", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payroll_bonuses_est_date_idx": { + "name": "payroll_bonuses_est_date_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payroll_bonuses_org_idx": { + "name": "payroll_bonuses_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payroll_bonuses_organization_id_organizations_id_fk": { + "name": "payroll_bonuses_organization_id_organizations_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_establishment_id_establishments_id_fk": { + "name": "payroll_bonuses_establishment_id_establishments_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_employee_id_employees_id_fk": { + "name": "payroll_bonuses_employee_id_employees_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_created_by_users_id_fk": { + "name": "payroll_bonuses_created_by_users_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "payroll_bonuses_amount_ck": { + "name": "payroll_bonuses_amount_ck", + "value": "\"payroll_bonuses\".\"amount_gross\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.payroll_parameters": { + "name": "payroll_parameters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "effective_from": { + "name": "effective_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "employer_charge_pct": { + "name": "employer_charge_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "labor_alert_pct": { + "name": "labor_alert_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "source_note": { + "name": "source_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "min_productivity_ht": { + "name": "min_productivity_ht", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "meal_value": { + "name": "meal_value", + "type": "numeric(8, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payroll_parameters_est_from_uq": { + "name": "payroll_parameters_est_from_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payroll_parameters_org_idx": { + "name": "payroll_parameters_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payroll_parameters_organization_id_organizations_id_fk": { + "name": "payroll_parameters_organization_id_organizations_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_parameters_establishment_id_establishments_id_fk": { + "name": "payroll_parameters_establishment_id_establishments_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_parameters_created_by_users_id_fk": { + "name": "payroll_parameters_created_by_users_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "payroll_parameters_pct_ck": { + "name": "payroll_parameters_pct_ck", + "value": "(\"payroll_parameters\".\"employer_charge_pct\" IS NULL OR \"payroll_parameters\".\"employer_charge_pct\" BETWEEN 0 AND 100) AND (\"payroll_parameters\".\"labor_alert_pct\" IS NULL OR \"payroll_parameters\".\"labor_alert_pct\" BETWEEN 0 AND 100)" + }, + "payroll_parameters_prod_ck": { + "name": "payroll_parameters_prod_ck", + "value": "\"payroll_parameters\".\"min_productivity_ht\" IS NULL OR \"payroll_parameters\".\"min_productivity_ht\" > 0" + }, + "payroll_parameters_meal_ck": { + "name": "payroll_parameters_meal_ck", + "value": "\"payroll_parameters\".\"meal_value\" IS NULL OR \"payroll_parameters\".\"meal_value\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.pennylane_category_mappings": { + "name": "pennylane_category_mappings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category_key": { + "name": "category_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_category_mappings_uq": { + "name": "pennylane_category_mappings_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "category_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_category_mappings_organization_id_organizations_id_fk": { + "name": "pennylane_category_mappings_organization_id_organizations_id_fk", + "tableFrom": "pennylane_category_mappings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_category_mappings_updated_by_users_id_fk": { + "name": "pennylane_category_mappings_updated_by_users_id_fk", + "tableFrom": "pennylane_category_mappings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.pennylane_item_prices": { + "name": "pennylane_item_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "record_id": { + "name": "record_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "line_index": { + "name": "line_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_item_prices_line_uq": { + "name": "pennylane_item_prices_line_uq", + "columns": [ + { + "expression": "record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "line_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pennylane_item_prices_item_idx": { + "name": "pennylane_item_prices_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_item_prices_organization_id_organizations_id_fk": { + "name": "pennylane_item_prices_organization_id_organizations_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_establishment_id_establishments_id_fk": { + "name": "pennylane_item_prices_establishment_id_establishments_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_record_id_pennylane_records_id_fk": { + "name": "pennylane_item_prices_record_id_pennylane_records_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "pennylane_records", + "columnsFrom": [ + "record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_item_id_purchase_items_id_fk": { + "name": "pennylane_item_prices_item_id_purchase_items_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pennylane_item_prices_method_ck": { + "name": "pennylane_item_prices_method_ck", + "value": "\"pennylane_item_prices\".\"method\" IN ('confirme', 'reference', 'libelle')" + }, + "pennylane_item_prices_values_ck": { + "name": "pennylane_item_prices_values_ck", + "value": "\"pennylane_item_prices\".\"quantity\" > 0 AND \"pennylane_item_prices\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.pennylane_records": { + "name": "pennylane_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "third_party": { + "name": "third_party", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "remaining": { + "name": "remaining", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "payment_status": { + "name": "payment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unknown'" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tax": { + "name": "tax", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "bank_account_ref": { + "name": "bank_account_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "raw": { + "name": "raw", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "synced_at": { + "name": "synced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_records_uq": { + "name": "pennylane_records_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pennylane_records_date_idx": { + "name": "pennylane_records_date_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_records_organization_id_organizations_id_fk": { + "name": "pennylane_records_organization_id_organizations_id_fk", + "tableFrom": "pennylane_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_records_establishment_id_establishments_id_fk": { + "name": "pennylane_records_establishment_id_establishments_id_fk", + "tableFrom": "pennylane_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pennylane_records_kind_ck": { + "name": "pennylane_records_kind_ck", + "value": "\"pennylane_records\".\"kind\" IN ('supplier_invoice', 'customer_invoice', 'transaction', 'bank_account')" + } + }, + "isRLSEnabled": false + }, + "public.planning_absences": { + "name": "planning_absences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "part": { + "name": "part", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'journee'" + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_absences_uq": { + "name": "planning_absences_uq", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "part", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_absences_organization_id_organizations_id_fk": { + "name": "planning_absences_organization_id_organizations_id_fk", + "tableFrom": "planning_absences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_absences_employee_id_employees_id_fk": { + "name": "planning_absences_employee_id_employees_id_fk", + "tableFrom": "planning_absences", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_absences_created_by_users_id_fk": { + "name": "planning_absences_created_by_users_id_fk", + "tableFrom": "planning_absences", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_absences_part_ck": { + "name": "planning_absences_part_ck", + "value": "\"planning_absences\".\"part\" IN ('journee', 'matin', 'apres_midi')" + } + }, + "isRLSEnabled": false + }, + "public.planning_day_budgets": { + "name": "planning_day_budgets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "sales_ht": { + "name": "sales_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_day_budgets_uq": { + "name": "planning_day_budgets_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "planning_day_budgets_org_idx": { + "name": "planning_day_budgets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_day_budgets_organization_id_organizations_id_fk": { + "name": "planning_day_budgets_organization_id_organizations_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_budgets_establishment_id_establishments_id_fk": { + "name": "planning_day_budgets_establishment_id_establishments_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_budgets_updated_by_users_id_fk": { + "name": "planning_day_budgets_updated_by_users_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_day_budgets_ck": { + "name": "planning_day_budgets_ck", + "value": "\"planning_day_budgets\".\"sales_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.planning_day_notes": { + "name": "planning_day_notes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_day_notes_uq": { + "name": "planning_day_notes_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_day_notes_organization_id_organizations_id_fk": { + "name": "planning_day_notes_organization_id_organizations_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_notes_establishment_id_establishments_id_fk": { + "name": "planning_day_notes_establishment_id_establishments_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_notes_updated_by_users_id_fk": { + "name": "planning_day_notes_updated_by_users_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_day_notes_len_ck": { + "name": "planning_day_notes_len_ck", + "value": "char_length(\"planning_day_notes\".\"text\") BETWEEN 1 AND 500" + } + }, + "isRLSEnabled": false + }, + "public.planning_weeks": { + "name": "planning_weeks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "week_start": { + "name": "week_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_by": { + "name": "published_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "changed_at": { + "name": "changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sales_forecast_ht": { + "name": "sales_forecast_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "hours_budget": { + "name": "hours_budget", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": false + }, + "published_teams": { + "name": "published_teams", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "published_pdf": { + "name": "published_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_weeks_uq": { + "name": "planning_weeks_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "week_start", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_weeks_organization_id_organizations_id_fk": { + "name": "planning_weeks_organization_id_organizations_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_weeks_establishment_id_establishments_id_fk": { + "name": "planning_weeks_establishment_id_establishments_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_weeks_published_by_users_id_fk": { + "name": "planning_weeks_published_by_users_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "users", + "columnsFrom": [ + "published_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_settings": { + "name": "platform_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "default": 1 + }, + "signup_open": { + "name": "signup_open", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "mail_organization_id": { + "name": "mail_organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "vapid_public_key": { + "name": "vapid_public_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vapid_private_enc": { + "name": "vapid_private_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "platform_settings_mail_organization_id_organizations_id_fk": { + "name": "platform_settings_mail_organization_id_organizations_id_fk", + "tableFrom": "platform_settings", + "tableTo": "organizations", + "columnsFrom": [ + "mail_organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "platform_settings_updated_by_users_id_fk": { + "name": "platform_settings_updated_by_users_id_fk", + "tableFrom": "platform_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "platform_settings_single_ck": { + "name": "platform_settings_single_ck", + "value": "\"platform_settings\".\"id\" = 1" + } + }, + "isRLSEnabled": false + }, + "public.posting_records": { + "name": "posting_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "values": { + "name": "values", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installed_on": { + "name": "installed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_size": { + "name": "photo_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "validated_by_name": { + "name": "validated_by_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "posting_records_uq": { + "name": "posting_records_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "posting_records_org_idx": { + "name": "posting_records_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "posting_records_organization_id_organizations_id_fk": { + "name": "posting_records_organization_id_organizations_id_fk", + "tableFrom": "posting_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "posting_records_establishment_id_establishments_id_fk": { + "name": "posting_records_establishment_id_establishments_id_fk", + "tableFrom": "posting_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "posting_records_validated_by_users_id_fk": { + "name": "posting_records_validated_by_users_id_fk", + "tableFrom": "posting_records", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "posting_records_updated_by_users_id_fk": { + "name": "posting_records_updated_by_users_id_fk", + "tableFrom": "posting_records", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "posting_records_photo_ck": { + "name": "posting_records_photo_ck", + "value": "(\"posting_records\".\"photo\" IS NULL) = (\"posting_records\".\"photo_mime\" IS NULL) AND (\"posting_records\".\"photo\" IS NULL OR \"posting_records\".\"photo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + }, + "posting_records_validation_ck": { + "name": "posting_records_validation_ck", + "value": "(\"posting_records\".\"validated_at\" IS NULL) = (\"posting_records\".\"validated_by_name\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.price_request_lines": { + "name": "price_request_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "price_request_lines_item_uq": { + "name": "price_request_lines_item_uq", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_lines_organization_id_organizations_id_fk": { + "name": "price_request_lines_organization_id_organizations_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_lines_request_id_price_requests_id_fk": { + "name": "price_request_lines_request_id_price_requests_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "price_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_lines_item_id_purchase_items_id_fk": { + "name": "price_request_lines_item_id_purchase_items_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_lines_amount_ck": { + "name": "price_request_lines_amount_ck", + "value": "\"price_request_lines\".\"amount\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.price_request_offers": { + "name": "price_request_offers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_supplier_id": { + "name": "request_supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "line_id": { + "name": "line_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "awarded": { + "name": "awarded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_request_offers_uq": { + "name": "price_request_offers_uq", + "columns": [ + { + "expression": "request_supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "line_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_offers_organization_id_organizations_id_fk": { + "name": "price_request_offers_organization_id_organizations_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_offers_request_supplier_id_price_request_suppliers_id_fk": { + "name": "price_request_offers_request_supplier_id_price_request_suppliers_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "price_request_suppliers", + "columnsFrom": [ + "request_supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_offers_line_id_price_request_lines_id_fk": { + "name": "price_request_offers_line_id_price_request_lines_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "price_request_lines", + "columnsFrom": [ + "line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_offers_price_ck": { + "name": "price_request_offers_price_ck", + "value": "\"price_request_offers\".\"unit_price_ht\" IS NULL OR \"price_request_offers\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.price_request_suppliers": { + "name": "price_request_suppliers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emailed": { + "name": "emailed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "answered_at": { + "name": "answered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "answered_via": { + "name": "answered_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answered_name": { + "name": "answered_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answer_note": { + "name": "answer_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_request_suppliers_uq": { + "name": "price_request_suppliers_uq", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "price_request_suppliers_token_uq": { + "name": "price_request_suppliers_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_suppliers_organization_id_organizations_id_fk": { + "name": "price_request_suppliers_organization_id_organizations_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_suppliers_request_id_price_requests_id_fk": { + "name": "price_request_suppliers_request_id_price_requests_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "price_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_suppliers_supplier_id_suppliers_id_fk": { + "name": "price_request_suppliers_supplier_id_suppliers_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_suppliers_via_ck": { + "name": "price_request_suppliers_via_ck", + "value": "\"price_request_suppliers\".\"answered_via\" IS NULL OR \"price_request_suppliers\".\"answered_via\" IN ('en_ligne', 'saisie')" + } + }, + "isRLSEnabled": false + }, + "public.price_requests": { + "name": "price_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_by": { + "name": "reply_by", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "needed_by": { + "name": "needed_by", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "awarded_at": { + "name": "awarded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_requests_number_uq": { + "name": "price_requests_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "price_requests_est_idx": { + "name": "price_requests_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_requests_organization_id_organizations_id_fk": { + "name": "price_requests_organization_id_organizations_id_fk", + "tableFrom": "price_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_requests_establishment_id_establishments_id_fk": { + "name": "price_requests_establishment_id_establishments_id_fk", + "tableFrom": "price_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "price_requests_created_by_users_id_fk": { + "name": "price_requests_created_by_users_id_fk", + "tableFrom": "price_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_requests_status_ck": { + "name": "price_requests_status_ck", + "value": "\"price_requests\".\"status\" IN ('brouillon', 'envoyee', 'attribuee', 'annulee')" + } + }, + "isRLSEnabled": false + }, + "public.privacy_requests": { + "name": "privacy_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_kind": { + "name": "subject_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_label": { + "name": "subject_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_type": { + "name": "request_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "target_on": { + "name": "target_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'recue'" + }, + "responded_on": { + "name": "responded_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "handled_by": { + "name": "handled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "privacy_requests_org_idx": { + "name": "privacy_requests_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "privacy_requests_organization_id_organizations_id_fk": { + "name": "privacy_requests_organization_id_organizations_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "privacy_requests_establishment_id_establishments_id_fk": { + "name": "privacy_requests_establishment_id_establishments_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "privacy_requests_employee_id_employees_id_fk": { + "name": "privacy_requests_employee_id_employees_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_customer_id_customers_id_fk": { + "name": "privacy_requests_customer_id_customers_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_handled_by_users_id_fk": { + "name": "privacy_requests_handled_by_users_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "users", + "columnsFrom": [ + "handled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_created_by_users_id_fk": { + "name": "privacy_requests_created_by_users_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "privacy_requests_kind_ck": { + "name": "privacy_requests_kind_ck", + "value": "\"privacy_requests\".\"subject_kind\" IN ('salarie', 'client', 'autre')" + }, + "privacy_requests_type_ck": { + "name": "privacy_requests_type_ck", + "value": "\"privacy_requests\".\"request_type\" IN ('acces', 'rectification', 'effacement', 'opposition')" + }, + "privacy_requests_channel_ck": { + "name": "privacy_requests_channel_ck", + "value": "\"privacy_requests\".\"channel\" IN ('email', 'courrier', 'oral', 'sur_place', 'autre')" + }, + "privacy_requests_status_ck": { + "name": "privacy_requests_status_ck", + "value": "\"privacy_requests\".\"status\" IN ('recue', 'en_cours', 'traitee', 'refusee', 'sans_suite')" + }, + "privacy_requests_done_ck": { + "name": "privacy_requests_done_ck", + "value": "\"privacy_requests\".\"status\" NOT IN ('traitee', 'refusee') OR \"privacy_requests\".\"responded_on\" IS NOT NULL" + }, + "privacy_requests_refused_ck": { + "name": "privacy_requests_refused_ck", + "value": "\"privacy_requests\".\"status\" <> 'refusee' OR \"privacy_requests\".\"outcome\" IS NOT NULL" + }, + "privacy_requests_dates_ck": { + "name": "privacy_requests_dates_ck", + "value": "\"privacy_requests\".\"responded_on\" IS NULL OR \"privacy_requests\".\"responded_on\" >= \"privacy_requests\".\"received_on\"" + } + }, + "isRLSEnabled": false + }, + "public.product_temperatures": { + "name": "product_temperatures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_at": { + "name": "start_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "start_temp": { + "name": "start_temp", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": true + }, + "end_at": { + "name": "end_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "end_temp": { + "name": "end_temp", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "completed_by": { + "name": "completed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "product_temperatures_est_idx": { + "name": "product_temperatures_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "start_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "product_temperatures_organization_id_organizations_id_fk": { + "name": "product_temperatures_organization_id_organizations_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_temperatures_establishment_id_establishments_id_fk": { + "name": "product_temperatures_establishment_id_establishments_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "product_temperatures_recorded_by_users_id_fk": { + "name": "product_temperatures_recorded_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_temperatures_completed_by_users_id_fk": { + "name": "product_temperatures_completed_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "completed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_temperatures_cancelled_by_users_id_fk": { + "name": "product_temperatures_cancelled_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "product_temperatures_kind_ck": { + "name": "product_temperatures_kind_ck", + "value": "\"product_temperatures\".\"kind\" IN ('refroidissement', 'remise_en_temperature', 'coeur_chaud', 'coeur_froid')" + }, + "product_temperatures_status_ck": { + "name": "product_temperatures_status_ck", + "value": "\"product_temperatures\".\"status\" IN ('en_cours', 'termine')" + }, + "product_temperatures_action_ck": { + "name": "product_temperatures_action_ck", + "value": "\"product_temperatures\".\"conform\" IS NOT FALSE OR \"product_temperatures\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.purchase_control_settings": { + "name": "purchase_control_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rise_threshold_pct": { + "name": "rise_threshold_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "rise_window_days": { + "name": "rise_window_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "reception_tolerance_pct": { + "name": "reception_tolerance_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_control_settings_org_uq": { + "name": "purchase_control_settings_org_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_control_settings\".\"establishment_id\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_control_settings_est_uq": { + "name": "purchase_control_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_control_settings\".\"establishment_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_control_settings_organization_id_organizations_id_fk": { + "name": "purchase_control_settings_organization_id_organizations_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_control_settings_establishment_id_establishments_id_fk": { + "name": "purchase_control_settings_establishment_id_establishments_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_control_settings_updated_by_users_id_fk": { + "name": "purchase_control_settings_updated_by_users_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_control_settings_ck": { + "name": "purchase_control_settings_ck", + "value": "(\"purchase_control_settings\".\"rise_threshold_pct\" IS NULL OR (\"purchase_control_settings\".\"rise_threshold_pct\" > 0 AND \"purchase_control_settings\".\"rise_threshold_pct\" <= 100)) AND (\"purchase_control_settings\".\"rise_window_days\" IS NULL OR \"purchase_control_settings\".\"rise_window_days\" BETWEEN 7 AND 365) AND (\"purchase_control_settings\".\"reception_tolerance_pct\" IS NULL OR (\"purchase_control_settings\".\"reception_tolerance_pct\" >= 0 AND \"purchase_control_settings\".\"reception_tolerance_pct\" <= 50))" + } + }, + "isRLSEnabled": false + }, + "public.purchase_invoice_lines": { + "name": "purchase_invoice_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "line_ht": { + "name": "line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_lines_invoice_idx": { + "name": "purchase_lines_invoice_idx", + "columns": [ + { + "expression": "invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_lines_item_idx": { + "name": "purchase_lines_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_invoice_lines_organization_id_organizations_id_fk": { + "name": "purchase_invoice_lines_organization_id_organizations_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoice_lines_invoice_id_purchase_invoices_id_fk": { + "name": "purchase_invoice_lines_invoice_id_purchase_invoices_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoice_lines_item_id_purchase_items_id_fk": { + "name": "purchase_invoice_lines_item_id_purchase_items_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_lines_qty_ck": { + "name": "purchase_lines_qty_ck", + "value": "\"purchase_invoice_lines\".\"quantity\" > 0" + }, + "purchase_lines_price_ck": { + "name": "purchase_lines_price_ck", + "value": "\"purchase_invoice_lines\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.purchase_invoices": { + "name": "purchase_invoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'invoice'" + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_vat": { + "name": "total_vat", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "printed_ttc": { + "name": "printed_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "credit_request_id": { + "name": "credit_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paid_at": { + "name": "paid_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_invoices_period_idx": { + "name": "purchase_invoices_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_number_uq": { + "name": "purchase_invoices_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"invoice_number\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_credit_request_uq": { + "name": "purchase_invoices_credit_request_uq", + "columns": [ + { + "expression": "credit_request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL AND \"purchase_invoices\".\"credit_request_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_order_uq": { + "name": "purchase_invoices_order_uq", + "columns": [ + { + "expression": "purchase_order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL AND \"purchase_invoices\".\"kind\" = 'invoice' AND \"purchase_invoices\".\"purchase_order_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_invoices_organization_id_organizations_id_fk": { + "name": "purchase_invoices_organization_id_organizations_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoices_establishment_id_establishments_id_fk": { + "name": "purchase_invoices_establishment_id_establishments_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_supplier_id_suppliers_id_fk": { + "name": "purchase_invoices_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_purchase_order_id_purchase_orders_id_fk": { + "name": "purchase_invoices_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_credit_request_id_credit_requests_id_fk": { + "name": "purchase_invoices_credit_request_id_credit_requests_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "credit_requests", + "columnsFrom": [ + "credit_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_created_by_users_id_fk": { + "name": "purchase_invoices_created_by_users_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_invoices_cancelled_by_users_id_fk": { + "name": "purchase_invoices_cancelled_by_users_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_invoices_kind_ck": { + "name": "purchase_invoices_kind_ck", + "value": "\"purchase_invoices\".\"kind\" IN ('invoice', 'credit_note')" + }, + "purchase_invoices_ttc_ck": { + "name": "purchase_invoices_ttc_ck", + "value": "\"purchase_invoices\".\"total_ttc\" = \"purchase_invoices\".\"total_ht\" + \"purchase_invoices\".\"total_vat\"" + }, + "purchase_invoices_due_ck": { + "name": "purchase_invoices_due_ck", + "value": "\"purchase_invoices\".\"due_date\" IS NULL OR \"purchase_invoices\".\"due_date\" >= \"purchase_invoices\".\"invoice_date\"" + } + }, + "isRLSEnabled": false + }, + "public.purchase_items": { + "name": "purchase_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "storage_zone": { + "name": "storage_zone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "default_supplier_id": { + "name": "default_supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_ref": { + "name": "supplier_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "barcode": { + "name": "barcode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "catalog_price_ht": { + "name": "catalog_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "catalog_price_date": { + "name": "catalog_price_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "opened_shelf_life_days": { + "name": "opened_shelf_life_days", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_items_org_idx": { + "name": "purchase_items_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_items_org_name_unit_uq": { + "name": "purchase_items_org_name_unit_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "unit", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_items_org_barcode_uq": { + "name": "purchase_items_org_barcode_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "barcode", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_items\".\"barcode\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_items_organization_id_organizations_id_fk": { + "name": "purchase_items_organization_id_organizations_id_fk", + "tableFrom": "purchase_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_items_default_supplier_id_suppliers_id_fk": { + "name": "purchase_items_default_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_items", + "tableTo": "suppliers", + "columnsFrom": [ + "default_supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_items_opened_life_ck": { + "name": "purchase_items_opened_life_ck", + "value": "\"purchase_items\".\"opened_shelf_life_days\" IS NULL OR \"purchase_items\".\"opened_shelf_life_days\" BETWEEN 1 AND 60" + }, + "purchase_items_pack_ck": { + "name": "purchase_items_pack_ck", + "value": "\"purchase_items\".\"pack_size\" IS NULL OR \"purchase_items\".\"pack_size\" > 0" + }, + "purchase_items_catalog_ck": { + "name": "purchase_items_catalog_ck", + "value": "\"purchase_items\".\"catalog_price_ht\" IS NULL OR \"purchase_items\".\"catalog_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.purchase_order_groups": { + "name": "purchase_order_groups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expected_date": { + "name": "expected_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_order_groups_number_uq": { + "name": "purchase_order_groups_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_order_groups_organization_id_organizations_id_fk": { + "name": "purchase_order_groups_organization_id_organizations_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_groups_supplier_id_suppliers_id_fk": { + "name": "purchase_order_groups_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_order_groups_created_by_users_id_fk": { + "name": "purchase_order_groups_created_by_users_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_order_groups_status_ck": { + "name": "purchase_order_groups_status_ck", + "value": "\"purchase_order_groups\".\"status\" IN ('draft', 'sent', 'cancelled')" + } + }, + "isRLSEnabled": false + }, + "public.purchase_order_lines": { + "name": "purchase_order_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "packs": { + "name": "packs", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "line_ht": { + "name": "line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "received_quantity": { + "name": "received_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "received_unit_price_ht": { + "name": "received_unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "received_line_ht": { + "name": "received_line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "reception_note": { + "name": "reception_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_order_lines_order_idx": { + "name": "purchase_order_lines_order_idx", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_order_lines_item_uq": { + "name": "purchase_order_lines_item_uq", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_order_lines_organization_id_organizations_id_fk": { + "name": "purchase_order_lines_organization_id_organizations_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_lines_order_id_purchase_orders_id_fk": { + "name": "purchase_order_lines_order_id_purchase_orders_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "purchase_orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_lines_item_id_purchase_items_id_fk": { + "name": "purchase_order_lines_item_id_purchase_items_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_order_lines_qty_ck": { + "name": "purchase_order_lines_qty_ck", + "value": "\"purchase_order_lines\".\"quantity\" > 0 AND \"purchase_order_lines\".\"unit_price_ht\" >= 0 AND (\"purchase_order_lines\".\"received_quantity\" IS NULL OR \"purchase_order_lines\".\"received_quantity\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.purchase_orders": { + "name": "purchase_orders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "expected_date": { + "name": "expected_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines_ht": { + "name": "lines_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "delivery_fee_ht": { + "name": "delivery_fee_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "ordered_at": { + "name": "ordered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "received_date": { + "name": "received_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "received_time": { + "name": "received_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "delivery_note_number": { + "name": "delivery_note_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplier_gaps_ack_at": { + "name": "supplier_gaps_ack_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "supplier_gaps_ack_by": { + "name": "supplier_gaps_ack_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "received_ht": { + "name": "received_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "reception_comment": { + "name": "reception_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_by": { + "name": "received_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_request_id": { + "name": "price_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_orders_group_idx": { + "name": "purchase_orders_group_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_orders_est_idx": { + "name": "purchase_orders_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_orders_number_uq": { + "name": "purchase_orders_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_orders_organization_id_organizations_id_fk": { + "name": "purchase_orders_organization_id_organizations_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_orders_establishment_id_establishments_id_fk": { + "name": "purchase_orders_establishment_id_establishments_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_supplier_id_suppliers_id_fk": { + "name": "purchase_orders_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_supplier_gaps_ack_by_users_id_fk": { + "name": "purchase_orders_supplier_gaps_ack_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "supplier_gaps_ack_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_orders_received_by_users_id_fk": { + "name": "purchase_orders_received_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "received_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_orders_price_request_id_price_requests_id_fk": { + "name": "purchase_orders_price_request_id_price_requests_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "price_requests", + "columnsFrom": [ + "price_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_group_id_purchase_order_groups_id_fk": { + "name": "purchase_orders_group_id_purchase_order_groups_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "purchase_order_groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_created_by_users_id_fk": { + "name": "purchase_orders_created_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_orders_status_ck": { + "name": "purchase_orders_status_ck", + "value": "\"purchase_orders\".\"status\" IN ('draft', 'sent', 'confirmed', 'received', 'cancelled')" + }, + "purchase_orders_time_ck": { + "name": "purchase_orders_time_ck", + "value": "\"purchase_orders\".\"received_time\" IS NULL OR \"purchase_orders\".\"received_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + } + }, + "isRLSEnabled": false + }, + "public.push_subscriptions": { + "name": "push_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Appareil'" + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "push_subscriptions_endpoint_uq": { + "name": "push_subscriptions_endpoint_uq", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "push_subscriptions_user_idx": { + "name": "push_subscriptions_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "push_subscriptions_organization_id_organizations_id_fk": { + "name": "push_subscriptions_organization_id_organizations_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.quotes": { + "name": "quotes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_kind": { + "name": "event_kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_time": { + "name": "event_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "guests": { + "name": "guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "client_name": { + "name": "client_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_company": { + "name": "client_company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_email": { + "name": "client_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_phone": { + "name": "client_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_address": { + "name": "client_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "issued_on": { + "name": "issued_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_vat": { + "name": "total_vat", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "deposit_percent": { + "name": "deposit_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "deposit_amount": { + "name": "deposit_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "deposit_received_on": { + "name": "deposit_received_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "terms": { + "name": "terms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "viewed_at": { + "name": "viewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_name": { + "name": "accepted_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_via": { + "name": "accepted_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_meta": { + "name": "accepted_meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "refused_reason": { + "name": "refused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lead_id": { + "name": "lead_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "quotes_number_uq": { + "name": "quotes_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "quotes_token_uq": { + "name": "quotes_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"quotes\".\"token_hash\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "quotes_org_idx": { + "name": "quotes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "quotes_organization_id_organizations_id_fk": { + "name": "quotes_organization_id_organizations_id_fk", + "tableFrom": "quotes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "quotes_establishment_id_establishments_id_fk": { + "name": "quotes_establishment_id_establishments_id_fk", + "tableFrom": "quotes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "quotes_customer_id_customers_id_fk": { + "name": "quotes_customer_id_customers_id_fk", + "tableFrom": "quotes", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_reservation_id_reservations_id_fk": { + "name": "quotes_reservation_id_reservations_id_fk", + "tableFrom": "quotes", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_lead_id_leads_id_fk": { + "name": "quotes_lead_id_leads_id_fk", + "tableFrom": "quotes", + "tableTo": "leads", + "columnsFrom": [ + "lead_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_created_by_users_id_fk": { + "name": "quotes_created_by_users_id_fk", + "tableFrom": "quotes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "quotes_status_ck": { + "name": "quotes_status_ck", + "value": "\"quotes\".\"status\" IN ('brouillon', 'envoye', 'accepte', 'refuse', 'annule')" + }, + "quotes_valid_ck": { + "name": "quotes_valid_ck", + "value": "\"quotes\".\"valid_until\" >= \"quotes\".\"issued_on\"" + }, + "quotes_guests_ck": { + "name": "quotes_guests_ck", + "value": "\"quotes\".\"guests\" IS NULL OR \"quotes\".\"guests\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reception_control_lines": { + "name": "reception_control_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "control_id": { + "name": "control_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "stock_lot_id": { + "name": "stock_lot_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "packaging_ok": { + "name": "packaging_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "label_ok": { + "name": "label_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "reception_control_lines_ctl_idx": { + "name": "reception_control_lines_ctl_idx", + "columns": [ + { + "expression": "control_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reception_control_lines_organization_id_organizations_id_fk": { + "name": "reception_control_lines_organization_id_organizations_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_control_lines_control_id_reception_controls_id_fk": { + "name": "reception_control_lines_control_id_reception_controls_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "reception_controls", + "columnsFrom": [ + "control_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_control_lines_item_id_purchase_items_id_fk": { + "name": "reception_control_lines_item_id_purchase_items_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reception_control_lines_stock_lot_id_stock_expiry_lots_id_fk": { + "name": "reception_control_lines_stock_lot_id_stock_expiry_lots_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "stock_expiry_lots", + "columnsFrom": [ + "stock_lot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reception_controls": { + "name": "reception_controls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delivery_note": { + "name": "delivery_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "truck_temperature": { + "name": "truck_temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "vehicle_clean": { + "name": "vehicle_clean", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "decision": { + "name": "decision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reception_controls_est_idx": { + "name": "reception_controls_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reception_controls_organization_id_organizations_id_fk": { + "name": "reception_controls_organization_id_organizations_id_fk", + "tableFrom": "reception_controls", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_controls_establishment_id_establishments_id_fk": { + "name": "reception_controls_establishment_id_establishments_id_fk", + "tableFrom": "reception_controls", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reception_controls_supplier_id_suppliers_id_fk": { + "name": "reception_controls_supplier_id_suppliers_id_fk", + "tableFrom": "reception_controls", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reception_controls_purchase_order_id_purchase_orders_id_fk": { + "name": "reception_controls_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "reception_controls", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reception_controls_recorded_by_users_id_fk": { + "name": "reception_controls_recorded_by_users_id_fk", + "tableFrom": "reception_controls", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reception_controls_cancelled_by_users_id_fk": { + "name": "reception_controls_cancelled_by_users_id_fk", + "tableFrom": "reception_controls", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reception_controls_decision_ck": { + "name": "reception_controls_decision_ck", + "value": "\"reception_controls\".\"decision\" IN ('accepte', 'accepte_reserve', 'refuse')" + }, + "reception_controls_action_ck": { + "name": "reception_controls_action_ck", + "value": "\"reception_controls\".\"conform\" OR \"reception_controls\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.recipe_lines": { + "name": "recipe_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sub_recipe_id": { + "name": "sub_recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "waste_pct": { + "name": "waste_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_lines_recipe_idx": { + "name": "recipe_lines_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_lines_sub_idx": { + "name": "recipe_lines_sub_idx", + "columns": [ + { + "expression": "sub_recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_lines_organization_id_organizations_id_fk": { + "name": "recipe_lines_organization_id_organizations_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_lines_recipe_id_recipes_id_fk": { + "name": "recipe_lines_recipe_id_recipes_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_lines_item_id_purchase_items_id_fk": { + "name": "recipe_lines_item_id_purchase_items_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "recipe_lines_sub_recipe_id_recipes_id_fk": { + "name": "recipe_lines_sub_recipe_id_recipes_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "recipes", + "columnsFrom": [ + "sub_recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipe_lines_waste_ck": { + "name": "recipe_lines_waste_ck", + "value": "\"recipe_lines\".\"waste_pct\" IS NULL OR (\"recipe_lines\".\"waste_pct\" >= 0 AND \"recipe_lines\".\"waste_pct\" < 100)" + }, + "recipe_lines_qty_ck": { + "name": "recipe_lines_qty_ck", + "value": "\"recipe_lines\".\"quantity\" > 0" + }, + "recipe_lines_source_ck": { + "name": "recipe_lines_source_ck", + "value": "(\"recipe_lines\".\"item_id\" IS NULL) <> (\"recipe_lines\".\"sub_recipe_id\" IS NULL)" + }, + "recipe_lines_self_ck": { + "name": "recipe_lines_self_ck", + "value": "\"recipe_lines\".\"sub_recipe_id\" IS NULL OR \"recipe_lines\".\"sub_recipe_id\" <> \"recipe_lines\".\"recipe_id\"" + } + }, + "isRLSEnabled": false + }, + "public.recipe_versions": { + "name": "recipe_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "effective_from": { + "name": "effective_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "yield_quantity": { + "name": "yield_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "yield_unit": { + "name": "yield_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_versions_no_uq": { + "name": "recipe_versions_no_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_from_uq": { + "name": "recipe_versions_from_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_origin_uq": { + "name": "recipe_versions_origin_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"recipe_versions\".\"effective_from\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_org_idx": { + "name": "recipe_versions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_versions_organization_id_organizations_id_fk": { + "name": "recipe_versions_organization_id_organizations_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_versions_recipe_id_recipes_id_fk": { + "name": "recipe_versions_recipe_id_recipes_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_versions_created_by_users_id_fk": { + "name": "recipe_versions_created_by_users_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipe_versions_ck": { + "name": "recipe_versions_ck", + "value": "\"recipe_versions\".\"version\" >= 1 AND \"recipe_versions\".\"portions\" > 0 AND ((\"recipe_versions\".\"version\" = 1) = (\"recipe_versions\".\"effective_from\" IS NULL))" + } + }, + "isRLSEnabled": false + }, + "public.recipes": { + "name": "recipes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "course": { + "name": "course", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'plat'" + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'1'" + }, + "selling_price_ttc": { + "name": "selling_price_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.10'" + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "yield_quantity": { + "name": "yield_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "yield_unit": { + "name": "yield_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "target_margin_pct": { + "name": "target_margin_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "portion_weight_g": { + "name": "portion_weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "quality_tolerance_pct": { + "name": "quality_tolerance_pct", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "plating_standard": { + "name": "plating_standard", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "shelf_life_days": { + "name": "shelf_life_days", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "storage_note": { + "name": "storage_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipes_org_idx": { + "name": "recipes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipes_org_name_uq": { + "name": "recipes_org_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipes_organization_id_organizations_id_fk": { + "name": "recipes_organization_id_organizations_id_fk", + "tableFrom": "recipes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipes_created_by_users_id_fk": { + "name": "recipes_created_by_users_id_fk", + "tableFrom": "recipes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipes_shelf_life_ck": { + "name": "recipes_shelf_life_ck", + "value": "\"recipes\".\"shelf_life_days\" IS NULL OR \"recipes\".\"shelf_life_days\" BETWEEN 1 AND 90" + }, + "recipes_portions_ck": { + "name": "recipes_portions_ck", + "value": "\"recipes\".\"portions\" > 0" + }, + "recipes_yield_ck": { + "name": "recipes_yield_ck", + "value": "(\"recipes\".\"yield_quantity\" IS NULL AND \"recipes\".\"yield_unit\" IS NULL) OR (\"recipes\".\"yield_quantity\" > 0 AND \"recipes\".\"yield_unit\" IS NOT NULL)" + }, + "recipes_margin_ck": { + "name": "recipes_margin_ck", + "value": "\"recipes\".\"target_margin_pct\" IS NULL OR (\"recipes\".\"target_margin_pct\" >= 0 AND \"recipes\".\"target_margin_pct\" < 100)" + }, + "recipes_quality_ck": { + "name": "recipes_quality_ck", + "value": "(\"recipes\".\"portion_weight_g\" IS NULL OR \"recipes\".\"portion_weight_g\" BETWEEN 1 AND 20000) AND (\"recipes\".\"quality_tolerance_pct\" IS NULL OR \"recipes\".\"quality_tolerance_pct\" BETWEEN 1 AND 50)" + } + }, + "isRLSEnabled": false + }, + "public.recovery_codes": { + "name": "recovery_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recovery_codes_user_idx": { + "name": "recovery_codes_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recovery_codes_user_id_users_id_fk": { + "name": "recovery_codes_user_id_users_id_fk", + "tableFrom": "recovery_codes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.register_entries": { + "name": "register_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "topic": { + "name": "topic", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "organism": { + "name": "organism", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "performed_on": { + "name": "performed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "next_due_on": { + "name": "next_due_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "participants": { + "name": "participants", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "observations": { + "name": "observations", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'saisie'" + }, + "source_ref": { + "name": "source_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "register_entries_est_idx": { + "name": "register_entries_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "performed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "register_entries_source_uq": { + "name": "register_entries_source_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"register_entries\".\"source_ref\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "register_entries_organization_id_organizations_id_fk": { + "name": "register_entries_organization_id_organizations_id_fk", + "tableFrom": "register_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "register_entries_establishment_id_establishments_id_fk": { + "name": "register_entries_establishment_id_establishments_id_fk", + "tableFrom": "register_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "register_entries_employee_id_employees_id_fk": { + "name": "register_entries_employee_id_employees_id_fk", + "tableFrom": "register_entries", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_supplier_id_suppliers_id_fk": { + "name": "register_entries_supplier_id_suppliers_id_fk", + "tableFrom": "register_entries", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_document_id_business_documents_id_fk": { + "name": "register_entries_document_id_business_documents_id_fk", + "tableFrom": "register_entries", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_created_by_users_id_fk": { + "name": "register_entries_created_by_users_id_fk", + "tableFrom": "register_entries", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "register_entries_cancelled_by_users_id_fk": { + "name": "register_entries_cancelled_by_users_id_fk", + "tableFrom": "register_entries", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "register_entries_kind_ck": { + "name": "register_entries_kind_ck", + "value": "\"register_entries\".\"kind\" IN ('epi', 'exercice_incendie', 'controle', 'vigilance')" + }, + "register_entries_result_ck": { + "name": "register_entries_result_ck", + "value": "\"register_entries\".\"result\" IS NULL OR \"register_entries\".\"result\" IN ('conforme', 'reserves', 'non_conforme')" + }, + "register_entries_source_ck": { + "name": "register_entries_source_ck", + "value": "\"register_entries\".\"source\" IN ('saisie', 'document')" + }, + "register_entries_due_ck": { + "name": "register_entries_due_ck", + "value": "\"register_entries\".\"next_due_on\" IS NULL OR \"register_entries\".\"next_due_on\" >= \"register_entries\".\"performed_on\"" + }, + "register_entries_counts_ck": { + "name": "register_entries_counts_ck", + "value": "(\"register_entries\".\"quantity\" IS NULL OR \"register_entries\".\"quantity\" BETWEEN 1 AND 1000) AND (\"register_entries\".\"participants\" IS NULL OR \"register_entries\".\"participants\" BETWEEN 0 AND 10000) AND (\"register_entries\".\"duration_minutes\" IS NULL OR \"register_entries\".\"duration_minutes\" BETWEEN 1 AND 1440)" + }, + "register_entries_cancel_ck": { + "name": "register_entries_cancel_ck", + "value": "\"register_entries\".\"cancelled_at\" IS NULL OR (\"register_entries\".\"cancelled_by\" IS NOT NULL AND \"register_entries\".\"cancel_reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.regulatory_obligations": { + "name": "regulatory_obligations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "applicability": { + "name": "applicability", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source_status": { + "name": "source_status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_reference": { + "name": "source_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference_origin": { + "name": "reference_origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "catalogued_on": { + "name": "catalogued_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "verified_at": { + "name": "verified_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "validation_status": { + "name": "validation_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'non_validee'" + }, + "validator_name": { + "name": "validator_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validator_quality": { + "name": "validator_quality", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validated_on": { + "name": "validated_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "legal_delay_text": { + "name": "legal_delay_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hr_check": { + "name": "hr_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "regulatory_obligations_code_uq": { + "name": "regulatory_obligations_code_uq", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "regulatory_obligations_domain_ck": { + "name": "regulatory_obligations_domain_ck", + "value": "\"regulatory_obligations\".\"domain\" IN ('hygiene', 'social', 'securite', 'fiscal', 'affichage', 'licences', 'consommateurs', 'environnement', 'donnees_personnelles')" + }, + "regulatory_obligations_source_ck": { + "name": "regulatory_obligations_source_ck", + "value": "\"regulatory_obligations\".\"source_status\" IN ('documentee', 'a_documenter') AND (\"regulatory_obligations\".\"source_status\" = 'a_documenter' OR \"regulatory_obligations\".\"source_reference\" IS NOT NULL)" + }, + "regulatory_obligations_validation_ck": { + "name": "regulatory_obligations_validation_ck", + "value": "\"regulatory_obligations\".\"validation_status\" IN ('non_validee', 'validee_par_professionnel') AND (\"regulatory_obligations\".\"validation_status\" = 'non_validee' OR (\"regulatory_obligations\".\"validator_name\" IS NOT NULL AND \"regulatory_obligations\".\"validator_quality\" IS NOT NULL AND \"regulatory_obligations\".\"validated_on\" IS NOT NULL))" + }, + "regulatory_obligations_active_ck": { + "name": "regulatory_obligations_active_ck", + "value": "NOT \"regulatory_obligations\".\"active\" OR (\"regulatory_obligations\".\"validation_status\" = 'validee_par_professionnel' AND \"regulatory_obligations\".\"source_status\" = 'documentee' AND \"regulatory_obligations\".\"source_url\" IS NOT NULL AND \"regulatory_obligations\".\"verified_at\" IS NOT NULL)" + }, + "regulatory_obligations_hr_ck": { + "name": "regulatory_obligations_hr_ck", + "value": "\"regulatory_obligations\".\"hr_check\" IS NULL OR \"regulatory_obligations\".\"hr_check\" IN ('work_permit', 'medical_visit', 'dpae')" + } + }, + "isRLSEnabled": false + }, + "public.report_schedules": { + "name": "report_schedules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gestion'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Rapport de gestion'" + }, + "send_time": { + "name": "send_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'07:00'" + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "attach_pdf": { + "name": "attach_pdf", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notify_in_app": { + "name": "notify_in_app", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "recipients": { + "name": "recipients", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "last_period_from": { + "name": "last_period_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "last_sent_at": { + "name": "last_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "indicators": { + "name": "indicators", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "send_condition": { + "name": "send_condition", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "report_schedules_org_idx": { + "name": "report_schedules_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "report_schedules_organization_id_organizations_id_fk": { + "name": "report_schedules_organization_id_organizations_id_fk", + "tableFrom": "report_schedules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_schedules_establishment_id_establishments_id_fk": { + "name": "report_schedules_establishment_id_establishments_id_fk", + "tableFrom": "report_schedules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_schedules_created_by_users_id_fk": { + "name": "report_schedules_created_by_users_id_fk", + "tableFrom": "report_schedules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "report_schedules_audience_ck": { + "name": "report_schedules_audience_ck", + "value": "\"report_schedules\".\"audience\" IS NULL OR \"report_schedules\".\"audience\" IN ('proprietaire', 'direction', 'comptable', 'equipe', 'cuisine')" + }, + "report_schedules_freq_ck": { + "name": "report_schedules_freq_ck", + "value": "\"report_schedules\".\"frequency\" IN ('daily', 'weekly', 'monthly')" + }, + "report_schedules_time_ck": { + "name": "report_schedules_time_ck", + "value": "\"report_schedules\".\"send_time\" ~ '^(0[5-9]|1[0-9]|2[0-2]):(00|15|30|45)$'" + }, + "report_schedules_days_ck": { + "name": "report_schedules_days_ck", + "value": "\"report_schedules\".\"frequency\" <> 'daily' OR (CASE WHEN jsonb_typeof(\"report_schedules\".\"weekdays\") = 'array' THEN jsonb_array_length(\"report_schedules\".\"weekdays\") >= 1 ELSE false END)" + }, + "report_schedules_kind_ck": { + "name": "report_schedules_kind_ck", + "value": "\"report_schedules\".\"kind\" IN ('gestion', 'fermeture', 'groupe')" + }, + "report_schedules_closing_ck": { + "name": "report_schedules_closing_ck", + "value": "\"report_schedules\".\"kind\" <> 'fermeture' OR (\"report_schedules\".\"frequency\" = 'daily' AND \"report_schedules\".\"establishment_id\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.reputation_policies": { + "name": "reputation_policies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "levels": { + "name": "levels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "forbidden_words": { + "name": "forbidden_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "email_alerts": { + "name": "email_alerts", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "escalate_to": { + "name": "escalate_to", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reputation_policies_org_uq": { + "name": "reputation_policies_org_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reputation_policies\".\"establishment_id\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "reputation_policies_est_uq": { + "name": "reputation_policies_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reputation_policies\".\"establishment_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reputation_policies_organization_id_organizations_id_fk": { + "name": "reputation_policies_organization_id_organizations_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_policies_establishment_id_establishments_id_fk": { + "name": "reputation_policies_establishment_id_establishments_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_policies_escalate_to_users_id_fk": { + "name": "reputation_policies_escalate_to_users_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "users", + "columnsFrom": [ + "escalate_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reputation_policies_updated_by_users_id_fk": { + "name": "reputation_policies_updated_by_users_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reputation_policies_tone_ck": { + "name": "reputation_policies_tone_ck", + "value": "\"reputation_policies\".\"tone\" IS NULL OR \"reputation_policies\".\"tone\" IN ('formel', 'chaleureux', 'sobre')" + }, + "reputation_policies_lang_ck": { + "name": "reputation_policies_lang_ck", + "value": "\"reputation_policies\".\"language\" IS NULL OR \"reputation_policies\".\"language\" IN ('fr', 'en')" + } + }, + "isRLSEnabled": false + }, + "public.reputation_settings": { + "name": "reputation_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "review_url": { + "name": "review_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signature": { + "name": "signature", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reputation_settings_establishment_id_establishments_id_fk": { + "name": "reputation_settings_establishment_id_establishments_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_settings_organization_id_organizations_id_fk": { + "name": "reputation_settings_organization_id_organizations_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_settings_updated_by_users_id_fk": { + "name": "reputation_settings_updated_by_users_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reservation_exceptions": { + "name": "reservation_exceptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "service_id": { + "name": "service_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed": { + "name": "closed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "service_capacity": { + "name": "service_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_exceptions_day_idx": { + "name": "reservation_exceptions_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_exceptions_organization_id_organizations_id_fk": { + "name": "reservation_exceptions_organization_id_organizations_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_exceptions_establishment_id_establishments_id_fk": { + "name": "reservation_exceptions_establishment_id_establishments_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservation_exceptions_service_id_reservation_services_id_fk": { + "name": "reservation_exceptions_service_id_reservation_services_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "reservation_services", + "columnsFrom": [ + "service_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_exceptions_created_by_users_id_fk": { + "name": "reservation_exceptions_created_by_users_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_exceptions_cap_ck": { + "name": "reservation_exceptions_cap_ck", + "value": "\"reservation_exceptions\".\"closed\" OR \"reservation_exceptions\".\"service_capacity\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reservation_services": { + "name": "reservation_services", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "first_time": { + "name": "first_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_time": { + "name": "last_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slot_minutes": { + "name": "slot_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "slot_capacity": { + "name": "slot_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "service_capacity": { + "name": "service_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_services_est_idx": { + "name": "reservation_services_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_services_organization_id_organizations_id_fk": { + "name": "reservation_services_organization_id_organizations_id_fk", + "tableFrom": "reservation_services", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_services_establishment_id_establishments_id_fk": { + "name": "reservation_services_establishment_id_establishments_id_fk", + "tableFrom": "reservation_services", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_services_time_ck": { + "name": "reservation_services_time_ck", + "value": "\"reservation_services\".\"first_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_services\".\"last_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "reservation_services_slot_ck": { + "name": "reservation_services_slot_ck", + "value": "\"reservation_services\".\"slot_minutes\" IN (15, 30, 60) AND \"reservation_services\".\"duration_minutes\" BETWEEN 15 AND 720" + }, + "reservation_services_cap_ck": { + "name": "reservation_services_cap_ck", + "value": "(\"reservation_services\".\"slot_capacity\" IS NULL OR \"reservation_services\".\"slot_capacity\" > 0) AND (\"reservation_services\".\"service_capacity\" IS NULL OR \"reservation_services\".\"service_capacity\" > 0)" + } + }, + "isRLSEnabled": false + }, + "public.reservation_settings": { + "name": "reservation_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reminder_email": { + "name": "reminder_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reminder_hour": { + "name": "reminder_hour", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "online_enabled": { + "name": "online_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "online_token": { + "name": "online_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "online_by": { + "name": "online_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "online_max_covers": { + "name": "online_max_covers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 8 + }, + "waitlist_auto_offer": { + "name": "waitlist_auto_offer", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "online_auto_confirm": { + "name": "online_auto_confirm", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "online_lead_minutes": { + "name": "online_lead_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "online_days": { + "name": "online_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 60 + }, + "online_message": { + "name": "online_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "online_groups": { + "name": "online_groups", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_settings_online_token_uq": { + "name": "reservation_settings_online_token_uq", + "columns": [ + { + "expression": "online_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_settings_establishment_id_establishments_id_fk": { + "name": "reservation_settings_establishment_id_establishments_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_settings_organization_id_organizations_id_fk": { + "name": "reservation_settings_organization_id_organizations_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_settings_online_by_users_id_fk": { + "name": "reservation_settings_online_by_users_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "users", + "columnsFrom": [ + "online_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_settings_hour_ck": { + "name": "reservation_settings_hour_ck", + "value": "\"reservation_settings\".\"reminder_hour\" BETWEEN 7 AND 21" + }, + "reservation_settings_online_ck": { + "name": "reservation_settings_online_ck", + "value": "\"reservation_settings\".\"online_max_covers\" BETWEEN 1 AND 50 AND \"reservation_settings\".\"online_lead_minutes\" BETWEEN 0 AND 2880 AND \"reservation_settings\".\"online_days\" BETWEEN 1 AND 365" + } + }, + "isRLSEnabled": false + }, + "public.reservation_tables": { + "name": "reservation_tables", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "starts_at": { + "name": "starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ends_at": { + "name": "ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "released_at": { + "name": "released_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_tables_res_idx": { + "name": "reservation_tables_res_idx", + "columns": [ + { + "expression": "reservation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservation_tables_table_idx": { + "name": "reservation_tables_table_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "starts_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_tables_organization_id_organizations_id_fk": { + "name": "reservation_tables_organization_id_organizations_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_tables_establishment_id_establishments_id_fk": { + "name": "reservation_tables_establishment_id_establishments_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservation_tables_reservation_id_reservations_id_fk": { + "name": "reservation_tables_reservation_id_reservations_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_tables_table_id_floor_items_id_fk": { + "name": "reservation_tables_table_id_floor_items_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "floor_items", + "columnsFrom": [ + "table_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_tables_range_ck": { + "name": "reservation_tables_range_ck", + "value": "\"reservation_tables\".\"ends_at\" > \"reservation_tables\".\"starts_at\"" + } + }, + "isRLSEnabled": false + }, + "public.reservation_waitlist": { + "name": "reservation_waitlist", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "time_from": { + "name": "time_from", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "time_to": { + "name": "time_to", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "offered_at": { + "name": "offered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "offered_from_reservation_id": { + "name": "offered_from_reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "offered_time": { + "name": "offered_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "close_reason": { + "name": "close_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_waitlist_day_idx": { + "name": "reservation_waitlist_day_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_waitlist_organization_id_organizations_id_fk": { + "name": "reservation_waitlist_organization_id_organizations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_waitlist_establishment_id_establishments_id_fk": { + "name": "reservation_waitlist_establishment_id_establishments_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_waitlist_offered_from_reservation_id_reservations_id_fk": { + "name": "reservation_waitlist_offered_from_reservation_id_reservations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "reservations", + "columnsFrom": [ + "offered_from_reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservation_waitlist_reservation_id_reservations_id_fk": { + "name": "reservation_waitlist_reservation_id_reservations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservation_waitlist_created_by_users_id_fk": { + "name": "reservation_waitlist_created_by_users_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_waitlist_status_ck": { + "name": "reservation_waitlist_status_ck", + "value": "\"reservation_waitlist\".\"status\" IN ('en_attente', 'proposee', 'convertie', 'annulee')" + }, + "reservation_waitlist_covers_ck": { + "name": "reservation_waitlist_covers_ck", + "value": "\"reservation_waitlist\".\"covers\" BETWEEN 1 AND 500" + }, + "reservation_waitlist_time_ck": { + "name": "reservation_waitlist_time_ck", + "value": "\"reservation_waitlist\".\"time_from\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_waitlist\".\"time_to\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_waitlist\".\"time_to\" >= \"reservation_waitlist\".\"time_from\"" + }, + "reservation_waitlist_contact_ck": { + "name": "reservation_waitlist_contact_ck", + "value": "\"reservation_waitlist\".\"phone\" IS NOT NULL OR \"reservation_waitlist\".\"email\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.reservations": { + "name": "reservations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "service_id": { + "name": "service_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "time": { + "name": "time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starts_at": { + "name": "starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ends_at": { + "name": "ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'confirmee'" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'telephone'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request": { + "name": "request", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "arrived_at": { + "name": "arrived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "confirmation_sent_at": { + "name": "confirmation_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reminder_sent_at": { + "name": "reminder_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "external_ref": { + "name": "external_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservations_day_idx": { + "name": "reservations_day_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_customer_idx": { + "name": "reservations_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_external_ref_uq": { + "name": "reservations_external_ref_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reservations\".\"external_ref\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservations_organization_id_organizations_id_fk": { + "name": "reservations_organization_id_organizations_id_fk", + "tableFrom": "reservations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservations_establishment_id_establishments_id_fk": { + "name": "reservations_establishment_id_establishments_id_fk", + "tableFrom": "reservations", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservations_service_id_reservation_services_id_fk": { + "name": "reservations_service_id_reservation_services_id_fk", + "tableFrom": "reservations", + "tableTo": "reservation_services", + "columnsFrom": [ + "service_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservations_customer_id_customers_id_fk": { + "name": "reservations_customer_id_customers_id_fk", + "tableFrom": "reservations", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservations_created_by_users_id_fk": { + "name": "reservations_created_by_users_id_fk", + "tableFrom": "reservations", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservations_status_ck": { + "name": "reservations_status_ck", + "value": "\"reservations\".\"status\" IN ('en_attente', 'confirmee', 'arrivee', 'terminee', 'no_show', 'annulee')" + }, + "reservations_covers_ck": { + "name": "reservations_covers_ck", + "value": "\"reservations\".\"covers\" BETWEEN 1 AND 500" + }, + "reservations_time_ck": { + "name": "reservations_time_ck", + "value": "\"reservations\".\"time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservations\".\"ends_at\" > \"reservations\".\"starts_at\"" + } + }, + "isRLSEnabled": false + }, + "public.review_autopublish": { + "name": "review_autopublish", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "levels": { + "name": "levels", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled_by": { + "name": "enabled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "enabled_at": { + "name": "enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmation": { + "name": "confirmation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "review_autopublish_establishment_id_establishments_id_fk": { + "name": "review_autopublish_establishment_id_establishments_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_autopublish_organization_id_organizations_id_fk": { + "name": "review_autopublish_organization_id_organizations_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_autopublish_enabled_by_users_id_fk": { + "name": "review_autopublish_enabled_by_users_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "users", + "columnsFrom": [ + "enabled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "review_autopublish_updated_by_users_id_fk": { + "name": "review_autopublish_updated_by_users_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.review_publications": { + "name": "review_publications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "review_id": { + "name": "review_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blocked_words": { + "name": "blocked_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "google_reply_state": { + "name": "google_reply_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "review_publications_review_uq": { + "name": "review_publications_review_uq", + "columns": [ + { + "expression": "review_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "review_publications_due_idx": { + "name": "review_publications_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "review_publications_organization_id_organizations_id_fk": { + "name": "review_publications_organization_id_organizations_id_fk", + "tableFrom": "review_publications", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_publications_establishment_id_establishments_id_fk": { + "name": "review_publications_establishment_id_establishments_id_fk", + "tableFrom": "review_publications", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_publications_review_id_reviews_id_fk": { + "name": "review_publications_review_id_reviews_id_fk", + "tableFrom": "review_publications", + "tableTo": "reviews", + "columnsFrom": [ + "review_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "review_publications_status_ck": { + "name": "review_publications_status_ck", + "value": "\"review_publications\".\"status\" IN ('scheduled', 'publishing', 'published', 'failed', 'blocked', 'cancelled', 'skipped')" + } + }, + "isRLSEnabled": false + }, + "public.reviews": { + "name": "reviews", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reviewed_on": { + "name": "reviewed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fingerprint": { + "name": "fingerprint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_text": { + "name": "reply_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "replied_at": { + "name": "replied_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "replied_by": { + "name": "replied_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assigned_to": { + "name": "assigned_to", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "assigned_by": { + "name": "assigned_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rule_action": { + "name": "rule_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "alerted_at": { + "name": "alerted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_name": { + "name": "external_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_updated_at": { + "name": "external_updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reply_origin": { + "name": "reply_origin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reviews_fingerprint_uq": { + "name": "reviews_fingerprint_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "fingerprint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_external_uq": { + "name": "reviews_external_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reviews\".\"external_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_est_day_idx": { + "name": "reviews_est_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reviewed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_assigned_idx": { + "name": "reviews_assigned_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "assigned_to", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"reviews\".\"assigned_to\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reviews_organization_id_organizations_id_fk": { + "name": "reviews_organization_id_organizations_id_fk", + "tableFrom": "reviews", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reviews_establishment_id_establishments_id_fk": { + "name": "reviews_establishment_id_establishments_id_fk", + "tableFrom": "reviews", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reviews_replied_by_users_id_fk": { + "name": "reviews_replied_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "replied_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reviews_assigned_to_users_id_fk": { + "name": "reviews_assigned_to_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "assigned_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reviews_assigned_by_users_id_fk": { + "name": "reviews_assigned_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "assigned_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reviews_created_by_users_id_fk": { + "name": "reviews_created_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reviews_reply_origin_ck": { + "name": "reviews_reply_origin_ck", + "value": "\"reviews\".\"reply_origin\" IS NULL OR \"reviews\".\"reply_origin\" IN ('manuel', 'google', 'auto')" + }, + "reviews_rating_ck": { + "name": "reviews_rating_ck", + "value": "\"reviews\".\"rating\" BETWEEN 1 AND 5" + }, + "reviews_source_ck": { + "name": "reviews_source_ck", + "value": "\"reviews\".\"source\" IN ('google', 'tripadvisor', 'thefork', 'facebook', 'direct', 'autre')" + }, + "reviews_rule_action_ck": { + "name": "reviews_rule_action_ck", + "value": "\"reviews\".\"rule_action\" IS NULL OR \"reviews\".\"rule_action\" IN ('remercier', 'remercier_inviter', 'demander_retour', 'transmettre', 'alerte')" + } + }, + "isRLSEnabled": false + }, + "public.sales_challenges": { + "name": "sales_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'perso'" + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keywords": { + "name": "keywords", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "from_day": { + "name": "from_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "to_day": { + "name": "to_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "rewards": { + "name": "rewards", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "target_value": { + "name": "target_value", + "type": "numeric(14, 3)", + "primaryKey": false, + "notNull": false + }, + "results": { + "name": "results", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_challenges_org_idx": { + "name": "sales_challenges_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_challenges_organization_id_organizations_id_fk": { + "name": "sales_challenges_organization_id_organizations_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_challenges_establishment_id_establishments_id_fk": { + "name": "sales_challenges_establishment_id_establishments_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_challenges_created_by_users_id_fk": { + "name": "sales_challenges_created_by_users_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_challenges_metric_ck": { + "name": "sales_challenges_metric_ck", + "value": "\"sales_challenges\".\"metric\" IN ('quantite', 'ca_ht', 'ca_heure')" + }, + "sales_challenges_range_ck": { + "name": "sales_challenges_range_ck", + "value": "\"sales_challenges\".\"to_day\" >= \"sales_challenges\".\"from_day\" AND \"sales_challenges\".\"to_day\" - \"sales_challenges\".\"from_day\" <= 366" + }, + "sales_challenges_target_ck": { + "name": "sales_challenges_target_ck", + "value": "\"sales_challenges\".\"target_value\" IS NULL OR \"sales_challenges\".\"target_value\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.sales_entries": { + "name": "sales_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "batch_id": { + "name": "batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_date": { + "name": "business_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "ticket_ref": { + "name": "ticket_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "payment_method": { + "name": "payment_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "format_version": { + "name": "format_version", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "line_ref": { + "name": "line_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sold_time": { + "name": "sold_time", + "type": "time", + "primaryKey": false, + "notNull": false + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "product": { + "name": "product", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(12, 3)", + "primaryKey": false, + "notNull": false + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "table_label": { + "name": "table_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discount_ttc": { + "name": "discount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "comp_ttc": { + "name": "comp_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "product_code": { + "name": "product_code", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sales_entries_row_uq": { + "name": "sales_entries_row_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_entries_period_idx": { + "name": "sales_entries_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_entries_ticket_idx": { + "name": "sales_entries_ticket_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ticket_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_entries_organization_id_organizations_id_fk": { + "name": "sales_entries_organization_id_organizations_id_fk", + "tableFrom": "sales_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_entries_establishment_id_establishments_id_fk": { + "name": "sales_entries_establishment_id_establishments_id_fk", + "tableFrom": "sales_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_entries_batch_id_sales_import_batches_id_fk": { + "name": "sales_entries_batch_id_sales_import_batches_id_fk", + "tableFrom": "sales_entries", + "tableTo": "sales_import_batches", + "columnsFrom": [ + "batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_ttc_consistency_ck": { + "name": "sales_ttc_consistency_ck", + "value": "\"sales_entries\".\"amount_ttc\" = \"sales_entries\".\"amount_ht\" + \"sales_entries\".\"vat_amount\"" + }, + "sales_format_version_ck": { + "name": "sales_format_version_ck", + "value": "\"sales_entries\".\"format_version\" IN (1, 2)" + }, + "sales_channel_ck": { + "name": "sales_channel_ck", + "value": "\"sales_entries\".\"channel\" IS NULL OR \"sales_entries\".\"channel\" IN ('sur_place', 'emporter', 'livraison', 'click_collect', 'autre')" + }, + "sales_discount_ck": { + "name": "sales_discount_ck", + "value": "\"sales_entries\".\"discount_ttc\" IS NULL OR \"sales_entries\".\"discount_ttc\" >= 0" + }, + "sales_comp_ck": { + "name": "sales_comp_ck", + "value": "\"sales_entries\".\"comp_ttc\" IS NULL OR \"sales_entries\".\"comp_ttc\" >= 0" + }, + "sales_quantity_ck": { + "name": "sales_quantity_ck", + "value": "\"sales_entries\".\"quantity\" IS NULL OR \"sales_entries\".\"quantity\" <> 0" + } + }, + "isRLSEnabled": false + }, + "public.sales_families": { + "name": "sales_families", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_families_name_uq": { + "name": "sales_families_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_families_organization_id_organizations_id_fk": { + "name": "sales_families_organization_id_organizations_id_fk", + "tableFrom": "sales_families", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_families_created_by_users_id_fk": { + "name": "sales_families_created_by_users_id_fk", + "tableFrom": "sales_families", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_family_rules": { + "name": "sales_family_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "family_id": { + "name": "family_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_kind": { + "name": "match_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_family_rules_uq": { + "name": "sales_family_rules_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_family_rules_organization_id_organizations_id_fk": { + "name": "sales_family_rules_organization_id_organizations_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_family_rules_family_id_sales_families_id_fk": { + "name": "sales_family_rules_family_id_sales_families_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "sales_families", + "columnsFrom": [ + "family_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_family_rules_created_by_users_id_fk": { + "name": "sales_family_rules_created_by_users_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_family_rules_kind_ck": { + "name": "sales_family_rules_kind_ck", + "value": "\"sales_family_rules\".\"match_kind\" IN ('category', 'product')" + } + }, + "isRLSEnabled": false + }, + "public.sales_import_batches": { + "name": "sales_import_batches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_sha256": { + "name": "file_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "row_count": { + "name": "row_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "period_from": { + "name": "period_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_to": { + "name": "period_to", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "import_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "imported_by": { + "name": "imported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reverted_at": { + "name": "reverted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reverted_by": { + "name": "reverted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payment_count": { + "name": "payment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_batches_file_uq": { + "name": "sales_batches_file_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "file_sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_import_batches_organization_id_organizations_id_fk": { + "name": "sales_import_batches_organization_id_organizations_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_import_batches_establishment_id_establishments_id_fk": { + "name": "sales_import_batches_establishment_id_establishments_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_import_batches_imported_by_users_id_fk": { + "name": "sales_import_batches_imported_by_users_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "users", + "columnsFrom": [ + "imported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sales_import_batches_reverted_by_users_id_fk": { + "name": "sales_import_batches_reverted_by_users_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "users", + "columnsFrom": [ + "reverted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_import_profiles": { + "name": "sales_import_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header_signature": { + "name": "header_signature", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "headers": { + "name": "headers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "mapping": { + "name": "mapping", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "use_count": { + "name": "use_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_import_profiles_sig_uq": { + "name": "sales_import_profiles_sig_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "header_signature", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_import_profiles_organization_id_organizations_id_fk": { + "name": "sales_import_profiles_organization_id_organizations_id_fk", + "tableFrom": "sales_import_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_import_profiles_created_by_users_id_fk": { + "name": "sales_import_profiles_created_by_users_id_fk", + "tableFrom": "sales_import_profiles", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_import_profiles_name_ck": { + "name": "sales_import_profiles_name_ck", + "value": "length(\"sales_import_profiles\".\"name\") BETWEEN 1 AND 80" + } + }, + "isRLSEnabled": false + }, + "public.sales_payments": { + "name": "sales_payments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "batch_id": { + "name": "batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_date": { + "name": "business_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "ticket_ref": { + "name": "ticket_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_payments_row_uq": { + "name": "sales_payments_row_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_payments_period_idx": { + "name": "sales_payments_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_payments_organization_id_organizations_id_fk": { + "name": "sales_payments_organization_id_organizations_id_fk", + "tableFrom": "sales_payments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_payments_establishment_id_establishments_id_fk": { + "name": "sales_payments_establishment_id_establishments_id_fk", + "tableFrom": "sales_payments", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_payments_batch_id_sales_import_batches_id_fk": { + "name": "sales_payments_batch_id_sales_import_batches_id_fk", + "tableFrom": "sales_payments", + "tableTo": "sales_import_batches", + "columnsFrom": [ + "batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_product_recipe_history": { + "name": "sales_product_recipe_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "portions_per_sale": { + "name": "portions_per_sale", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_product_recipe_history_uq": { + "name": "sales_product_recipe_history_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "valid_until", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_product_recipe_history_organization_id_organizations_id_fk": { + "name": "sales_product_recipe_history_organization_id_organizations_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_product_recipe_history_recipe_id_recipes_id_fk": { + "name": "sales_product_recipe_history_recipe_id_recipes_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_product_recipe_history_created_by_users_id_fk": { + "name": "sales_product_recipe_history_created_by_users_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_product_recipes": { + "name": "sales_product_recipes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "portions_per_sale": { + "name": "portions_per_sale", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "match_code": { + "name": "match_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_product_recipes_key_uq": { + "name": "sales_product_recipes_key_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_product_recipes_code_uq": { + "name": "sales_product_recipes_code_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"sales_product_recipes\".\"match_code\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_product_recipes_recipe_idx": { + "name": "sales_product_recipes_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_product_recipes_organization_id_organizations_id_fk": { + "name": "sales_product_recipes_organization_id_organizations_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_product_recipes_recipe_id_recipes_id_fk": { + "name": "sales_product_recipes_recipe_id_recipes_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_product_recipes_created_by_users_id_fk": { + "name": "sales_product_recipes_created_by_users_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sales_product_recipes_updated_by_users_id_fk": { + "name": "sales_product_recipes_updated_by_users_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_product_recipes_ck": { + "name": "sales_product_recipes_ck", + "value": "(\"sales_product_recipes\".\"recipe_id\" IS NULL AND \"sales_product_recipes\".\"portions_per_sale\" IS NULL) OR (\"sales_product_recipes\".\"recipe_id\" IS NOT NULL AND \"sales_product_recipes\".\"portions_per_sale\" > 0)" + } + }, + "isRLSEnabled": false + }, + "public.sales_server_links": { + "name": "sales_server_links", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "server_key": { + "name": "server_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "server_label": { + "name": "server_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_server_links_uq": { + "name": "sales_server_links_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "server_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_server_links_org_idx": { + "name": "sales_server_links_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_server_links_organization_id_organizations_id_fk": { + "name": "sales_server_links_organization_id_organizations_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_establishment_id_establishments_id_fk": { + "name": "sales_server_links_establishment_id_establishments_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_employee_id_employees_id_fk": { + "name": "sales_server_links_employee_id_employees_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_created_by_users_id_fk": { + "name": "sales_server_links_created_by_users_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_server_links_key_ck": { + "name": "sales_server_links_key_ck", + "value": "length(\"sales_server_links\".\"server_key\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + }, + "public.sales_service_periods": { + "name": "sales_service_periods", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_service_periods_name_uq": { + "name": "sales_service_periods_name_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_service_periods_organization_id_organizations_id_fk": { + "name": "sales_service_periods_organization_id_organizations_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_service_periods_establishment_id_establishments_id_fk": { + "name": "sales_service_periods_establishment_id_establishments_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_service_periods_created_by_users_id_fk": { + "name": "sales_service_periods_created_by_users_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_service_periods_time_ck": { + "name": "sales_service_periods_time_ck", + "value": "\"sales_service_periods\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"sales_service_periods\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"sales_service_periods\".\"start_time\" <> \"sales_service_periods\".\"end_time\"" + } + }, + "isRLSEnabled": false + }, + "public.sensitive_views": { + "name": "sensitive_views", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "area": { + "name": "area", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "viewed_at": { + "name": "viewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sensitive_views_org_idx": { + "name": "sensitive_views_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "viewed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sensitive_views_user_idx": { + "name": "sensitive_views_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "viewed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sensitive_views_organization_id_organizations_id_fk": { + "name": "sensitive_views_organization_id_organizations_id_fk", + "tableFrom": "sensitive_views", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sensitive_views_user_id_users_id_fk": { + "name": "sensitive_views_user_id_users_id_fk", + "tableFrom": "sensitive_views", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.seo_listings": { + "name": "seo_listings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "directory": { + "name": "directory", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nap_hash": { + "name": "nap_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "checked_by": { + "name": "checked_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_listings_est_dir_uq": { + "name": "seo_listings_est_dir_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "directory", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_listings_org_idx": { + "name": "seo_listings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_listings_organization_id_organizations_id_fk": { + "name": "seo_listings_organization_id_organizations_id_fk", + "tableFrom": "seo_listings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_listings_establishment_id_establishments_id_fk": { + "name": "seo_listings_establishment_id_establishments_id_fk", + "tableFrom": "seo_listings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_listings_checked_by_users_id_fk": { + "name": "seo_listings_checked_by_users_id_fk", + "tableFrom": "seo_listings", + "tableTo": "users", + "columnsFrom": [ + "checked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "seo_listings_status_ck": { + "name": "seo_listings_status_ck", + "value": "\"seo_listings\".\"status\" IN ('en_ligne', 'absent', 'non_concerne')" + } + }, + "isRLSEnabled": false + }, + "public.seo_profiles": { + "name": "seo_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cuisines": { + "name": "cuisines", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "price_range": { + "name": "price_range", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "menu_url": { + "name": "menu_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "links": { + "name": "links", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "keywords": { + "name": "keywords", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_profiles_est_uq": { + "name": "seo_profiles_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_profiles_org_idx": { + "name": "seo_profiles_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_profiles_organization_id_organizations_id_fk": { + "name": "seo_profiles_organization_id_organizations_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_profiles_establishment_id_establishments_id_fk": { + "name": "seo_profiles_establishment_id_establishments_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_profiles_updated_by_users_id_fk": { + "name": "seo_profiles_updated_by_users_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "seo_profiles_price_ck": { + "name": "seo_profiles_price_ck", + "value": "\"seo_profiles\".\"price_range\" IS NULL OR \"seo_profiles\".\"price_range\" IN ('\u20ac', '\u20ac\u20ac', '\u20ac\u20ac\u20ac', '\u20ac\u20ac\u20ac\u20ac')" + } + }, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sessions_user_idx": { + "name": "sessions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sessions_organization_id_organizations_id_fk": { + "name": "sessions_organization_id_organizations_id_fk", + "tableFrom": "sessions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.set_menus": { + "name": "set_menus", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "occasion": { + "name": "occasion", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "min_guests": { + "name": "min_guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_guests": { + "name": "max_guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "available_from": { + "name": "available_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "available_to": { + "name": "available_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "recipe_ids": { + "name": "recipe_ids", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::uuid[]" + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "set_menus_est_idx": { + "name": "set_menus_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "set_menus_organization_id_organizations_id_fk": { + "name": "set_menus_organization_id_organizations_id_fk", + "tableFrom": "set_menus", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "set_menus_establishment_id_establishments_id_fk": { + "name": "set_menus_establishment_id_establishments_id_fk", + "tableFrom": "set_menus", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "set_menus_created_by_users_id_fk": { + "name": "set_menus_created_by_users_id_fk", + "tableFrom": "set_menus", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "set_menus_category_ck": { + "name": "set_menus_category_ck", + "value": "\"set_menus\".\"category\" IN ('carte', 'groupe', 'evenement')" + }, + "set_menus_guests_ck": { + "name": "set_menus_guests_ck", + "value": "(\"set_menus\".\"min_guests\" IS NULL OR \"set_menus\".\"min_guests\" > 0) AND (\"set_menus\".\"max_guests\" IS NULL OR \"set_menus\".\"max_guests\" > 0) AND (\"set_menus\".\"min_guests\" IS NULL OR \"set_menus\".\"max_guests\" IS NULL OR \"set_menus\".\"min_guests\" <= \"set_menus\".\"max_guests\")" + }, + "set_menus_dates_ck": { + "name": "set_menus_dates_ck", + "value": "\"set_menus\".\"available_from\" IS NULL OR \"set_menus\".\"available_to\" IS NULL OR \"set_menus\".\"available_from\" <= \"set_menus\".\"available_to\"" + } + }, + "isRLSEnabled": false + }, + "public.shift_swaps": { + "name": "shift_swaps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "shift_id": { + "name": "shift_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "from_employee_id": { + "name": "from_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_employee_id": { + "name": "to_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counter_shift_id": { + "name": "counter_shift_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "shift_snapshot": { + "name": "shift_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counter_snapshot": { + "name": "counter_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'attente_collegue'" + }, + "colleague_answered_at": { + "name": "colleague_answered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shift_swaps_est_status_idx": { + "name": "shift_swaps_est_status_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shift_swaps_from_idx": { + "name": "shift_swaps_from_idx", + "columns": [ + { + "expression": "from_employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shift_swaps_to_idx": { + "name": "shift_swaps_to_idx", + "columns": [ + { + "expression": "to_employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shift_swaps_organization_id_organizations_id_fk": { + "name": "shift_swaps_organization_id_organizations_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_establishment_id_establishments_id_fk": { + "name": "shift_swaps_establishment_id_establishments_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_shift_id_shifts_id_fk": { + "name": "shift_swaps_shift_id_shifts_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "shifts", + "columnsFrom": [ + "shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "shift_swaps_from_employee_id_employees_id_fk": { + "name": "shift_swaps_from_employee_id_employees_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "employees", + "columnsFrom": [ + "from_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_to_employee_id_employees_id_fk": { + "name": "shift_swaps_to_employee_id_employees_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "employees", + "columnsFrom": [ + "to_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_counter_shift_id_shifts_id_fk": { + "name": "shift_swaps_counter_shift_id_shifts_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "shifts", + "columnsFrom": [ + "counter_shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "shift_swaps_decided_by_users_id_fk": { + "name": "shift_swaps_decided_by_users_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shift_swaps_created_by_users_id_fk": { + "name": "shift_swaps_created_by_users_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shift_swaps_status_ck": { + "name": "shift_swaps_status_ck", + "value": "\"shift_swaps\".\"status\" IN ('attente_collegue', 'attente_responsable', 'acceptee', 'refusee', 'annulee', 'expiree')" + }, + "shift_swaps_people_ck": { + "name": "shift_swaps_people_ck", + "value": "\"shift_swaps\".\"from_employee_id\" <> \"shift_swaps\".\"to_employee_id\"" + } + }, + "isRLSEnabled": false + }, + "public.shift_templates": { + "name": "shift_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "break_minutes": { + "name": "break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shift_templates_est_idx": { + "name": "shift_templates_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shift_templates_organization_id_organizations_id_fk": { + "name": "shift_templates_organization_id_organizations_id_fk", + "tableFrom": "shift_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_templates_establishment_id_establishments_id_fk": { + "name": "shift_templates_establishment_id_establishments_id_fk", + "tableFrom": "shift_templates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_templates_created_by_users_id_fk": { + "name": "shift_templates_created_by_users_id_fk", + "tableFrom": "shift_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shift_templates_time_ck": { + "name": "shift_templates_time_ck", + "value": "\"shift_templates\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shift_templates\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shift_templates\".\"start_time\" <> \"shift_templates\".\"end_time\"" + }, + "shift_templates_break_ck": { + "name": "shift_templates_break_ck", + "value": "\"shift_templates\".\"break_minutes\" >= 0 AND \"shift_templates\".\"break_minutes\" <= 240" + } + }, + "isRLSEnabled": false + }, + "public.shifts": { + "name": "shifts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "break_minutes": { + "name": "break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_start": { + "name": "actual_start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_end": { + "name": "actual_end", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_break_minutes": { + "name": "actual_break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "meals": { + "name": "meals", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "no_show": { + "name": "no_show", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shifts_est_date_idx": { + "name": "shifts_est_date_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shifts_emp_date_idx": { + "name": "shifts_emp_date_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shifts_organization_id_organizations_id_fk": { + "name": "shifts_organization_id_organizations_id_fk", + "tableFrom": "shifts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_establishment_id_establishments_id_fk": { + "name": "shifts_establishment_id_establishments_id_fk", + "tableFrom": "shifts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_employee_id_employees_id_fk": { + "name": "shifts_employee_id_employees_id_fk", + "tableFrom": "shifts", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_validated_by_users_id_fk": { + "name": "shifts_validated_by_users_id_fk", + "tableFrom": "shifts", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shifts_created_by_users_id_fk": { + "name": "shifts_created_by_users_id_fk", + "tableFrom": "shifts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shifts_meals_ck": { + "name": "shifts_meals_ck", + "value": "\"shifts\".\"meals\" >= 0 AND \"shifts\".\"meals\" <= 3" + }, + "shifts_time_ck": { + "name": "shifts_time_ck", + "value": "\"shifts\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shifts\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shifts\".\"start_time\" <> \"shifts\".\"end_time\"" + }, + "shifts_break_ck": { + "name": "shifts_break_ck", + "value": "\"shifts\".\"break_minutes\" >= 0 AND \"shifts\".\"break_minutes\" <= 240" + } + }, + "isRLSEnabled": false + }, + "public.signature_requests": { + "name": "signature_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_id": { + "name": "contract_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_pdf": { + "name": "document_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "document_sha256": { + "name": "document_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "signer_email": { + "name": "signer_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employer_name": { + "name": "employer_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code_expires_at": { + "name": "code_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "code_sent_at": { + "name": "code_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "codes_sent": { + "name": "codes_sent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "code_attempts": { + "name": "code_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "signed_at": { + "name": "signed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "signed_name": { + "name": "signed_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signed_pdf": { + "name": "signed_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "signed_sha256": { + "name": "signed_sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refusal_note": { + "name": "refusal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "drawn_signature": { + "name": "drawn_signature", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "reminders_sent": { + "name": "reminders_sent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_reminder_at": { + "name": "last_reminder_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "signature_requests_token_uq": { + "name": "signature_requests_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "signature_requests_emp_idx": { + "name": "signature_requests_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "signature_requests_organization_id_organizations_id_fk": { + "name": "signature_requests_organization_id_organizations_id_fk", + "tableFrom": "signature_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_establishment_id_establishments_id_fk": { + "name": "signature_requests_establishment_id_establishments_id_fk", + "tableFrom": "signature_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_employee_id_employees_id_fk": { + "name": "signature_requests_employee_id_employees_id_fk", + "tableFrom": "signature_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_file_id_employee_files_id_fk": { + "name": "signature_requests_file_id_employee_files_id_fk", + "tableFrom": "signature_requests", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "signature_requests_created_by_users_id_fk": { + "name": "signature_requests_created_by_users_id_fk", + "tableFrom": "signature_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "signature_requests_status_ck": { + "name": "signature_requests_status_ck", + "value": "\"signature_requests\".\"status\" IN ('en_attente', 'signe', 'refuse', 'annule')" + } + }, + "isRLSEnabled": false + }, + "public.skills": { + "name": "skills", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "skills_name_uq": { + "name": "skills_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"skills\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "skills_organization_id_organizations_id_fk": { + "name": "skills_organization_id_organizations_id_fk", + "tableFrom": "skills", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.social_posts": { + "name": "social_posts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "visual_id": { + "name": "visual_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "networks": { + "name": "networks", + "type": "text[]", + "primaryKey": false, + "notNull": true + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_mime": { + "name": "image_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "image_format": { + "name": "image_format", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external": { + "name": "external", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stats": { + "name": "stats", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stats_at": { + "name": "stats_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "social_posts_cal_idx": { + "name": "social_posts_cal_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_due_idx": { + "name": "social_posts_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_source_uq": { + "name": "social_posts_source_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"social_posts\".\"source_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_token_uq": { + "name": "social_posts_token_uq", + "columns": [ + { + "expression": "public_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "social_posts_organization_id_organizations_id_fk": { + "name": "social_posts_organization_id_organizations_id_fk", + "tableFrom": "social_posts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_posts_establishment_id_establishments_id_fk": { + "name": "social_posts_establishment_id_establishments_id_fk", + "tableFrom": "social_posts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_posts_visual_id_studio_visuals_id_fk": { + "name": "social_posts_visual_id_studio_visuals_id_fk", + "tableFrom": "social_posts", + "tableTo": "studio_visuals", + "columnsFrom": [ + "visual_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "social_posts_approved_by_users_id_fk": { + "name": "social_posts_approved_by_users_id_fk", + "tableFrom": "social_posts", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "social_posts_created_by_users_id_fk": { + "name": "social_posts_created_by_users_id_fk", + "tableFrom": "social_posts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "social_posts_source_ck": { + "name": "social_posts_source_ck", + "value": "\"social_posts\".\"source\" IN ('manuel', 'menu_du_jour', 'evenement', 'fermeture', 'avis')" + }, + "social_posts_status_ck": { + "name": "social_posts_status_ck", + "value": "\"social_posts\".\"status\" IN ('a_valider', 'planifie', 'publie', 'partiel', 'echec', 'annule')" + }, + "social_posts_networks_ck": { + "name": "social_posts_networks_ck", + "value": "\"social_posts\".\"networks\" <@ ARRAY['instagram','facebook']::text[] AND cardinality(\"social_posts\".\"networks\") >= 1" + }, + "social_posts_image_ck": { + "name": "social_posts_image_ck", + "value": "(\"social_posts\".\"image\" IS NULL) = (\"social_posts\".\"image_mime\" IS NULL) AND (\"social_posts\".\"image_mime\" IS NULL OR \"social_posts\".\"image_mime\" = 'image/png')" + }, + "social_posts_format_ck": { + "name": "social_posts_format_ck", + "value": "\"social_posts\".\"image_format\" IS NULL OR \"social_posts\".\"image_format\" IN ('carre', 'portrait', 'facebook')" + }, + "social_posts_caption_ck": { + "name": "social_posts_caption_ck", + "value": "char_length(\"social_posts\".\"caption\") BETWEEN 1 AND 2200" + } + }, + "isRLSEnabled": false + }, + "public.social_settings": { + "name": "social_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "networks": { + "name": "networks", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY['instagram','facebook']::text[]" + }, + "require_approval": { + "name": "require_approval", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "auto_menu": { + "name": "auto_menu", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "menu_time": { + "name": "menu_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'11:00'" + }, + "auto_events": { + "name": "auto_events", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "event_time": { + "name": "event_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'18:00'" + }, + "closure_days_before": { + "name": "closure_days_before", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "auto_reviews": { + "name": "auto_reviews", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "review_min_rating": { + "name": "review_min_rating", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "review_time": { + "name": "review_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'17:30'" + }, + "hashtags": { + "name": "hashtags", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_posts_per_day": { + "name": "max_posts_per_day", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "repeat_days": { + "name": "repeat_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 14 + }, + "auto_best_times": { + "name": "auto_best_times", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "social_settings_org_idx": { + "name": "social_settings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "social_settings_establishment_id_establishments_id_fk": { + "name": "social_settings_establishment_id_establishments_id_fk", + "tableFrom": "social_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_settings_organization_id_organizations_id_fk": { + "name": "social_settings_organization_id_organizations_id_fk", + "tableFrom": "social_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_settings_updated_by_users_id_fk": { + "name": "social_settings_updated_by_users_id_fk", + "tableFrom": "social_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "social_settings_repeat_ck": { + "name": "social_settings_repeat_ck", + "value": "\"social_settings\".\"max_posts_per_day\" BETWEEN 1 AND 5 AND \"social_settings\".\"repeat_days\" BETWEEN 0 AND 90" + }, + "social_settings_networks_ck": { + "name": "social_settings_networks_ck", + "value": "\"social_settings\".\"networks\" <@ ARRAY['instagram','facebook']::text[] AND cardinality(\"social_settings\".\"networks\") >= 1" + }, + "social_settings_times_ck": { + "name": "social_settings_times_ck", + "value": "\"social_settings\".\"menu_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"social_settings\".\"event_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"social_settings\".\"review_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "social_settings_rating_ck": { + "name": "social_settings_rating_ck", + "value": "\"social_settings\".\"review_min_rating\" BETWEEN 4 AND 5" + }, + "social_settings_days_ck": { + "name": "social_settings_days_ck", + "value": "\"social_settings\".\"closure_days_before\" BETWEEN 0 AND 14" + } + }, + "isRLSEnabled": false + }, + "public.staff_meals": { + "name": "staff_meals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "meal_date": { + "name": "meal_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "beneficiary_name": { + "name": "beneficiary_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dish_label": { + "name": "dish_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'1'" + }, + "pricing": { + "name": "pricing", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "total_cost": { + "name": "total_cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_paid": { + "name": "amount_paid", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "meal_value": { + "name": "meal_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "staff_meals_est_idx": { + "name": "staff_meals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "meal_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "staff_meals_emp_idx": { + "name": "staff_meals_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "meal_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "staff_meals_organization_id_organizations_id_fk": { + "name": "staff_meals_organization_id_organizations_id_fk", + "tableFrom": "staff_meals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "staff_meals_establishment_id_establishments_id_fk": { + "name": "staff_meals_establishment_id_establishments_id_fk", + "tableFrom": "staff_meals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "staff_meals_employee_id_employees_id_fk": { + "name": "staff_meals_employee_id_employees_id_fk", + "tableFrom": "staff_meals", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "staff_meals_recipe_id_recipes_id_fk": { + "name": "staff_meals_recipe_id_recipes_id_fk", + "tableFrom": "staff_meals", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "staff_meals_created_by_users_id_fk": { + "name": "staff_meals_created_by_users_id_fk", + "tableFrom": "staff_meals", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_meals_cancelled_by_users_id_fk": { + "name": "staff_meals_cancelled_by_users_id_fk", + "tableFrom": "staff_meals", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "staff_meals_pricing_ck": { + "name": "staff_meals_pricing_ck", + "value": "\"staff_meals\".\"pricing\" IN ('offert', 'cout', 'prix_libre')" + }, + "staff_meals_beneficiary_ck": { + "name": "staff_meals_beneficiary_ck", + "value": "(\"staff_meals\".\"employee_id\" IS NULL) <> (\"staff_meals\".\"beneficiary_name\" IS NULL)" + }, + "staff_meals_amounts_ck": { + "name": "staff_meals_amounts_ck", + "value": "\"staff_meals\".\"portions\" > 0 AND \"staff_meals\".\"portions\" <= 20 AND \"staff_meals\".\"amount_paid\" >= 0 AND (\"staff_meals\".\"pricing\" <> 'offert' OR \"staff_meals\".\"amount_paid\" = 0)" + }, + "staff_meals_service_ck": { + "name": "staff_meals_service_ck", + "value": "\"staff_meals\".\"service\" IS NULL OR \"staff_meals\".\"service\" IN ('midi', 'soir')" + } + }, + "isRLSEnabled": false + }, + "public.stock_expiry_lots": { + "name": "stock_expiry_lots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_on": { + "name": "expires_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_line_id": { + "name": "order_line_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_reason": { + "name": "closed_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "loss_id": { + "name": "loss_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_expiry_lots_loss_idx": { + "name": "stock_expiry_lots_loss_idx", + "columns": [ + { + "expression": "loss_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"stock_expiry_lots\".\"loss_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_expiry_lots_open_idx": { + "name": "stock_expiry_lots_open_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"stock_expiry_lots\".\"closed_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_expiry_lots_item_idx": { + "name": "stock_expiry_lots_item_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_expiry_lots_organization_id_organizations_id_fk": { + "name": "stock_expiry_lots_organization_id_organizations_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_establishment_id_establishments_id_fk": { + "name": "stock_expiry_lots_establishment_id_establishments_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_item_id_purchase_items_id_fk": { + "name": "stock_expiry_lots_item_id_purchase_items_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_order_line_id_purchase_order_lines_id_fk": { + "name": "stock_expiry_lots_order_line_id_purchase_order_lines_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "purchase_order_lines", + "columnsFrom": [ + "order_line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "stock_expiry_lots_closed_by_users_id_fk": { + "name": "stock_expiry_lots_closed_by_users_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_expiry_lots_loss_id_stock_losses_id_fk": { + "name": "stock_expiry_lots_loss_id_stock_losses_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "stock_losses", + "columnsFrom": [ + "loss_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "stock_expiry_lots_created_by_users_id_fk": { + "name": "stock_expiry_lots_created_by_users_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_expiry_lots_kind_ck": { + "name": "stock_expiry_lots_kind_ck", + "value": "\"stock_expiry_lots\".\"kind\" IN ('dlc', 'ddm')" + }, + "stock_expiry_lots_qty_ck": { + "name": "stock_expiry_lots_qty_ck", + "value": "\"stock_expiry_lots\".\"quantity\" > 0" + }, + "stock_expiry_lots_close_ck": { + "name": "stock_expiry_lots_close_ck", + "value": "(\"stock_expiry_lots\".\"closed_at\" IS NULL) = (\"stock_expiry_lots\".\"closed_reason\" IS NULL) AND (\"stock_expiry_lots\".\"closed_reason\" IS NULL OR \"stock_expiry_lots\".\"closed_reason\" IN ('ecoule', 'perte', 'retour', 'erreur'))" + } + }, + "isRLSEnabled": false + }, + "public.stock_losses": { + "name": "stock_losses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "loss_date": { + "name": "loss_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credit_request_id": { + "name": "credit_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_losses_est_idx": { + "name": "stock_losses_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "loss_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_losses_organization_id_organizations_id_fk": { + "name": "stock_losses_organization_id_organizations_id_fk", + "tableFrom": "stock_losses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_losses_establishment_id_establishments_id_fk": { + "name": "stock_losses_establishment_id_establishments_id_fk", + "tableFrom": "stock_losses", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_losses_item_id_purchase_items_id_fk": { + "name": "stock_losses_item_id_purchase_items_id_fk", + "tableFrom": "stock_losses", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_losses_created_by_users_id_fk": { + "name": "stock_losses_created_by_users_id_fk", + "tableFrom": "stock_losses", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_losses_cancelled_by_users_id_fk": { + "name": "stock_losses_cancelled_by_users_id_fk", + "tableFrom": "stock_losses", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_losses_credit_request_id_credit_requests_id_fk": { + "name": "stock_losses_credit_request_id_credit_requests_id_fk", + "tableFrom": "stock_losses", + "tableTo": "credit_requests", + "columnsFrom": [ + "credit_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_losses_qty_ck": { + "name": "stock_losses_qty_ck", + "value": "\"stock_losses\".\"quantity\" > 0" + }, + "stock_losses_reason_ck": { + "name": "stock_losses_reason_ck", + "value": "\"stock_losses\".\"reason\" IN ('peremption', 'casse', 'erreur_production', 'retour_client', 'repas_personnel', 'offert', 'vol', 'retour_fournisseur', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.stock_rotation_settings": { + "name": "stock_rotation_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "overstock_days": { + "name": "overstock_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "lookback_days": { + "name": "lookback_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 28 + }, + "level_basis": { + "name": "level_basis", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'compte'" + }, + "expiry_alert_days": { + "name": "expiry_alert_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_rotation_settings_est_uq": { + "name": "stock_rotation_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_rotation_settings_organization_id_organizations_id_fk": { + "name": "stock_rotation_settings_organization_id_organizations_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_rotation_settings_establishment_id_establishments_id_fk": { + "name": "stock_rotation_settings_establishment_id_establishments_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_rotation_settings_updated_by_users_id_fk": { + "name": "stock_rotation_settings_updated_by_users_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_rotation_overstock_ck": { + "name": "stock_rotation_overstock_ck", + "value": "\"stock_rotation_settings\".\"overstock_days\" IS NULL OR \"stock_rotation_settings\".\"overstock_days\" BETWEEN 1 AND 365" + }, + "stock_rotation_lookback_ck": { + "name": "stock_rotation_lookback_ck", + "value": "\"stock_rotation_settings\".\"lookback_days\" BETWEEN 7 AND 365" + }, + "stock_rotation_basis_ck": { + "name": "stock_rotation_basis_ck", + "value": "\"stock_rotation_settings\".\"level_basis\" IN ('compte', 'theorique')" + }, + "stock_rotation_expiry_ck": { + "name": "stock_rotation_expiry_ck", + "value": "\"stock_rotation_settings\".\"expiry_alert_days\" BETWEEN 0 AND 30" + } + }, + "isRLSEnabled": false + }, + "public.stock_transfer_lines": { + "name": "stock_transfer_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "transfer_id": { + "name": "transfer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_transfer_lines_item_uq": { + "name": "stock_transfer_lines_item_uq", + "columns": [ + { + "expression": "transfer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfer_lines_item_idx": { + "name": "stock_transfer_lines_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_transfer_lines_organization_id_organizations_id_fk": { + "name": "stock_transfer_lines_organization_id_organizations_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfer_lines_transfer_id_stock_transfers_id_fk": { + "name": "stock_transfer_lines_transfer_id_stock_transfers_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "stock_transfers", + "columnsFrom": [ + "transfer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfer_lines_item_id_purchase_items_id_fk": { + "name": "stock_transfer_lines_item_id_purchase_items_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_transfer_lines_ck": { + "name": "stock_transfer_lines_ck", + "value": "\"stock_transfer_lines\".\"quantity\" > 0 AND \"stock_transfer_lines\".\"unit_cost\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.stock_transfers": { + "name": "stock_transfers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "from_establishment_id": { + "name": "from_establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_establishment_id": { + "name": "to_establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "transfer_date": { + "name": "transfer_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_value": { + "name": "total_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_transfers_number_uq": { + "name": "stock_transfers_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfers_from_idx": { + "name": "stock_transfers_from_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "transfer_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfers_to_idx": { + "name": "stock_transfers_to_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "transfer_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_transfers_organization_id_organizations_id_fk": { + "name": "stock_transfers_organization_id_organizations_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfers_from_establishment_id_establishments_id_fk": { + "name": "stock_transfers_from_establishment_id_establishments_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "establishments", + "columnsFrom": [ + "from_establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_transfers_to_establishment_id_establishments_id_fk": { + "name": "stock_transfers_to_establishment_id_establishments_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "establishments", + "columnsFrom": [ + "to_establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_transfers_created_by_users_id_fk": { + "name": "stock_transfers_created_by_users_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_transfers_cancelled_by_users_id_fk": { + "name": "stock_transfers_cancelled_by_users_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_transfers_distinct_ck": { + "name": "stock_transfers_distinct_ck", + "value": "\"stock_transfers\".\"from_establishment_id\" <> \"stock_transfers\".\"to_establishment_id\"" + } + }, + "isRLSEnabled": false + }, + "public.studio_brands": { + "name": "studio_brands", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "handle": { + "name": "handle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "background": { + "name": "background", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#1f2a24'" + }, + "primary": { + "name": "primary", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#d9a441'" + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#fbf7ee'" + }, + "font": { + "name": "font", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'classique'" + }, + "logo_mime": { + "name": "logo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo": { + "name": "logo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "studio_brands_org_idx": { + "name": "studio_brands_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "studio_brands_establishment_id_establishments_id_fk": { + "name": "studio_brands_establishment_id_establishments_id_fk", + "tableFrom": "studio_brands", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_brands_organization_id_organizations_id_fk": { + "name": "studio_brands_organization_id_organizations_id_fk", + "tableFrom": "studio_brands", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_brands_updated_by_users_id_fk": { + "name": "studio_brands_updated_by_users_id_fk", + "tableFrom": "studio_brands", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "studio_brands_colors_ck": { + "name": "studio_brands_colors_ck", + "value": "\"studio_brands\".\"background\" ~ '^#[0-9a-f]{6}$' AND \"studio_brands\".\"primary\" ~ '^#[0-9a-f]{6}$' AND \"studio_brands\".\"text\" ~ '^#[0-9a-f]{6}$'" + }, + "studio_brands_font_ck": { + "name": "studio_brands_font_ck", + "value": "\"studio_brands\".\"font\" IN ('classique', 'moderne', 'elegant')" + }, + "studio_brands_logo_ck": { + "name": "studio_brands_logo_ck", + "value": "(\"studio_brands\".\"logo\" IS NULL) = (\"studio_brands\".\"logo_mime\" IS NULL) AND (\"studio_brands\".\"logo_mime\" IS NULL OR \"studio_brands\".\"logo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + } + }, + "isRLSEnabled": false + }, + "public.studio_visuals": { + "name": "studio_visuals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "studio_visuals_est_idx": { + "name": "studio_visuals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "studio_visuals_organization_id_organizations_id_fk": { + "name": "studio_visuals_organization_id_organizations_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_visuals_establishment_id_establishments_id_fk": { + "name": "studio_visuals_establishment_id_establishments_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_visuals_created_by_users_id_fk": { + "name": "studio_visuals_created_by_users_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "studio_visuals_template_ck": { + "name": "studio_visuals_template_ck", + "value": "\"studio_visuals\".\"template\" IN ('menu_du_jour', 'plat', 'evenement', 'avis')" + }, + "studio_visuals_format_ck": { + "name": "studio_visuals_format_ck", + "value": "\"studio_visuals\".\"format\" IN ('carre', 'portrait', 'story', 'facebook')" + }, + "studio_visuals_photo_ck": { + "name": "studio_visuals_photo_ck", + "value": "(\"studio_visuals\".\"photo\" IS NULL) = (\"studio_visuals\".\"photo_mime\" IS NULL) AND (\"studio_visuals\".\"photo_mime\" IS NULL OR \"studio_visuals\".\"photo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + } + }, + "isRLSEnabled": false + }, + "public.supplier_offer_prices": { + "name": "supplier_offer_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "offer_id": { + "name": "offer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "price_ht": { + "name": "price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "content_quantity": { + "name": "content_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "content_unit": { + "name": "content_unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_offer_prices_offer_idx": { + "name": "supplier_offer_prices_offer_idx", + "columns": [ + { + "expression": "offer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_offer_prices_organization_id_organizations_id_fk": { + "name": "supplier_offer_prices_organization_id_organizations_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offer_prices_offer_id_supplier_offers_id_fk": { + "name": "supplier_offer_prices_offer_id_supplier_offers_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "supplier_offers", + "columnsFrom": [ + "offer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offer_prices_created_by_users_id_fk": { + "name": "supplier_offer_prices_created_by_users_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "supplier_offer_prices_source_ck": { + "name": "supplier_offer_prices_source_ck", + "value": "\"supplier_offer_prices\".\"source\" IN ('manual', 'import', 'migration', 'demande_prix')" + }, + "supplier_offer_prices_price_ck": { + "name": "supplier_offer_prices_price_ck", + "value": "\"supplier_offer_prices\".\"price_ht\" >= 0 AND \"supplier_offer_prices\".\"content_quantity\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.supplier_offers": { + "name": "supplier_offers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_ref": { + "name": "supplier_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_ht": { + "name": "price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "content_quantity": { + "name": "content_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "content_unit": { + "name": "content_unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price_date": { + "name": "price_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_offers_item_idx": { + "name": "supplier_offers_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "supplier_offers_supplier_idx": { + "name": "supplier_offers_supplier_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "supplier_offers_active_uq": { + "name": "supplier_offers_active_uq", + "columns": [ + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(coalesce(\"supplier_ref\", ''))", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"supplier_offers\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_offers_organization_id_organizations_id_fk": { + "name": "supplier_offers_organization_id_organizations_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offers_item_id_purchase_items_id_fk": { + "name": "supplier_offers_item_id_purchase_items_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offers_supplier_id_suppliers_id_fk": { + "name": "supplier_offers_supplier_id_suppliers_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "supplier_offers_created_by_users_id_fk": { + "name": "supplier_offers_created_by_users_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "supplier_offers_updated_by_users_id_fk": { + "name": "supplier_offers_updated_by_users_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "supplier_offers_price_ck": { + "name": "supplier_offers_price_ck", + "value": "\"supplier_offers\".\"price_ht\" >= 0 AND \"supplier_offers\".\"content_quantity\" > 0" + }, + "supplier_offers_unit_ck": { + "name": "supplier_offers_unit_ck", + "value": "\"supplier_offers\".\"content_unit\" IN ('kg', 'g', 'L', 'cl', 'pi\u00e8ce', 'botte', 'carton', 'colis', 'bouteille', 'f\u00fbt', 'lot', 'heure', 'forfait')" + }, + "supplier_offers_source_ck": { + "name": "supplier_offers_source_ck", + "value": "\"supplier_offers\".\"source\" IN ('manual', 'import', 'migration', 'demande_prix')" + } + }, + "isRLSEnabled": false + }, + "public.suppliers": { + "name": "suppliers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_number": { + "name": "vat_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_terms_days": { + "name": "payment_terms_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "default_category": { + "name": "default_category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'food'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "min_order_ht": { + "name": "min_order_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "order_cutoff": { + "name": "order_cutoff", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lead_time_days": { + "name": "lead_time_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_mode": { + "name": "delivery_fee_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "delivery_fee_fixed": { + "name": "delivery_fee_fixed", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_percent": { + "name": "delivery_fee_percent", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_tiers": { + "name": "delivery_fee_tiers", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "suppliers_org_idx": { + "name": "suppliers_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "suppliers_org_name_uq": { + "name": "suppliers_org_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "suppliers_organization_id_organizations_id_fk": { + "name": "suppliers_organization_id_organizations_id_fk", + "tableFrom": "suppliers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "suppliers_created_by_users_id_fk": { + "name": "suppliers_created_by_users_id_fk", + "tableFrom": "suppliers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "suppliers_fee_mode_ck": { + "name": "suppliers_fee_mode_ck", + "value": "\"suppliers\".\"delivery_fee_mode\" IN ('none', 'fixed', 'tiers', 'percent')" + }, + "suppliers_cutoff_ck": { + "name": "suppliers_cutoff_ck", + "value": "\"suppliers\".\"order_cutoff\" IS NULL OR \"suppliers\".\"order_cutoff\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "suppliers_siret_ck": { + "name": "suppliers_siret_ck", + "value": "\"suppliers\".\"siret\" IS NULL OR \"suppliers\".\"siret\" ~ '^[0-9]{14}$'" + }, + "suppliers_terms_ck": { + "name": "suppliers_terms_ck", + "value": "\"suppliers\".\"payment_terms_days\" IS NULL OR (\"suppliers\".\"payment_terms_days\" >= 0 AND \"suppliers\".\"payment_terms_days\" <= 365)" + } + }, + "isRLSEnabled": false + }, + "public.tablet_devices": { + "name": "tablet_devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo_on_punch": { + "name": "photo_on_punch", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pairing_code_hash": { + "name": "pairing_code_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pairing_expires_at": { + "name": "pairing_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paired_at": { + "name": "paired_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "operator_employee_id": { + "name": "operator_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "operator_token_hash": { + "name": "operator_token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "operator_until": { + "name": "operator_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tablet_devices_org_idx": { + "name": "tablet_devices_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tablet_devices_token_uq": { + "name": "tablet_devices_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tablet_devices_pairing_uq": { + "name": "tablet_devices_pairing_uq", + "columns": [ + { + "expression": "pairing_code_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tablet_devices_organization_id_organizations_id_fk": { + "name": "tablet_devices_organization_id_organizations_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tablet_devices_establishment_id_establishments_id_fk": { + "name": "tablet_devices_establishment_id_establishments_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tablet_devices_operator_employee_id_employees_id_fk": { + "name": "tablet_devices_operator_employee_id_employees_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "employees", + "columnsFrom": [ + "operator_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tablet_devices_created_by_users_id_fk": { + "name": "tablet_devices_created_by_users_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "tablet_devices_mode_ck": { + "name": "tablet_devices_mode_ck", + "value": "\"tablet_devices\".\"mode\" IN ('pointeuse', 'haccp')" + } + }, + "isRLSEnabled": false + }, + "public.task_completions": { + "name": "task_completions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "occurrence": { + "name": "occurrence", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "task_completions_est_idx": { + "name": "task_completions_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "task_completions_once_uq": { + "name": "task_completions_once_uq", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"task_completions\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_completions_organization_id_organizations_id_fk": { + "name": "task_completions_organization_id_organizations_id_fk", + "tableFrom": "task_completions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_completions_establishment_id_establishments_id_fk": { + "name": "task_completions_establishment_id_establishments_id_fk", + "tableFrom": "task_completions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_completions_task_id_task_definitions_id_fk": { + "name": "task_completions_task_id_task_definitions_id_fk", + "tableFrom": "task_completions", + "tableTo": "task_definitions", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_completions_done_by_users_id_fk": { + "name": "task_completions_done_by_users_id_fk", + "tableFrom": "task_completions", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "task_completions_cancelled_by_users_id_fk": { + "name": "task_completions_cancelled_by_users_id_fk", + "tableFrom": "task_completions", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_definitions": { + "name": "task_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "instructions": { + "name": "instructions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "month_day": { + "name": "month_day", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "once_date": { + "name": "once_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "due_time": { + "name": "due_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_required": { + "name": "photo_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "starts_on": { + "name": "starts_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "task_definitions_est_idx": { + "name": "task_definitions_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_definitions_organization_id_organizations_id_fk": { + "name": "task_definitions_organization_id_organizations_id_fk", + "tableFrom": "task_definitions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_definitions_establishment_id_establishments_id_fk": { + "name": "task_definitions_establishment_id_establishments_id_fk", + "tableFrom": "task_definitions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_definitions_assignee_user_id_users_id_fk": { + "name": "task_definitions_assignee_user_id_users_id_fk", + "tableFrom": "task_definitions", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "task_definitions_created_by_users_id_fk": { + "name": "task_definitions_created_by_users_id_fk", + "tableFrom": "task_definitions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "task_definitions_freq_ck": { + "name": "task_definitions_freq_ck", + "value": "\"task_definitions\".\"frequency\" IN ('once', 'daily', 'weekly', 'monthly')" + }, + "task_definitions_due_ck": { + "name": "task_definitions_due_ck", + "value": "\"task_definitions\".\"due_time\" IS NULL OR \"task_definitions\".\"due_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "task_definitions_month_ck": { + "name": "task_definitions_month_ck", + "value": "\"task_definitions\".\"month_day\" IS NULL OR \"task_definitions\".\"month_day\" BETWEEN 1 AND 31" + } + }, + "isRLSEnabled": false + }, + "public.temperature_readings": { + "name": "temperature_readings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": true + }, + "temp_min": { + "name": "temp_min", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sensor_id": { + "name": "sensor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "temperature_readings_est_idx": { + "name": "temperature_readings_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_readings_eq_idx": { + "name": "temperature_readings_eq_idx", + "columns": [ + { + "expression": "equipment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_readings_sensor_idx": { + "name": "temperature_readings_sensor_idx", + "columns": [ + { + "expression": "sensor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "temperature_readings_organization_id_organizations_id_fk": { + "name": "temperature_readings_organization_id_organizations_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "temperature_readings_establishment_id_establishments_id_fk": { + "name": "temperature_readings_establishment_id_establishments_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_equipment_id_equipment_id_fk": { + "name": "temperature_readings_equipment_id_equipment_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_recorded_by_users_id_fk": { + "name": "temperature_readings_recorded_by_users_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "temperature_readings_sensor_id_temperature_sensors_id_fk": { + "name": "temperature_readings_sensor_id_temperature_sensors_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "temperature_sensors", + "columnsFrom": [ + "sensor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_cancelled_by_users_id_fk": { + "name": "temperature_readings_cancelled_by_users_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "temperature_readings_action_ck": { + "name": "temperature_readings_action_ck", + "value": "\"temperature_readings\".\"conform\" OR \"temperature_readings\".\"corrective_action\" IS NOT NULL OR \"temperature_readings\".\"sensor_id\" IS NOT NULL" + }, + "temperature_readings_author_ck": { + "name": "temperature_readings_author_ck", + "value": "\"temperature_readings\".\"recorded_by\" IS NOT NULL OR \"temperature_readings\".\"sensor_id\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.temperature_sensors": { + "name": "temperature_sensors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hint": { + "name": "token_hint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keep_every_minutes": { + "name": "keep_every_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 15 + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_temperature": { + "name": "last_temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "temperature_sensors_token_uq": { + "name": "temperature_sensors_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_sensors_est_idx": { + "name": "temperature_sensors_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "temperature_sensors_organization_id_organizations_id_fk": { + "name": "temperature_sensors_organization_id_organizations_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "temperature_sensors_establishment_id_establishments_id_fk": { + "name": "temperature_sensors_establishment_id_establishments_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_sensors_equipment_id_equipment_id_fk": { + "name": "temperature_sensors_equipment_id_equipment_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_sensors_created_by_users_id_fk": { + "name": "temperature_sensors_created_by_users_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "temperature_sensors_keep_ck": { + "name": "temperature_sensors_keep_ck", + "value": "\"temperature_sensors\".\"keep_every_minutes\" BETWEEN 1 AND 240" + } + }, + "isRLSEnabled": false + }, + "public.trace_labels": { + "name": "trace_labels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "taken_at": { + "name": "taken_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_size": { + "name": "photo_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "usage": { + "name": "usage", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "production_name": { + "name": "production_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "trace_labels_est_idx": { + "name": "trace_labels_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "taken_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "trace_labels_organization_id_organizations_id_fk": { + "name": "trace_labels_organization_id_organizations_id_fk", + "tableFrom": "trace_labels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "trace_labels_establishment_id_establishments_id_fk": { + "name": "trace_labels_establishment_id_establishments_id_fk", + "tableFrom": "trace_labels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "trace_labels_item_id_purchase_items_id_fk": { + "name": "trace_labels_item_id_purchase_items_id_fk", + "tableFrom": "trace_labels", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "trace_labels_recorded_by_users_id_fk": { + "name": "trace_labels_recorded_by_users_id_fk", + "tableFrom": "trace_labels", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "trace_labels_cancelled_by_users_id_fk": { + "name": "trace_labels_cancelled_by_users_id_fk", + "tableFrom": "trace_labels", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "trace_labels_usage_ck": { + "name": "trace_labels_usage_ck", + "value": "\"trace_labels\".\"usage\" IN ('reception', 'ouverture', 'production')" + }, + "trace_labels_size_ck": { + "name": "trace_labels_size_ck", + "value": "\"trace_labels\".\"photo_size\" IS NULL OR \"trace_labels\".\"photo_size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.treasury_settings": { + "name": "treasury_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "vat_regime": { + "name": "vat_regime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_due_day": { + "name": "vat_due_day", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "alert_threshold": { + "name": "alert_threshold", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "treasury_settings_est_uq": { + "name": "treasury_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "treasury_settings_organization_id_organizations_id_fk": { + "name": "treasury_settings_organization_id_organizations_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "treasury_settings_establishment_id_establishments_id_fk": { + "name": "treasury_settings_establishment_id_establishments_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "treasury_settings_updated_by_users_id_fk": { + "name": "treasury_settings_updated_by_users_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "treasury_settings_vat_ck": { + "name": "treasury_settings_vat_ck", + "value": "(\"treasury_settings\".\"vat_regime\" IS NULL OR \"treasury_settings\".\"vat_regime\" IN ('monthly', 'quarterly')) AND (\"treasury_settings\".\"vat_due_day\" IS NULL OR \"treasury_settings\".\"vat_due_day\" BETWEEN 1 AND 31)" + } + }, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "totp_secret_enc": { + "name": "totp_secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "totp_enabled_at": { + "name": "totp_enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "totp_last_step": { + "name": "totp_last_step", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "password_changed_at": { + "name": "password_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "failed_login_count": { + "name": "failed_login_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "disabled_at": { + "name": "disabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "message_emails": { + "name": "message_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notification_phone": { + "name": "notification_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seen_release": { + "name": "seen_release", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_login_at": { + "name": "last_login_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "platform_admin": { + "name": "platform_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "email_verification_pending": { + "name": "email_verification_pending", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by_organization_id": { + "name": "created_by_organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_lower_uq": { + "name": "users_email_lower_uq", + "columns": [ + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_created_by_organization_id_organizations_id_fk": { + "name": "users_created_by_organization_id_organizations_id_fk", + "tableFrom": "users", + "tableTo": "organizations", + "columnsFrom": [ + "created_by_organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.waiter_closings": { + "name": "waiter_closings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "waiter_label": { + "name": "waiter_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "waiter_key": { + "name": "waiter_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "groupe": { + "name": "groupe", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "cb": { + "name": "cb", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "especes": { + "name": "especes", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "autre": { + "name": "autre", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recorded_at": { + "name": "recorded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "waiter_closings_est_idx": { + "name": "waiter_closings_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "waiter_closings_organization_id_organizations_id_fk": { + "name": "waiter_closings_organization_id_organizations_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "waiter_closings_establishment_id_establishments_id_fk": { + "name": "waiter_closings_establishment_id_establishments_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "waiter_closings_recorded_by_users_id_fk": { + "name": "waiter_closings_recorded_by_users_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "waiter_closings_cancelled_by_users_id_fk": { + "name": "waiter_closings_cancelled_by_users_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "waiter_closings_amounts_ck": { + "name": "waiter_closings_amounts_ck", + "value": "\"waiter_closings\".\"groupe\" >= 0 AND \"waiter_closings\".\"cb\" >= 0 AND \"waiter_closings\".\"especes\" >= 0 AND \"waiter_closings\".\"autre\" >= 0" + }, + "waiter_closings_key_ck": { + "name": "waiter_closings_key_ck", + "value": "length(\"waiter_closings\".\"waiter_key\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + } + }, + "enums": { + "public.connection_status": { + "name": "connection_status", + "schema": "public", + "values": [ + "not_configured", + "pending_verification", + "connected", + "error", + "disabled" + ] + }, + "public.data_status": { + "name": "data_status", + "schema": "public", + "values": [ + "real_validated", + "real_unvalidated", + "provisional", + "estimated", + "forecast", + "missing" + ] + }, + "public.import_status": { + "name": "import_status", + "schema": "public", + "values": [ + "completed", + "rejected", + "reverted" + ] + }, + "public.member_role": { + "name": "member_role", + "schema": "public", + "values": [ + "owner", + "admin", + "director", + "manager", + "accountant", + "chef", + "staff", + "cuisine", + "viewer", + "rh", + "controller", + "purchasing" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/0126_snapshot.json b/drizzle/meta/0126_snapshot.json new file mode 100644 index 00000000..e91c345e --- /dev/null +++ b/drizzle/meta/0126_snapshot.json @@ -0,0 +1,40876 @@ +{ + "id": "b45a7d33-fc36-4907-b9f2-308b5cc43c17", + "prevId": "0416a0c1-b430-4ac9-8475-d9e6bc09da02", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.absence_requests": { + "name": "absence_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "part": { + "name": "part", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'journee'" + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "absence_requests_emp_idx": { + "name": "absence_requests_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "absence_requests_organization_id_organizations_id_fk": { + "name": "absence_requests_organization_id_organizations_id_fk", + "tableFrom": "absence_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "absence_requests_employee_id_employees_id_fk": { + "name": "absence_requests_employee_id_employees_id_fk", + "tableFrom": "absence_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "absence_requests_decided_by_users_id_fk": { + "name": "absence_requests_decided_by_users_id_fk", + "tableFrom": "absence_requests", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "absence_requests_created_by_users_id_fk": { + "name": "absence_requests_created_by_users_id_fk", + "tableFrom": "absence_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "absence_requests_status_ck": { + "name": "absence_requests_status_ck", + "value": "\"absence_requests\".\"status\" IN ('en_attente', 'acceptee', 'refusee', 'annulee')" + }, + "absence_requests_dates_ck": { + "name": "absence_requests_dates_ck", + "value": "\"absence_requests\".\"end_date\" >= \"absence_requests\".\"start_date\"" + } + }, + "isRLSEnabled": false + }, + "public.account_invites": { + "name": "account_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'invite'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "account_invites_token_uq": { + "name": "account_invites_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "account_invites_user_idx": { + "name": "account_invites_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_invites_organization_id_organizations_id_fk": { + "name": "account_invites_organization_id_organizations_id_fk", + "tableFrom": "account_invites", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_invites_user_id_users_id_fk": { + "name": "account_invites_user_id_users_id_fk", + "tableFrom": "account_invites", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_invites_created_by_users_id_fk": { + "name": "account_invites_created_by_users_id_fk", + "tableFrom": "account_invites", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "account_invites_purpose_ck": { + "name": "account_invites_purpose_ck", + "value": "\"account_invites\".\"purpose\" IN ('invite', 'reset', 'verify')" + } + }, + "isRLSEnabled": false + }, + "public.ai_actions": { + "name": "ai_actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "source_href": { + "name": "source_href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "discard_reason": { + "name": "discard_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_actions_org_idx": { + "name": "ai_actions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_actions_pending_uq": { + "name": "ai_actions_pending_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_actions\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_actions_organization_id_organizations_id_fk": { + "name": "ai_actions_organization_id_organizations_id_fk", + "tableFrom": "ai_actions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_actions_created_by_users_id_fk": { + "name": "ai_actions_created_by_users_id_fk", + "tableFrom": "ai_actions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "ai_actions_decided_by_users_id_fk": { + "name": "ai_actions_decided_by_users_id_fk", + "tableFrom": "ai_actions", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_actions_kind_ck": { + "name": "ai_actions_kind_ck", + "value": "\"ai_actions\".\"kind\" IN ('negotiation_email', 'price_change')" + }, + "ai_actions_status_ck": { + "name": "ai_actions_status_ck", + "value": "\"ai_actions\".\"status\" IN ('pending', 'sent', 'applied', 'done_manual', 'discarded')" + }, + "ai_actions_decided_ck": { + "name": "ai_actions_decided_ck", + "value": "\"ai_actions\".\"status\" = 'pending' OR \"ai_actions\".\"decided_at\" IS NOT NULL" + }, + "ai_actions_discarded_ck": { + "name": "ai_actions_discarded_ck", + "value": "\"ai_actions\".\"status\" <> 'discarded' OR \"ai_actions\".\"discard_reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.ai_conversations": { + "name": "ai_conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_conversations_user_idx": { + "name": "ai_conversations_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_conversations_organization_id_organizations_id_fk": { + "name": "ai_conversations_organization_id_organizations_id_fk", + "tableFrom": "ai_conversations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_conversations_user_id_users_id_fk": { + "name": "ai_conversations_user_id_users_id_fk", + "tableFrom": "ai_conversations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_messages": { + "name": "ai_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tools": { + "name": "tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_messages_conv_idx": { + "name": "ai_messages_conv_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_messages_org_idx": { + "name": "ai_messages_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_messages_organization_id_organizations_id_fk": { + "name": "ai_messages_organization_id_organizations_id_fk", + "tableFrom": "ai_messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_messages_conversation_id_ai_conversations_id_fk": { + "name": "ai_messages_conversation_id_ai_conversations_id_fk", + "tableFrom": "ai_messages", + "tableTo": "ai_conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_messages_role_ck": { + "name": "ai_messages_role_ck", + "value": "\"ai_messages\".\"role\" IN ('user', 'assistant')" + } + }, + "isRLSEnabled": false + }, + "public.ai_reco_dismissals": { + "name": "ai_reco_dismissals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reco_id": { + "name": "reco_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "until": { + "name": "until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "dismissed_by": { + "name": "dismissed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_reco_dismissals_uq": { + "name": "ai_reco_dismissals_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reco_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_reco_dismissals_organization_id_organizations_id_fk": { + "name": "ai_reco_dismissals_organization_id_organizations_id_fk", + "tableFrom": "ai_reco_dismissals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_reco_dismissals_dismissed_by_users_id_fk": { + "name": "ai_reco_dismissals_dismissed_by_users_id_fk", + "tableFrom": "ai_reco_dismissals", + "tableTo": "users", + "columnsFrom": [ + "dismissed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_reco_dismissals_reason_ck": { + "name": "ai_reco_dismissals_reason_ck", + "value": "length(trim(\"ai_reco_dismissals\".\"reason\")) >= 3" + } + }, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "before": { + "name": "before", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "after": { + "name": "after", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_org_idx": { + "name": "audit_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_log_organization_id_organizations_id_fk": { + "name": "audit_log_organization_id_organizations_id_fk", + "tableFrom": "audit_log", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "audit_log_user_id_users_id_fk": { + "name": "audit_log_user_id_users_id_fk", + "tableFrom": "audit_log", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_throttle": { + "name": "auth_throttle", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_throttle_ip_idx": { + "name": "auth_throttle_ip_idx", + "columns": [ + { + "expression": "ip", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "approver_id": { + "name": "approver_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "delivered": { + "name": "delivered", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_approvals_once_uq": { + "name": "automation_approvals_once_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_approvals_org_idx": { + "name": "automation_approvals_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_approvals_organization_id_organizations_id_fk": { + "name": "automation_approvals_organization_id_organizations_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_approvals_rule_id_automation_rules_id_fk": { + "name": "automation_approvals_rule_id_automation_rules_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_approvals_approver_id_users_id_fk": { + "name": "automation_approvals_approver_id_users_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "users", + "columnsFrom": [ + "approver_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "automation_approvals_decided_by_users_id_fk": { + "name": "automation_approvals_decided_by_users_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_approvals_status_ck": { + "name": "automation_approvals_status_ck", + "value": "\"automation_approvals\".\"status\" IN ('pending', 'approved', 'rejected')" + }, + "automation_approvals_reason_ck": { + "name": "automation_approvals_reason_ck", + "value": "\"automation_approvals\".\"status\" <> 'rejected' OR \"automation_approvals\".\"reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.automation_drafts": { + "name": "automation_drafts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rule_name": { + "name": "rule_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "source_href": { + "name": "source_href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prepared_for": { + "name": "prepared_for", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "discard_reason": { + "name": "discard_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_entity_type": { + "name": "result_entity_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_entity_id": { + "name": "result_entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_drafts_org_idx": { + "name": "automation_drafts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_drafts_est_idx": { + "name": "automation_drafts_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_drafts_organization_id_organizations_id_fk": { + "name": "automation_drafts_organization_id_organizations_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_drafts_establishment_id_establishments_id_fk": { + "name": "automation_drafts_establishment_id_establishments_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_drafts_rule_id_automation_rules_id_fk": { + "name": "automation_drafts_rule_id_automation_rules_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "automation_drafts_prepared_for_users_id_fk": { + "name": "automation_drafts_prepared_for_users_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "users", + "columnsFrom": [ + "prepared_for" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "automation_drafts_decided_by_users_id_fk": { + "name": "automation_drafts_decided_by_users_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_drafts_kind_ck": { + "name": "automation_drafts_kind_ck", + "value": "\"automation_drafts\".\"kind\" IN ('purchase_order', 'credit_request', 'maintenance_request')" + }, + "automation_drafts_status_ck": { + "name": "automation_drafts_status_ck", + "value": "\"automation_drafts\".\"status\" IN ('pending', 'validated', 'discarded', 'expired')" + }, + "automation_drafts_validated_ck": { + "name": "automation_drafts_validated_ck", + "value": "\"automation_drafts\".\"status\" <> 'validated' OR (\"automation_drafts\".\"decided_by\" IS NOT NULL AND \"automation_drafts\".\"result_entity_type\" IS NOT NULL)" + }, + "automation_drafts_discarded_ck": { + "name": "automation_drafts_discarded_ck", + "value": "\"automation_drafts\".\"status\" <> 'discarded' OR \"automation_drafts\".\"discard_reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.automation_occurrences": { + "name": "automation_occurrences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "occurrence_key": { + "name": "occurrence_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "draft_id": { + "name": "draft_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_occurrences_uq": { + "name": "automation_occurrences_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_occurrences_org_key_idx": { + "name": "automation_occurrences_org_key_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_occurrences_organization_id_organizations_id_fk": { + "name": "automation_occurrences_organization_id_organizations_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_occurrences_rule_id_automation_rules_id_fk": { + "name": "automation_occurrences_rule_id_automation_rules_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_occurrences_draft_id_automation_drafts_id_fk": { + "name": "automation_occurrences_draft_id_automation_drafts_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "automation_drafts", + "columnsFrom": [ + "draft_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_pending": { + "name": "automation_pending", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_pending_org_idx": { + "name": "automation_pending_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_pending_organization_id_organizations_id_fk": { + "name": "automation_pending_organization_id_organizations_id_fk", + "tableFrom": "automation_pending", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_pending_rule_id_automation_rules_id_fk": { + "name": "automation_pending_rule_id_automation_rules_id_fk", + "tableFrom": "automation_pending", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_pending_user_id_users_id_fk": { + "name": "automation_pending_user_id_users_id_fk", + "tableFrom": "automation_pending", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "automation_pending_rule_id_user_id_item_key_pk": { + "name": "automation_pending_rule_id_user_id_item_key_pk", + "columns": [ + "rule_id", + "user_id", + "item_key" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_rules": { + "name": "automation_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "min_severity": { + "name": "min_severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'warning'" + }, + "recipient_ids": { + "name": "recipient_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "by_email": { + "name": "by_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'notify'" + }, + "params": { + "name": "params", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conditions": { + "name": "conditions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "delay_minutes": { + "name": "delay_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "approver_id": { + "name": "approver_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_triggered_at": { + "name": "last_triggered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_rules_org_idx": { + "name": "automation_rules_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_rules_organization_id_organizations_id_fk": { + "name": "automation_rules_organization_id_organizations_id_fk", + "tableFrom": "automation_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_rules_establishment_id_establishments_id_fk": { + "name": "automation_rules_establishment_id_establishments_id_fk", + "tableFrom": "automation_rules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_rules_approver_id_users_id_fk": { + "name": "automation_rules_approver_id_users_id_fk", + "tableFrom": "automation_rules", + "tableTo": "users", + "columnsFrom": [ + "approver_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "automation_rules_created_by_users_id_fk": { + "name": "automation_rules_created_by_users_id_fk", + "tableFrom": "automation_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_rules_severity_ck": { + "name": "automation_rules_severity_ck", + "value": "\"automation_rules\".\"min_severity\" IN ('warning', 'danger')" + }, + "automation_rules_action_ck": { + "name": "automation_rules_action_ck", + "value": "\"automation_rules\".\"action\" IN ('notify', 'draft_purchase_order', 'draft_credit_request', 'draft_maintenance_request')" + }, + "automation_rules_delay_ck": { + "name": "automation_rules_delay_ck", + "value": "\"automation_rules\".\"delay_minutes\" >= 0 AND \"automation_rules\".\"delay_minutes\" <= 10080" + } + }, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emailed": { + "name": "emailed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_runs_once_uq": { + "name": "automation_runs_once_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_runs_org_idx": { + "name": "automation_runs_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_runs_organization_id_organizations_id_fk": { + "name": "automation_runs_organization_id_organizations_id_fk", + "tableFrom": "automation_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_runs_rule_id_automation_rules_id_fk": { + "name": "automation_runs_rule_id_automation_rules_id_fk", + "tableFrom": "automation_runs", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_runs_user_id_users_id_fk": { + "name": "automation_runs_user_id_users_id_fk", + "tableFrom": "automation_runs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_settings": { + "name": "automation_settings", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "paused": { + "name": "paused", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_by": { + "name": "paused_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "paused_at": { + "name": "paused_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "automation_settings_organization_id_organizations_id_fk": { + "name": "automation_settings_organization_id_organizations_id_fk", + "tableFrom": "automation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_settings_paused_by_users_id_fk": { + "name": "automation_settings_paused_by_users_id_fk", + "tableFrom": "automation_settings", + "tableTo": "users", + "columnsFrom": [ + "paused_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bank_accounts": { + "name": "bank_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bank_name": { + "name": "bank_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban_last4": { + "name": "iban_last4", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "opening_balance": { + "name": "opening_balance", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "opening_date": { + "name": "opening_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "alert_threshold": { + "name": "alert_threshold", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_accounts_org_idx": { + "name": "bank_accounts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_accounts_organization_id_organizations_id_fk": { + "name": "bank_accounts_organization_id_organizations_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_accounts_establishment_id_establishments_id_fk": { + "name": "bank_accounts_establishment_id_establishments_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_accounts_created_by_users_id_fk": { + "name": "bank_accounts_created_by_users_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_accounts_iban_ck": { + "name": "bank_accounts_iban_ck", + "value": "\"bank_accounts\".\"iban_last4\" IS NULL OR \"bank_accounts\".\"iban_last4\" ~ '^[0-9A-Z]{4}$'" + } + }, + "isRLSEnabled": false + }, + "public.bank_imports": { + "name": "bank_imports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_sha256": { + "name": "file_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rows_total": { + "name": "rows_total", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "rows_inserted": { + "name": "rows_inserted", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "period_from": { + "name": "period_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "period_to": { + "name": "period_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_imports_account_idx": { + "name": "bank_imports_account_idx", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_imports_organization_id_organizations_id_fk": { + "name": "bank_imports_organization_id_organizations_id_fk", + "tableFrom": "bank_imports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_imports_account_id_bank_accounts_id_fk": { + "name": "bank_imports_account_id_bank_accounts_id_fk", + "tableFrom": "bank_imports", + "tableTo": "bank_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_imports_created_by_users_id_fk": { + "name": "bank_imports_created_by_users_id_fk", + "tableFrom": "bank_imports", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bank_rules": { + "name": "bank_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'any'" + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_rules_uq": { + "name": "bank_rules_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"keyword\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "direction", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_rules_organization_id_organizations_id_fk": { + "name": "bank_rules_organization_id_organizations_id_fk", + "tableFrom": "bank_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_rules_created_by_users_id_fk": { + "name": "bank_rules_created_by_users_id_fk", + "tableFrom": "bank_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_rules_direction_ck": { + "name": "bank_rules_direction_ck", + "value": "\"bank_rules\".\"direction\" IN ('in', 'out', 'any')" + } + }, + "isRLSEnabled": false + }, + "public.bank_transactions": { + "name": "bank_transactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "import_id": { + "name": "import_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "booking_date": { + "name": "booking_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "value_date": { + "name": "value_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "balance_after": { + "name": "balance_after", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category_source": { + "name": "category_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_tx_row_uq": { + "name": "bank_tx_row_uq", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "bank_tx_invoice_uq": { + "name": "bank_tx_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"bank_transactions\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "bank_tx_period_idx": { + "name": "bank_tx_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "booking_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_transactions_organization_id_organizations_id_fk": { + "name": "bank_transactions_organization_id_organizations_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_transactions_establishment_id_establishments_id_fk": { + "name": "bank_transactions_establishment_id_establishments_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_account_id_bank_accounts_id_fk": { + "name": "bank_transactions_account_id_bank_accounts_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "bank_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_import_id_bank_imports_id_fk": { + "name": "bank_transactions_import_id_bank_imports_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "bank_imports", + "columnsFrom": [ + "import_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "bank_transactions_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_tx_amount_ck": { + "name": "bank_tx_amount_ck", + "value": "\"bank_transactions\".\"amount\" <> 0" + } + }, + "isRLSEnabled": false + }, + "public.booking_button_clicks": { + "name": "booking_button_clicks", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "placement": { + "name": "placement", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "clicks": { + "name": "clicks", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "booking_button_clicks_establishment_id_establishments_id_fk": { + "name": "booking_button_clicks_establishment_id_establishments_id_fk", + "tableFrom": "booking_button_clicks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_button_clicks_organization_id_organizations_id_fk": { + "name": "booking_button_clicks_organization_id_organizations_id_fk", + "tableFrom": "booking_button_clicks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "booking_button_clicks_establishment_id_day_placement_target_pk": { + "name": "booking_button_clicks_establishment_id_day_placement_target_pk", + "columns": [ + "establishment_id", + "day", + "placement", + "target" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "booking_button_clicks_placement_ck": { + "name": "booking_button_clicks_placement_ck", + "value": "\"booking_button_clicks\".\"placement\" IN ('instagram', 'google', 'site')" + }, + "booking_button_clicks_target_ck": { + "name": "booking_button_clicks_target_ck", + "value": "\"booking_button_clicks\".\"target\" IN ('altair', 'thefork', 'opentable', 'zenchef')" + } + }, + "isRLSEnabled": false + }, + "public.booking_channels": { + "name": "booking_channels", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "instagram_target": { + "name": "instagram_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "google_target": { + "name": "google_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "site_target": { + "name": "site_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "thefork_url": { + "name": "thefork_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "opentable_url": { + "name": "opentable_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "zenchef_url": { + "name": "zenchef_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "booking_channels_establishment_id_establishments_id_fk": { + "name": "booking_channels_establishment_id_establishments_id_fk", + "tableFrom": "booking_channels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_channels_organization_id_organizations_id_fk": { + "name": "booking_channels_organization_id_organizations_id_fk", + "tableFrom": "booking_channels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_channels_updated_by_users_id_fk": { + "name": "booking_channels_updated_by_users_id_fk", + "tableFrom": "booking_channels", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "booking_channels_targets_ck": { + "name": "booking_channels_targets_ck", + "value": "\"booking_channels\".\"instagram_target\" IN ('altair', 'thefork', 'opentable', 'zenchef') AND \"booking_channels\".\"google_target\" IN ('altair', 'thefork', 'opentable', 'zenchef') AND \"booking_channels\".\"site_target\" IN ('altair', 'thefork', 'opentable', 'zenchef')" + }, + "booking_channels_urls_ck": { + "name": "booking_channels_urls_ck", + "value": "(\"booking_channels\".\"thefork_url\" IS NULL OR \"booking_channels\".\"thefork_url\" LIKE 'https://%') AND (\"booking_channels\".\"opentable_url\" IS NULL OR \"booking_channels\".\"opentable_url\" LIKE 'https://%') AND (\"booking_channels\".\"zenchef_url\" IS NULL OR \"booking_channels\".\"zenchef_url\" LIKE 'https://%')" + } + }, + "isRLSEnabled": false + }, + "public.business_document_versions": { + "name": "business_document_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version_no": { + "name": "version_no", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "replaced_by": { + "name": "replaced_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "replaced_at": { + "name": "replaced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "business_document_versions_uq": { + "name": "business_document_versions_uq", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version_no", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_document_versions_sha_idx": { + "name": "business_document_versions_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "business_document_versions_organization_id_organizations_id_fk": { + "name": "business_document_versions_organization_id_organizations_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "business_document_versions_document_id_business_documents_id_fk": { + "name": "business_document_versions_document_id_business_documents_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "business_document_versions_replaced_by_users_id_fk": { + "name": "business_document_versions_replaced_by_users_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "users", + "columnsFrom": [ + "replaced_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "business_document_versions_size_ck": { + "name": "business_document_versions_size_ck", + "value": "\"business_document_versions\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.business_documents": { + "name": "business_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "party": { + "name": "party", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference": { + "name": "reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "issued_on": { + "name": "issued_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "expires_on": { + "name": "expires_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reminder_days": { + "name": "reminder_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "annual_cost": { + "name": "annual_cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_version": { + "name": "file_version", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notice_on": { + "name": "notice_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "sensitivity": { + "name": "sensitivity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'normal'" + }, + "duplicate_of_id": { + "name": "duplicate_of_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "replaced_by_id": { + "name": "replaced_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "checklist_code": { + "name": "checklist_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "business_documents_org_idx": { + "name": "business_documents_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_documents_checklist_uq": { + "name": "business_documents_checklist_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checklist_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"business_documents\".\"checklist_code\" IS NOT NULL AND \"business_documents\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_documents_sha_idx": { + "name": "business_documents_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "business_documents_organization_id_organizations_id_fk": { + "name": "business_documents_organization_id_organizations_id_fk", + "tableFrom": "business_documents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "business_documents_establishment_id_establishments_id_fk": { + "name": "business_documents_establishment_id_establishments_id_fk", + "tableFrom": "business_documents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "business_documents_duplicate_of_id_business_documents_id_fk": { + "name": "business_documents_duplicate_of_id_business_documents_id_fk", + "tableFrom": "business_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "duplicate_of_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "business_documents_replaced_by_id_business_documents_id_fk": { + "name": "business_documents_replaced_by_id_business_documents_id_fk", + "tableFrom": "business_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "replaced_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "business_documents_created_by_users_id_fk": { + "name": "business_documents_created_by_users_id_fk", + "tableFrom": "business_documents", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "business_documents_size_ck": { + "name": "business_documents_size_ck", + "value": "\"business_documents\".\"size\" IS NULL OR \"business_documents\".\"size\" <= 5242880" + }, + "business_documents_reminder_ck": { + "name": "business_documents_reminder_ck", + "value": "\"business_documents\".\"reminder_days\" BETWEEN 0 AND 365" + }, + "business_documents_sensitivity_ck": { + "name": "business_documents_sensitivity_ck", + "value": "\"business_documents\".\"sensitivity\" IN ('normal', 'confidentiel', 'restreint')" + }, + "business_documents_notice_ck": { + "name": "business_documents_notice_ck", + "value": "\"business_documents\".\"notice_on\" IS NULL OR \"business_documents\".\"expires_on\" IS NULL OR \"business_documents\".\"notice_on\" <= \"business_documents\".\"expires_on\"" + } + }, + "isRLSEnabled": false + }, + "public.campaign_recipients": { + "name": "campaign_recipients", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "campaign_id": { + "name": "campaign_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unsubscribe_token_hash": { + "name": "unsubscribe_token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unsubscribed_at": { + "name": "unsubscribed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "campaign_recipients_token_uq": { + "name": "campaign_recipients_token_uq", + "columns": [ + { + "expression": "unsubscribe_token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "campaign_recipients_campaign_customer_uq": { + "name": "campaign_recipients_campaign_customer_uq", + "columns": [ + { + "expression": "campaign_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "campaign_recipients_customer_idx": { + "name": "campaign_recipients_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "campaign_recipients_organization_id_organizations_id_fk": { + "name": "campaign_recipients_organization_id_organizations_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "campaign_recipients_campaign_id_marketing_campaigns_id_fk": { + "name": "campaign_recipients_campaign_id_marketing_campaigns_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "marketing_campaigns", + "columnsFrom": [ + "campaign_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "campaign_recipients_customer_id_customers_id_fk": { + "name": "campaign_recipients_customer_id_customers_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidates": { + "name": "candidates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "job_opening_id": { + "name": "job_opening_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'nouveau'" + }, + "stage_changed_at": { + "name": "stage_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "interview_at": { + "name": "interview_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "rating": { + "name": "rating", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refusal_reason": { + "name": "refusal_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_contact_at": { + "name": "last_contact_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidates_org_idx": { + "name": "candidates_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stage", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidates_opening_idx": { + "name": "candidates_opening_idx", + "columns": [ + { + "expression": "job_opening_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidates_organization_id_organizations_id_fk": { + "name": "candidates_organization_id_organizations_id_fk", + "tableFrom": "candidates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidates_establishment_id_establishments_id_fk": { + "name": "candidates_establishment_id_establishments_id_fk", + "tableFrom": "candidates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidates_job_opening_id_job_openings_id_fk": { + "name": "candidates_job_opening_id_job_openings_id_fk", + "tableFrom": "candidates", + "tableTo": "job_openings", + "columnsFrom": [ + "job_opening_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidates_employee_id_employees_id_fk": { + "name": "candidates_employee_id_employees_id_fk", + "tableFrom": "candidates", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidates_created_by_users_id_fk": { + "name": "candidates_created_by_users_id_fk", + "tableFrom": "candidates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "candidates_stage_ck": { + "name": "candidates_stage_ck", + "value": "\"candidates\".\"stage\" IN ('nouveau', 'preselection', 'entretien', 'essai', 'offre', 'embauche', 'refuse', 'desiste')" + }, + "candidates_rating_ck": { + "name": "candidates_rating_ck", + "value": "\"candidates\".\"rating\" IS NULL OR \"candidates\".\"rating\" BETWEEN 1 AND 5" + } + }, + "isRLSEnabled": false + }, + "public.cash_counts": { + "name": "cash_counts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "denominations": { + "name": "denominations", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "counted_total": { + "name": "counted_total", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "counted_by": { + "name": "counted_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counted_at": { + "name": "counted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_counts_est_idx": { + "name": "cash_counts_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_counts_organization_id_organizations_id_fk": { + "name": "cash_counts_organization_id_organizations_id_fk", + "tableFrom": "cash_counts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_counts_establishment_id_establishments_id_fk": { + "name": "cash_counts_establishment_id_establishments_id_fk", + "tableFrom": "cash_counts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_counts_counted_by_users_id_fk": { + "name": "cash_counts_counted_by_users_id_fk", + "tableFrom": "cash_counts", + "tableTo": "users", + "columnsFrom": [ + "counted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cash_counts_cancelled_by_users_id_fk": { + "name": "cash_counts_cancelled_by_users_id_fk", + "tableFrom": "cash_counts", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_counts_kind_ck": { + "name": "cash_counts_kind_ck", + "value": "\"cash_counts\".\"kind\" IN ('fermeture', 'ouverture')" + }, + "cash_counts_amounts_ck": { + "name": "cash_counts_amounts_ck", + "value": "\"cash_counts\".\"counted_total\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.cash_plan_items": { + "name": "cash_plan_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "recurrence": { + "name": "recurrence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'once'" + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_plan_org_idx": { + "name": "cash_plan_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_plan_items_organization_id_organizations_id_fk": { + "name": "cash_plan_items_organization_id_organizations_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_plan_items_establishment_id_establishments_id_fk": { + "name": "cash_plan_items_establishment_id_establishments_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_plan_items_created_by_users_id_fk": { + "name": "cash_plan_items_created_by_users_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_plan_recurrence_ck": { + "name": "cash_plan_recurrence_ck", + "value": "\"cash_plan_items\".\"recurrence\" IN ('once', 'weekly', 'monthly', 'quarterly')" + }, + "cash_plan_amount_ck": { + "name": "cash_plan_amount_ck", + "value": "\"cash_plan_items\".\"amount\" <> 0" + }, + "cash_plan_end_ck": { + "name": "cash_plan_end_ck", + "value": "\"cash_plan_items\".\"end_date\" IS NULL OR \"cash_plan_items\".\"end_date\" >= \"cash_plan_items\".\"start_date\"" + } + }, + "isRLSEnabled": false + }, + "public.cash_withdrawals": { + "name": "cash_withdrawals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recorded_at": { + "name": "recorded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_withdrawals_est_idx": { + "name": "cash_withdrawals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_withdrawals_organization_id_organizations_id_fk": { + "name": "cash_withdrawals_organization_id_organizations_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_withdrawals_establishment_id_establishments_id_fk": { + "name": "cash_withdrawals_establishment_id_establishments_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_withdrawals_recorded_by_users_id_fk": { + "name": "cash_withdrawals_recorded_by_users_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cash_withdrawals_cancelled_by_users_id_fk": { + "name": "cash_withdrawals_cancelled_by_users_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_withdrawals_kind_ck": { + "name": "cash_withdrawals_kind_ck", + "value": "\"cash_withdrawals\".\"kind\" IN ('fournisseur', 'banque', 'pourboires', 'avance', 'autre')" + }, + "cash_withdrawals_amount_ck": { + "name": "cash_withdrawals_amount_ck", + "value": "\"cash_withdrawals\".\"amount\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.catalog_price_changes": { + "name": "catalog_price_changes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "old_price_ht": { + "name": "old_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "new_price_ht": { + "name": "new_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "catalog_price_changes_org_idx": { + "name": "catalog_price_changes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "catalog_price_changes_organization_id_organizations_id_fk": { + "name": "catalog_price_changes_organization_id_organizations_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "catalog_price_changes_item_id_purchase_items_id_fk": { + "name": "catalog_price_changes_item_id_purchase_items_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "catalog_price_changes_supplier_id_suppliers_id_fk": { + "name": "catalog_price_changes_supplier_id_suppliers_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "catalog_price_changes_created_by_users_id_fk": { + "name": "catalog_price_changes_created_by_users_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "catalog_price_changes_source_ck": { + "name": "catalog_price_changes_source_ck", + "value": "\"catalog_price_changes\".\"source\" IN ('import', 'manual')" + }, + "catalog_price_changes_price_ck": { + "name": "catalog_price_changes_price_ck", + "value": "\"catalog_price_changes\".\"new_price_ht\" >= 0 AND (\"catalog_price_changes\".\"old_price_ht\" IS NULL OR \"catalog_price_changes\".\"old_price_ht\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.checklist_run_photos": { + "name": "checklist_run_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_index": { + "name": "item_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_run_photos_uq": { + "name": "checklist_run_photos_uq", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_run_photos_organization_id_organizations_id_fk": { + "name": "checklist_run_photos_organization_id_organizations_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_run_photos_establishment_id_establishments_id_fk": { + "name": "checklist_run_photos_establishment_id_establishments_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_run_photos_run_id_checklist_runs_id_fk": { + "name": "checklist_run_photos_run_id_checklist_runs_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "checklist_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checklist_runs": { + "name": "checklist_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "answers": { + "name": "answers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "yes_count": { + "name": "yes_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "no_count": { + "name": "no_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "na_count": { + "name": "na_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moment": { + "name": "moment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_count": { + "name": "photo_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_runs_est_idx": { + "name": "checklist_runs_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_runs_organization_id_organizations_id_fk": { + "name": "checklist_runs_organization_id_organizations_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_runs_establishment_id_establishments_id_fk": { + "name": "checklist_runs_establishment_id_establishments_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_runs_template_id_checklist_templates_id_fk": { + "name": "checklist_runs_template_id_checklist_templates_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "checklist_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_runs_recorded_by_users_id_fk": { + "name": "checklist_runs_recorded_by_users_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checklist_runs_cancelled_by_users_id_fk": { + "name": "checklist_runs_cancelled_by_users_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checklist_templates": { + "name": "checklist_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "items": { + "name": "items", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "due_by": { + "name": "due_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moment": { + "name": "moment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_items": { + "name": "photo_items", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_templates_est_idx": { + "name": "checklist_templates_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_templates_organization_id_organizations_id_fk": { + "name": "checklist_templates_organization_id_organizations_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_templates_establishment_id_establishments_id_fk": { + "name": "checklist_templates_establishment_id_establishments_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_templates_created_by_users_id_fk": { + "name": "checklist_templates_created_by_users_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "checklist_templates_moment_ck": { + "name": "checklist_templates_moment_ck", + "value": "\"checklist_templates\".\"moment\" IS NULL OR \"checklist_templates\".\"moment\" IN ('ouverture', 'service', 'fermeture')" + } + }, + "isRLSEnabled": false + }, + "public.cleaning_records": { + "name": "cleaning_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_records_est_idx": { + "name": "cleaning_records_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cleaning_records_task_idx": { + "name": "cleaning_records_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_records_organization_id_organizations_id_fk": { + "name": "cleaning_records_organization_id_organizations_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_records_establishment_id_establishments_id_fk": { + "name": "cleaning_records_establishment_id_establishments_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cleaning_records_task_id_cleaning_tasks_id_fk": { + "name": "cleaning_records_task_id_cleaning_tasks_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "cleaning_tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cleaning_records_recorded_by_users_id_fk": { + "name": "cleaning_records_recorded_by_users_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cleaning_records_cancelled_by_users_id_fk": { + "name": "cleaning_records_cancelled_by_users_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cleaning_tasks": { + "name": "cleaning_tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "due_by": { + "name": "due_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_tasks_zone_idx": { + "name": "cleaning_tasks_zone_idx", + "columns": [ + { + "expression": "zone_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_tasks_organization_id_organizations_id_fk": { + "name": "cleaning_tasks_organization_id_organizations_id_fk", + "tableFrom": "cleaning_tasks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_tasks_zone_id_cleaning_zones_id_fk": { + "name": "cleaning_tasks_zone_id_cleaning_zones_id_fk", + "tableFrom": "cleaning_tasks", + "tableTo": "cleaning_zones", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cleaning_tasks_freq_ck": { + "name": "cleaning_tasks_freq_ck", + "value": "\"cleaning_tasks\".\"frequency\" IN ('service', 'jour', 'semaine', 'mois')" + } + }, + "isRLSEnabled": false + }, + "public.cleaning_zones": { + "name": "cleaning_zones", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_zones_est_idx": { + "name": "cleaning_zones_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_zones_organization_id_organizations_id_fk": { + "name": "cleaning_zones_organization_id_organizations_id_fk", + "tableFrom": "cleaning_zones", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_zones_establishment_id_establishments_id_fk": { + "name": "cleaning_zones_establishment_id_establishments_id_fk", + "tableFrom": "cleaning_zones", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.clock_event_photos": { + "name": "clock_event_photos", + "schema": "", + "columns": { + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "clock_event_photos_org_idx": { + "name": "clock_event_photos_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "clock_event_photos_event_id_clock_events_id_fk": { + "name": "clock_event_photos_event_id_clock_events_id_fk", + "tableFrom": "clock_event_photos", + "tableTo": "clock_events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_event_photos_organization_id_organizations_id_fk": { + "name": "clock_event_photos_organization_id_organizations_id_fk", + "tableFrom": "clock_event_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "clock_event_photos_size_ck": { + "name": "clock_event_photos_size_ck", + "value": "octet_length(\"clock_event_photos\".\"data\") <= 307200" + } + }, + "isRLSEnabled": false + }, + "public.clock_events": { + "name": "clock_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ok'" + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geo_distance_m": { + "name": "geo_distance_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "geo_accuracy_m": { + "name": "geo_accuracy_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "clock_events_est_day_idx": { + "name": "clock_events_est_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "clock_events_emp_day_idx": { + "name": "clock_events_emp_day_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "clock_events_organization_id_organizations_id_fk": { + "name": "clock_events_organization_id_organizations_id_fk", + "tableFrom": "clock_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_establishment_id_establishments_id_fk": { + "name": "clock_events_establishment_id_establishments_id_fk", + "tableFrom": "clock_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_employee_id_employees_id_fk": { + "name": "clock_events_employee_id_employees_id_fk", + "tableFrom": "clock_events", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_created_by_users_id_fk": { + "name": "clock_events_created_by_users_id_fk", + "tableFrom": "clock_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "clock_events_reviewed_by_users_id_fk": { + "name": "clock_events_reviewed_by_users_id_fk", + "tableFrom": "clock_events", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "clock_events_kind_ck": { + "name": "clock_events_kind_ck", + "value": "\"clock_events\".\"kind\" IN ('in', 'break_start', 'break_end', 'out')" + }, + "clock_events_source_ck": { + "name": "clock_events_source_ck", + "value": "\"clock_events\".\"source\" IN ('borne', 'manuel', 'hors_ligne', 'qr', 'telephone')" + }, + "clock_events_status_ck": { + "name": "clock_events_status_ck", + "value": "\"clock_events\".\"status\" IN ('ok', 'a_valider', 'annule')" + } + }, + "isRLSEnabled": false + }, + "public.clock_pins": { + "name": "clock_pins", + "schema": "", + "columns": { + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pin_hash": { + "name": "pin_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "failed_attempts": { + "name": "failed_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "clock_pins_employee_id_employees_id_fk": { + "name": "clock_pins_employee_id_employees_id_fk", + "tableFrom": "clock_pins", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_pins_organization_id_organizations_id_fk": { + "name": "clock_pins_organization_id_organizations_id_fk", + "tableFrom": "clock_pins", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_pins_updated_by_users_id_fk": { + "name": "clock_pins_updated_by_users_id_fk", + "tableFrom": "clock_pins", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.clock_qr_settings": { + "name": "clock_qr_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone_enabled": { + "name": "phone_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "geo_lat": { + "name": "geo_lat", + "type": "numeric(9, 6)", + "primaryKey": false, + "notNull": false + }, + "geo_lng": { + "name": "geo_lng", + "type": "numeric(9, 6)", + "primaryKey": false, + "notNull": false + }, + "geo_radius_m": { + "name": "geo_radius_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "auto_apply": { + "name": "auto_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_apply_by": { + "name": "auto_apply_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "auto_applied_day": { + "name": "auto_applied_day", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "pin_by_employee": { + "name": "pin_by_employee", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "clock_qr_settings_establishment_id_establishments_id_fk": { + "name": "clock_qr_settings_establishment_id_establishments_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_qr_settings_organization_id_organizations_id_fk": { + "name": "clock_qr_settings_organization_id_organizations_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_qr_settings_auto_apply_by_users_id_fk": { + "name": "clock_qr_settings_auto_apply_by_users_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "users", + "columnsFrom": [ + "auto_apply_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "clock_qr_settings_updated_by_users_id_fk": { + "name": "clock_qr_settings_updated_by_users_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.companies": { + "name": "companies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "legal_name": { + "name": "legal_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "legal_form": { + "name": "legal_form", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siren": { + "name": "siren", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_number": { + "name": "vat_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_holding": { + "name": "is_holding", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hr_settings": { + "name": "hr_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "calendar_settings": { + "name": "calendar_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tax_settings": { + "name": "tax_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "companies_org_idx": { + "name": "companies_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "companies_organization_id_organizations_id_fk": { + "name": "companies_organization_id_organizations_id_fk", + "tableFrom": "companies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "companies_siren_ck": { + "name": "companies_siren_ck", + "value": "\"companies\".\"siren\" IS NULL OR \"companies\".\"siren\" ~ '^[0-9]{9}$'" + } + }, + "isRLSEnabled": false + }, + "public.company_holdings": { + "name": "company_holdings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "parent_company_id": { + "name": "parent_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "child_company_id": { + "name": "child_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "ownership_pct": { + "name": "ownership_pct", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": true + }, + "since": { + "name": "since", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "holdings_pair_uq": { + "name": "holdings_pair_uq", + "columns": [ + { + "expression": "parent_company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "child_company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "company_holdings_organization_id_organizations_id_fk": { + "name": "company_holdings_organization_id_organizations_id_fk", + "tableFrom": "company_holdings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "company_holdings_parent_company_id_companies_id_fk": { + "name": "company_holdings_parent_company_id_companies_id_fk", + "tableFrom": "company_holdings", + "tableTo": "companies", + "columnsFrom": [ + "parent_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "company_holdings_child_company_id_companies_id_fk": { + "name": "company_holdings_child_company_id_companies_id_fk", + "tableFrom": "company_holdings", + "tableTo": "companies", + "columnsFrom": [ + "child_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "holdings_pct_ck": { + "name": "holdings_pct_ck", + "value": "\"company_holdings\".\"ownership_pct\" > 0 AND \"company_holdings\".\"ownership_pct\" <= 100" + }, + "holdings_self_ck": { + "name": "holdings_self_ck", + "value": "\"company_holdings\".\"parent_company_id\" <> \"company_holdings\".\"child_company_id\"" + } + }, + "isRLSEnabled": false + }, + "public.compliance_items": { + "name": "compliance_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "obligation_id": { + "name": "obligation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "verified_by": { + "name": "verified_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "compliance_items_uq": { + "name": "compliance_items_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "obligation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "compliance_items_document_idx": { + "name": "compliance_items_document_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "compliance_items_organization_id_organizations_id_fk": { + "name": "compliance_items_organization_id_organizations_id_fk", + "tableFrom": "compliance_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "compliance_items_establishment_id_establishments_id_fk": { + "name": "compliance_items_establishment_id_establishments_id_fk", + "tableFrom": "compliance_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "compliance_items_obligation_id_regulatory_obligations_id_fk": { + "name": "compliance_items_obligation_id_regulatory_obligations_id_fk", + "tableFrom": "compliance_items", + "tableTo": "regulatory_obligations", + "columnsFrom": [ + "obligation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "compliance_items_document_id_business_documents_id_fk": { + "name": "compliance_items_document_id_business_documents_id_fk", + "tableFrom": "compliance_items", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "compliance_items_verified_by_users_id_fk": { + "name": "compliance_items_verified_by_users_id_fk", + "tableFrom": "compliance_items", + "tableTo": "users", + "columnsFrom": [ + "verified_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "compliance_items_status_ck": { + "name": "compliance_items_status_ck", + "value": "\"compliance_items\".\"status\" IN ('verifie', 'non_applicable_declare', 'en_cours')" + }, + "compliance_items_in_progress_ck": { + "name": "compliance_items_in_progress_ck", + "value": "\"compliance_items\".\"status\" <> 'en_cours' OR \"compliance_items\".\"note\" IS NOT NULL" + }, + "compliance_items_proof_ck": { + "name": "compliance_items_proof_ck", + "value": "(\"compliance_items\".\"status\" <> 'verifie' OR \"compliance_items\".\"document_id\" IS NOT NULL) AND (\"compliance_items\".\"status\" <> 'non_applicable_declare' OR \"compliance_items\".\"reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.context_observations": { + "name": "context_observations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "series": { + "name": "series", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "numeric(12, 3)", + "primaryKey": false, + "notNull": false + }, + "extra": { + "name": "extra", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "context_observations_uq": { + "name": "context_observations_uq", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "series", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "context_observations_source_ck": { + "name": "context_observations_source_ck", + "value": "\"context_observations\".\"source\" IN ('meteo_france', 'insee')" + } + }, + "isRLSEnabled": false + }, + "public.context_sources": { + "name": "context_sources", + "schema": "", + "columns": { + "source": { + "name": "source", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "last_attempt_at": { + "name": "last_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rows": { + "name": "rows", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_members": { + "name": "conversation_members", + "schema": "", + "columns": { + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_read_at": { + "name": "last_read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "notified_at": { + "name": "notified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversation_members_user_idx": { + "name": "conversation_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversation_members_conversation_id_conversations_id_fk": { + "name": "conversation_members_conversation_id_conversations_id_fk", + "tableFrom": "conversation_members", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversation_members_user_id_users_id_fk": { + "name": "conversation_members_user_id_users_id_fk", + "tableFrom": "conversation_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversation_members_conversation_id_user_id_pk": { + "name": "conversation_members_conversation_id_user_id_pk", + "columns": [ + "conversation_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_group": { + "name": "is_group", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversations_org_idx": { + "name": "conversations_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversations_organization_id_organizations_id_fk": { + "name": "conversations_organization_id_organizations_id_fk", + "tableFrom": "conversations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversations_created_by_users_id_fk": { + "name": "conversations_created_by_users_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credit_request_lines": { + "name": "credit_request_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_request_lines_req_idx": { + "name": "credit_request_lines_req_idx", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_request_lines_organization_id_organizations_id_fk": { + "name": "credit_request_lines_organization_id_organizations_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_lines_request_id_credit_requests_id_fk": { + "name": "credit_request_lines_request_id_credit_requests_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "credit_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_lines_item_id_purchase_items_id_fk": { + "name": "credit_request_lines_item_id_purchase_items_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_request_lines_amount_ck": { + "name": "credit_request_lines_amount_ck", + "value": "\"credit_request_lines\".\"quantity\" > 0 AND \"credit_request_lines\".\"unit_price_ht\" > 0 AND \"credit_request_lines\".\"amount_ht\" > 0" + }, + "credit_request_lines_reason_ck": { + "name": "credit_request_lines_reason_ck", + "value": "\"credit_request_lines\".\"reason\" IN ('manquant', 'abime', 'non_conforme', 'erreur_prix', 'erreur_quantite', 'dlc_courte', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.credit_request_photos": { + "name": "credit_request_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_request_photos_req_idx": { + "name": "credit_request_photos_req_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_request_photos_organization_id_organizations_id_fk": { + "name": "credit_request_photos_organization_id_organizations_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_photos_request_id_credit_requests_id_fk": { + "name": "credit_request_photos_request_id_credit_requests_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "credit_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_photos_created_by_users_id_fk": { + "name": "credit_request_photos_created_by_users_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_request_photos_size_ck": { + "name": "credit_request_photos_size_ck", + "value": "\"credit_request_photos\".\"size\" <= 5242880" + }, + "credit_request_photos_mime_ck": { + "name": "credit_request_photos_mime_ck", + "value": "\"credit_request_photos\".\"mime\" IN ('image/jpeg', 'image/png', 'image/webp')" + } + }, + "isRLSEnabled": false + }, + "public.credit_requests": { + "name": "credit_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "request_date": { + "name": "request_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "credited_ht": { + "name": "credited_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "close_reason": { + "name": "close_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_requests_est_idx": { + "name": "credit_requests_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_requests_number_uq": { + "name": "credit_requests_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_requests_organization_id_organizations_id_fk": { + "name": "credit_requests_organization_id_organizations_id_fk", + "tableFrom": "credit_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_requests_establishment_id_establishments_id_fk": { + "name": "credit_requests_establishment_id_establishments_id_fk", + "tableFrom": "credit_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_supplier_id_suppliers_id_fk": { + "name": "credit_requests_supplier_id_suppliers_id_fk", + "tableFrom": "credit_requests", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_purchase_order_id_purchase_orders_id_fk": { + "name": "credit_requests_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "credit_requests", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_invoice_id_purchase_invoices_id_fk": { + "name": "credit_requests_invoice_id_purchase_invoices_id_fk", + "tableFrom": "credit_requests", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_closed_by_users_id_fk": { + "name": "credit_requests_closed_by_users_id_fk", + "tableFrom": "credit_requests", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "credit_requests_created_by_users_id_fk": { + "name": "credit_requests_created_by_users_id_fk", + "tableFrom": "credit_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_requests_status_ck": { + "name": "credit_requests_status_ck", + "value": "\"credit_requests\".\"status\" IN ('open', 'sent', 'accepted', 'refused', 'cancelled')" + }, + "credit_requests_total_ck": { + "name": "credit_requests_total_ck", + "value": "\"credit_requests\".\"total_ht\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.customers": { + "name": "customers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergies": { + "name": "allergies", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preferences": { + "name": "preferences", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birthday": { + "name": "birthday", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "vip": { + "name": "vip", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "consent_email": { + "name": "consent_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "consent_sms": { + "name": "consent_sms", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "consent_at": { + "name": "consent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consent_source": { + "name": "consent_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "anonymized_at": { + "name": "anonymized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "customers_org_idx": { + "name": "customers_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "customers_phone_idx": { + "name": "customers_phone_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "phone", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "customers_email_idx": { + "name": "customers_email_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "customers_organization_id_organizations_id_fk": { + "name": "customers_organization_id_organizations_id_fk", + "tableFrom": "customers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.dashboard_layouts": { + "name": "dashboard_layouts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blocks": { + "name": "blocks", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "dashboard_layouts_user_id_users_id_fk": { + "name": "dashboard_layouts_user_id_users_id_fk", + "tableFrom": "dashboard_layouts", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dashboard_layouts_organization_id_organizations_id_fk": { + "name": "dashboard_layouts_organization_id_organizations_id_fk", + "tableFrom": "dashboard_layouts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "dashboard_layouts_user_id_organization_id_pk": { + "name": "dashboard_layouts_user_id_organization_id_pk", + "columns": [ + "user_id", + "organization_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.delivery_note_scans": { + "name": "delivery_note_scans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "delivery_note_scans_order_idx": { + "name": "delivery_note_scans_order_idx", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "delivery_note_scans_org_idx": { + "name": "delivery_note_scans_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "delivery_note_scans_organization_id_organizations_id_fk": { + "name": "delivery_note_scans_organization_id_organizations_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_establishment_id_establishments_id_fk": { + "name": "delivery_note_scans_establishment_id_establishments_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_order_id_purchase_orders_id_fk": { + "name": "delivery_note_scans_order_id_purchase_orders_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "purchase_orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_created_by_users_id_fk": { + "name": "delivery_note_scans_created_by_users_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "delivery_note_scans_status_ck": { + "name": "delivery_note_scans_status_ck", + "value": "\"delivery_note_scans\".\"status\" IN ('lu', 'echec')" + }, + "delivery_note_scans_size_ck": { + "name": "delivery_note_scans_size_ck", + "value": "\"delivery_note_scans\".\"size\" > 0 AND \"delivery_note_scans\".\"size\" <= 10485760" + } + }, + "isRLSEnabled": false + }, + "public.dish_quality_checks": { + "name": "dish_quality_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "checked_by": { + "name": "checked_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "weight_g": { + "name": "weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "target_weight_g": { + "name": "target_weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tolerance_pct": { + "name": "tolerance_pct", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "plating_ok": { + "name": "plating_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "temperature_ok": { + "name": "temperature_ok", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "dish_quality_checks_est_idx": { + "name": "dish_quality_checks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "dish_quality_checks_recipe_idx": { + "name": "dish_quality_checks_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "dish_quality_checks_organization_id_organizations_id_fk": { + "name": "dish_quality_checks_organization_id_organizations_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_establishment_id_establishments_id_fk": { + "name": "dish_quality_checks_establishment_id_establishments_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_recipe_id_recipes_id_fk": { + "name": "dish_quality_checks_recipe_id_recipes_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_checked_by_users_id_fk": { + "name": "dish_quality_checks_checked_by_users_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "users", + "columnsFrom": [ + "checked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "dish_quality_checks_weight_ck": { + "name": "dish_quality_checks_weight_ck", + "value": "(\"dish_quality_checks\".\"weight_g\" IS NULL OR \"dish_quality_checks\".\"weight_g\" BETWEEN 1 AND 20000) AND (\"dish_quality_checks\".\"target_weight_g\" IS NULL OR \"dish_quality_checks\".\"target_weight_g\" BETWEEN 1 AND 20000)" + } + }, + "isRLSEnabled": false + }, + "public.duerp_risks": { + "name": "duerp_risks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "unit_id": { + "name": "unit_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "hazard": { + "name": "hazard", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "situation": { + "name": "situation", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "existing_measures": { + "name": "existing_measures", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gravity": { + "name": "gravity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "probability": { + "name": "probability", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "planned_action": { + "name": "planned_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action_owner": { + "name": "action_owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action_due": { + "name": "action_due", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "action_status": { + "name": "action_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_template": { + "name": "from_template", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_risks_unit_idx": { + "name": "duerp_risks_unit_idx", + "columns": [ + { + "expression": "unit_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_risks_est_idx": { + "name": "duerp_risks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_risks_organization_id_organizations_id_fk": { + "name": "duerp_risks_organization_id_organizations_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_risks_establishment_id_establishments_id_fk": { + "name": "duerp_risks_establishment_id_establishments_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_risks_unit_id_duerp_units_id_fk": { + "name": "duerp_risks_unit_id_duerp_units_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "duerp_units", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "duerp_risks_scale_ck": { + "name": "duerp_risks_scale_ck", + "value": "(\"duerp_risks\".\"gravity\" IS NULL OR \"duerp_risks\".\"gravity\" BETWEEN 1 AND 4) AND (\"duerp_risks\".\"probability\" IS NULL OR \"duerp_risks\".\"probability\" BETWEEN 1 AND 4)" + }, + "duerp_risks_action_ck": { + "name": "duerp_risks_action_ck", + "value": "\"duerp_risks\".\"action_status\" IS NULL OR (\"duerp_risks\".\"action_status\" IN ('a_faire', 'en_cours', 'faite') AND \"duerp_risks\".\"planned_action\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.duerp_units": { + "name": "duerp_units", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headcount": { + "name": "headcount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_units_est_idx": { + "name": "duerp_units_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_units_name_uq": { + "name": "duerp_units_name_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"duerp_units\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_units_organization_id_organizations_id_fk": { + "name": "duerp_units_organization_id_organizations_id_fk", + "tableFrom": "duerp_units", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_units_establishment_id_establishments_id_fk": { + "name": "duerp_units_establishment_id_establishments_id_fk", + "tableFrom": "duerp_units", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "duerp_units_headcount_ck": { + "name": "duerp_units_headcount_ck", + "value": "\"duerp_units\".\"headcount\" IS NULL OR \"duerp_units\".\"headcount\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.duerp_versions": { + "name": "duerp_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version_no": { + "name": "version_no", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "snapshot": { + "name": "snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "published_by_name": { + "name": "published_by_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_versions_no_uq": { + "name": "duerp_versions_no_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version_no", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_versions_org_idx": { + "name": "duerp_versions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_versions_organization_id_organizations_id_fk": { + "name": "duerp_versions_organization_id_organizations_id_fk", + "tableFrom": "duerp_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_versions_establishment_id_establishments_id_fk": { + "name": "duerp_versions_establishment_id_establishments_id_fk", + "tableFrom": "duerp_versions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_attachments": { + "name": "email_attachments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'application/pdf'" + }, + "content": { + "name": "content", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_attachments_org_idx": { + "name": "email_attachments_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_attachments_organization_id_organizations_id_fk": { + "name": "email_attachments_organization_id_organizations_id_fk", + "tableFrom": "email_attachments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "email_attachments_mime_ck": { + "name": "email_attachments_mime_ck", + "value": "\"email_attachments\".\"mime\" = 'application/pdf'" + }, + "email_attachments_size_ck": { + "name": "email_attachments_size_ck", + "value": "\"email_attachments\".\"size\" >= 0 AND \"email_attachments\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.email_outbox": { + "name": "email_outbox", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "signature_request_id": { + "name": "signature_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "attachment_id": { + "name": "attachment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "list_unsubscribe": { + "name": "list_unsubscribe", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_outbox_pending_idx": { + "name": "email_outbox_pending_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_outbox_organization_id_organizations_id_fk": { + "name": "email_outbox_organization_id_organizations_id_fk", + "tableFrom": "email_outbox", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "email_outbox_attachment_id_email_attachments_id_fk": { + "name": "email_outbox_attachment_id_email_attachments_id_fk", + "tableFrom": "email_outbox", + "tableTo": "email_attachments", + "columnsFrom": [ + "attachment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "email_outbox_status_ck": { + "name": "email_outbox_status_ck", + "value": "\"email_outbox\".\"status\" IN ('en_attente', 'envoye', 'echec')" + } + }, + "isRLSEnabled": false + }, + "public.employee_contracts": { + "name": "employee_contracts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "amends_id": { + "name": "amends_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "trial_end_date": { + "name": "trial_end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "step": { + "name": "step", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'employe'" + }, + "weekly_hours": { + "name": "weekly_hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "hourly_rate_gross": { + "name": "hourly_rate_gross", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": false + }, + "monthly_gross": { + "name": "monthly_gross", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "cdd_reason": { + "name": "cdd_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "replaced_person": { + "name": "replaced_person", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "meal_benefit": { + "name": "meal_benefit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "end_reason": { + "name": "end_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hire_time": { + "name": "hire_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_status": { + "name": "dpae_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_declared_on": { + "name": "dpae_declared_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "dpae_reference": { + "name": "dpae_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_note": { + "name": "dpae_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_contracts_emp_idx": { + "name": "employee_contracts_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "start_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_contracts_organization_id_organizations_id_fk": { + "name": "employee_contracts_organization_id_organizations_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_contracts_employee_id_employees_id_fk": { + "name": "employee_contracts_employee_id_employees_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_contracts_amends_id_employee_contracts_id_fk": { + "name": "employee_contracts_amends_id_employee_contracts_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "employee_contracts", + "columnsFrom": [ + "amends_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "employee_contracts_created_by_users_id_fk": { + "name": "employee_contracts_created_by_users_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_contracts_dpae_ck": { + "name": "employee_contracts_dpae_ck", + "value": "(\"employee_contracts\".\"dpae_status\" IS NULL OR \"employee_contracts\".\"dpae_status\" IN ('enregistree', 'non_concernee_declaree')) AND (\"employee_contracts\".\"dpae_status\" IS DISTINCT FROM 'enregistree' OR \"employee_contracts\".\"dpae_declared_on\" IS NOT NULL) AND (\"employee_contracts\".\"dpae_status\" IS DISTINCT FROM 'non_concernee_declaree' OR \"employee_contracts\".\"dpae_note\" IS NOT NULL)" + }, + "employee_contracts_kind_ck": { + "name": "employee_contracts_kind_ck", + "value": "\"employee_contracts\".\"kind\" IN ('cdi', 'cdd', 'extra', 'saisonnier', 'apprentissage', 'professionnalisation', 'stage', 'dirigeant')" + }, + "employee_contracts_dates_ck": { + "name": "employee_contracts_dates_ck", + "value": "\"employee_contracts\".\"end_date\" IS NULL OR \"employee_contracts\".\"end_date\" >= \"employee_contracts\".\"start_date\"" + }, + "employee_contracts_category_ck": { + "name": "employee_contracts_category_ck", + "value": "\"employee_contracts\".\"category\" IN ('employe', 'agent_maitrise', 'cadre')" + }, + "employee_contracts_hours_ck": { + "name": "employee_contracts_hours_ck", + "value": "\"employee_contracts\".\"weekly_hours\" IS NULL OR (\"employee_contracts\".\"weekly_hours\" > 0 AND \"employee_contracts\".\"weekly_hours\" <= 48)" + }, + "employee_contracts_rate_ck": { + "name": "employee_contracts_rate_ck", + "value": "(\"employee_contracts\".\"hourly_rate_gross\" IS NULL OR \"employee_contracts\".\"hourly_rate_gross\" >= 0) AND (\"employee_contracts\".\"monthly_gross\" IS NULL OR \"employee_contracts\".\"monthly_gross\" >= 0)" + }, + "employee_contracts_hire_time_ck": { + "name": "employee_contracts_hire_time_ck", + "value": "\"employee_contracts\".\"hire_time\" IS NULL OR \"employee_contracts\".\"hire_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "employee_contracts_meal_ck": { + "name": "employee_contracts_meal_ck", + "value": "\"employee_contracts\".\"meal_benefit\" IS NULL OR \"employee_contracts\".\"meal_benefit\" IN ('nature', 'indemnite', 'aucun')" + } + }, + "isRLSEnabled": false + }, + "public.employee_files": { + "name": "employee_files", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duplicate_of_id": { + "name": "duplicate_of_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "visible_to_employee": { + "name": "visible_to_employee", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_files_emp_idx": { + "name": "employee_files_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "employee_files_sha_idx": { + "name": "employee_files_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_files_organization_id_organizations_id_fk": { + "name": "employee_files_organization_id_organizations_id_fk", + "tableFrom": "employee_files", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_files_employee_id_employees_id_fk": { + "name": "employee_files_employee_id_employees_id_fk", + "tableFrom": "employee_files", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_files_duplicate_of_id_employee_files_id_fk": { + "name": "employee_files_duplicate_of_id_employee_files_id_fk", + "tableFrom": "employee_files", + "tableTo": "employee_files", + "columnsFrom": [ + "duplicate_of_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_files_uploaded_by_users_id_fk": { + "name": "employee_files_uploaded_by_users_id_fk", + "tableFrom": "employee_files", + "tableTo": "users", + "columnsFrom": [ + "uploaded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_files_size_ck": { + "name": "employee_files_size_ck", + "value": "\"employee_files\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.employee_reviews": { + "name": "employee_reviews", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'prevu'" + }, + "scheduled_on": { + "name": "scheduled_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "done_on": { + "name": "done_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reviewer_id": { + "name": "reviewer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "objectives": { + "name": "objectives", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "training_wishes": { + "name": "training_wishes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_comment": { + "name": "employee_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_reviews_emp_idx": { + "name": "employee_reviews_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_reviews_organization_id_organizations_id_fk": { + "name": "employee_reviews_organization_id_organizations_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_reviews_employee_id_employees_id_fk": { + "name": "employee_reviews_employee_id_employees_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_reviews_reviewer_id_users_id_fk": { + "name": "employee_reviews_reviewer_id_users_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "users", + "columnsFrom": [ + "reviewer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_reviews_file_id_employee_files_id_fk": { + "name": "employee_reviews_file_id_employee_files_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_reviews_created_by_users_id_fk": { + "name": "employee_reviews_created_by_users_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_reviews_kind_ck": { + "name": "employee_reviews_kind_ck", + "value": "\"employee_reviews\".\"kind\" IN ('annuel', 'professionnel', 'etat_des_lieux', 'fin_essai')" + }, + "employee_reviews_status_ck": { + "name": "employee_reviews_status_ck", + "value": "\"employee_reviews\".\"status\" IN ('prevu', 'realise', 'annule')" + }, + "employee_reviews_done_ck": { + "name": "employee_reviews_done_ck", + "value": "\"employee_reviews\".\"status\" <> 'realise' OR \"employee_reviews\".\"done_on\" IS NOT NULL" + }, + "employee_reviews_planned_ck": { + "name": "employee_reviews_planned_ck", + "value": "\"employee_reviews\".\"status\" <> 'prevu' OR \"employee_reviews\".\"scheduled_on\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.employee_skills": { + "name": "employee_skills", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "skill_id": { + "name": "skill_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "assessed_on": { + "name": "assessed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "assessed_by": { + "name": "assessed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "employee_skills_organization_id_organizations_id_fk": { + "name": "employee_skills_organization_id_organizations_id_fk", + "tableFrom": "employee_skills", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_employee_id_employees_id_fk": { + "name": "employee_skills_employee_id_employees_id_fk", + "tableFrom": "employee_skills", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_skill_id_skills_id_fk": { + "name": "employee_skills_skill_id_skills_id_fk", + "tableFrom": "employee_skills", + "tableTo": "skills", + "columnsFrom": [ + "skill_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_assessed_by_users_id_fk": { + "name": "employee_skills_assessed_by_users_id_fk", + "tableFrom": "employee_skills", + "tableTo": "users", + "columnsFrom": [ + "assessed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "employee_skills_employee_id_skill_id_pk": { + "name": "employee_skills_employee_id_skill_id_pk", + "columns": [ + "employee_id", + "skill_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_skills_level_ck": { + "name": "employee_skills_level_ck", + "value": "\"employee_skills\".\"level\" BETWEEN 0 AND 4" + } + }, + "isRLSEnabled": false + }, + "public.employee_trainings": { + "name": "employee_trainings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'realisee'" + }, + "planned_on": { + "name": "planned_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "done_on": { + "name": "done_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "hours": { + "name": "hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "funded_by": { + "name": "funded_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_trainings_emp_idx": { + "name": "employee_trainings_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_trainings_organization_id_organizations_id_fk": { + "name": "employee_trainings_organization_id_organizations_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_trainings_employee_id_employees_id_fk": { + "name": "employee_trainings_employee_id_employees_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_trainings_file_id_employee_files_id_fk": { + "name": "employee_trainings_file_id_employee_files_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_trainings_created_by_users_id_fk": { + "name": "employee_trainings_created_by_users_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_trainings_status_ck": { + "name": "employee_trainings_status_ck", + "value": "\"employee_trainings\".\"status\" IN ('prevue', 'realisee', 'annulee')" + }, + "employee_trainings_done_ck": { + "name": "employee_trainings_done_ck", + "value": "\"employee_trainings\".\"status\" <> 'realisee' OR \"employee_trainings\".\"done_on\" IS NOT NULL" + }, + "employee_trainings_valid_ck": { + "name": "employee_trainings_valid_ck", + "value": "\"employee_trainings\".\"valid_until\" IS NULL OR \"employee_trainings\".\"done_on\" IS NULL OR \"employee_trainings\".\"valid_until\" >= \"employee_trainings\".\"done_on\"" + }, + "employee_trainings_amounts_ck": { + "name": "employee_trainings_amounts_ck", + "value": "(\"employee_trainings\".\"hours\" IS NULL OR \"employee_trainings\".\"hours\" > 0) AND (\"employee_trainings\".\"cost\" IS NULL OR \"employee_trainings\".\"cost\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.employees": { + "name": "employees", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "registry_number": { + "name": "registry_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "birth_name": { + "name": "birth_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "birth_date": { + "name": "birth_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "birth_place": { + "name": "birth_place", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "nationality": { + "name": "nationality", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birth_country": { + "name": "birth_country", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birth_department": { + "name": "birth_department", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family_situation": { + "name": "family_situation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_type": { + "name": "work_permit_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_number": { + "name": "work_permit_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_expiry": { + "name": "work_permit_expiry", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "social_security_enc": { + "name": "social_security_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban_enc": { + "name": "iban_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bic": { + "name": "bic", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "account_holder": { + "name": "account_holder", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emergency_contact": { + "name": "emergency_contact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emergency_phone": { + "name": "emergency_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disability": { + "name": "disability", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "medical_visit_date": { + "name": "medical_visit_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "medical_visit_next_due": { + "name": "medical_visit_next_due", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reinforced_medical": { + "name": "reinforced_medical", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "planning_hidden": { + "name": "planning_hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employees_org_idx": { + "name": "employees_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "employees_registry_uq": { + "name": "employees_registry_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "registry_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employees_organization_id_organizations_id_fk": { + "name": "employees_organization_id_organizations_id_fk", + "tableFrom": "employees", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employees_establishment_id_establishments_id_fk": { + "name": "employees_establishment_id_establishments_id_fk", + "tableFrom": "employees", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "employees_user_id_users_id_fk": { + "name": "employees_user_id_users_id_fk", + "tableFrom": "employees", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employees_gender_ck": { + "name": "employees_gender_ck", + "value": "\"employees\".\"gender\" IS NULL OR \"employees\".\"gender\" IN ('F', 'M', 'X')" + }, + "employees_birth_department_ck": { + "name": "employees_birth_department_ck", + "value": "\"employees\".\"birth_department\" IS NULL OR \"employees\".\"birth_department\" ~ '^([0-9]{2}|2[AB]|9[78][0-9])$'" + } + }, + "isRLSEnabled": false + }, + "public.employer_signatures": { + "name": "employer_signatures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "png": { + "name": "png", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "signer_name": { + "name": "signer_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employer_signatures_company_uq": { + "name": "employer_signatures_company_uq", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employer_signatures_organization_id_organizations_id_fk": { + "name": "employer_signatures_organization_id_organizations_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employer_signatures_company_id_companies_id_fk": { + "name": "employer_signatures_company_id_companies_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employer_signatures_updated_by_users_id_fk": { + "name": "employer_signatures_updated_by_users_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employer_signatures_size_ck": { + "name": "employer_signatures_size_ck", + "value": "octet_length(\"employer_signatures\".\"png\") <= 102400" + } + }, + "isRLSEnabled": false + }, + "public.equipment": { + "name": "equipment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "temp_tracked": { + "name": "temp_tracked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "temp_min": { + "name": "temp_min", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "readings_per_day": { + "name": "readings_per_day", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "serial_number": { + "name": "serial_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installed_on": { + "name": "installed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "warranty_until": { + "name": "warranty_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "service_partner": { + "name": "service_partner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_phone": { + "name": "service_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_every_months": { + "name": "service_every_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "purchase_price_ht": { + "name": "purchase_price_ht", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "equipment_est_idx": { + "name": "equipment_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "equipment_organization_id_organizations_id_fk": { + "name": "equipment_organization_id_organizations_id_fk", + "tableFrom": "equipment", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "equipment_establishment_id_establishments_id_fk": { + "name": "equipment_establishment_id_establishments_id_fk", + "tableFrom": "equipment", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "equipment_created_by_users_id_fk": { + "name": "equipment_created_by_users_id_fk", + "tableFrom": "equipment", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "equipment_range_ck": { + "name": "equipment_range_ck", + "value": "\"equipment\".\"temp_min\" IS NULL OR \"equipment\".\"temp_max\" IS NULL OR \"equipment\".\"temp_min\" <= \"equipment\".\"temp_max\"" + }, + "equipment_rpd_ck": { + "name": "equipment_rpd_ck", + "value": "\"equipment\".\"readings_per_day\" BETWEEN 1 AND 4" + }, + "equipment_price_ck": { + "name": "equipment_price_ck", + "value": "\"equipment\".\"purchase_price_ht\" IS NULL OR \"equipment\".\"purchase_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.establishment_fee_rules": { + "name": "establishment_fee_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rate_pct": { + "name": "rate_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "basis": { + "name": "basis", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ttc'" + }, + "match_channel": { + "name": "match_channel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "match_payment": { + "name": "match_payment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fixed_monthly_ht": { + "name": "fixed_monthly_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "valid_from": { + "name": "valid_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "valid_to": { + "name": "valid_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishment_fee_rules_est_idx": { + "name": "establishment_fee_rules_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishment_fee_rules_organization_id_organizations_id_fk": { + "name": "establishment_fee_rules_organization_id_organizations_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_fee_rules_establishment_id_establishments_id_fk": { + "name": "establishment_fee_rules_establishment_id_establishments_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_fee_rules_created_by_users_id_fk": { + "name": "establishment_fee_rules_created_by_users_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "establishment_fee_rules_kind_ck": { + "name": "establishment_fee_rules_kind_ck", + "value": "\"establishment_fee_rules\".\"kind\" IN ('plateforme', 'franchise')" + }, + "establishment_fee_rules_basis_ck": { + "name": "establishment_fee_rules_basis_ck", + "value": "\"establishment_fee_rules\".\"basis\" IN ('ttc', 'ht')" + }, + "establishment_fee_rules_rate_ck": { + "name": "establishment_fee_rules_rate_ck", + "value": "\"establishment_fee_rules\".\"rate_pct\" >= 0 AND \"establishment_fee_rules\".\"rate_pct\" < 100" + }, + "establishment_fee_rules_fixed_ck": { + "name": "establishment_fee_rules_fixed_ck", + "value": "\"establishment_fee_rules\".\"fixed_monthly_ht\" IS NULL OR \"establishment_fee_rules\".\"fixed_monthly_ht\" >= 0" + }, + "establishment_fee_rules_channel_ck": { + "name": "establishment_fee_rules_channel_ck", + "value": "\"establishment_fee_rules\".\"match_channel\" IS NULL OR \"establishment_fee_rules\".\"match_channel\" IN ('sur_place', 'emporter', 'livraison', 'click_collect', 'autre')" + }, + "establishment_fee_rules_dates_ck": { + "name": "establishment_fee_rules_dates_ck", + "value": "\"establishment_fee_rules\".\"valid_to\" IS NULL OR \"establishment_fee_rules\".\"valid_to\" >= \"establishment_fee_rules\".\"valid_from\"" + }, + "establishment_fee_rules_label_ck": { + "name": "establishment_fee_rules_label_ck", + "value": "char_length(\"establishment_fee_rules\".\"label\") BETWEEN 1 AND 80" + } + }, + "isRLSEnabled": false + }, + "public.establishment_regulatory_profiles": { + "name": "establishment_regulatory_profiles", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "on_site": { + "name": "on_site", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "takeaway": { + "name": "takeaway", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "delivery": { + "name": "delivery", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "seating_capacity": { + "name": "seating_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "erp_category": { + "name": "erp_category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erp_type": { + "name": "erp_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headcount_declared": { + "name": "headcount_declared", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "alcohol_licence": { + "name": "alcohol_licence", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "terrace": { + "name": "terrace", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "music": { + "name": "music", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "cameras": { + "name": "cameras", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "fryer": { + "name": "fryer", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "minors_employed": { + "name": "minors_employed", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "foreign_workers": { + "name": "foreign_workers", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "franchise": { + "name": "franchise", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishment_regulatory_profiles_org_idx": { + "name": "establishment_regulatory_profiles_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishment_regulatory_profiles_establishment_id_establishments_id_fk": { + "name": "establishment_regulatory_profiles_establishment_id_establishments_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_regulatory_profiles_organization_id_organizations_id_fk": { + "name": "establishment_regulatory_profiles_organization_id_organizations_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_regulatory_profiles_updated_by_users_id_fk": { + "name": "establishment_regulatory_profiles_updated_by_users_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "establishment_regulatory_profiles_erp_ck": { + "name": "establishment_regulatory_profiles_erp_ck", + "value": "\"establishment_regulatory_profiles\".\"erp_category\" IS NULL OR \"establishment_regulatory_profiles\".\"erp_category\" IN ('1', '2', '3', '4', '5')" + }, + "establishment_regulatory_profiles_licence_ck": { + "name": "establishment_regulatory_profiles_licence_ck", + "value": "\"establishment_regulatory_profiles\".\"alcohol_licence\" IS NULL OR \"establishment_regulatory_profiles\".\"alcohol_licence\" IN ('aucune', 'petite_licence_restaurant', 'licence_restaurant', 'licence_3', 'licence_4', 'petite_licence_emporter', 'licence_emporter', 'inconnue')" + }, + "establishment_regulatory_profiles_counts_ck": { + "name": "establishment_regulatory_profiles_counts_ck", + "value": "(\"establishment_regulatory_profiles\".\"seating_capacity\" IS NULL OR \"establishment_regulatory_profiles\".\"seating_capacity\" >= 0) AND (\"establishment_regulatory_profiles\".\"headcount_declared\" IS NULL OR \"establishment_regulatory_profiles\".\"headcount_declared\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.establishments": { + "name": "establishments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'restaurant'" + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ape_code": { + "name": "ape_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idcc": { + "name": "idcc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "country": { + "name": "country", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'FR'" + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Europe/Paris'" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'EUR'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishments_org_idx": { + "name": "establishments_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishments_organization_id_organizations_id_fk": { + "name": "establishments_organization_id_organizations_id_fk", + "tableFrom": "establishments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishments_company_id_companies_id_fk": { + "name": "establishments_company_id_companies_id_fk", + "tableFrom": "establishments", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.expense_entries": { + "name": "expense_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier": { + "name": "supplier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "period_start": { + "name": "period_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_end": { + "name": "period_end", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "recurrence": { + "name": "recurrence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "recurrence_until": { + "name": "recurrence_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deleted_by": { + "name": "deleted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "deletion_reason": { + "name": "deletion_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "double_count_decision": { + "name": "double_count_decision", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "double_count_decided_by": { + "name": "double_count_decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "double_count_decided_at": { + "name": "double_count_decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "expenses_period_idx": { + "name": "expenses_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_start", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_end", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "expense_entries_organization_id_organizations_id_fk": { + "name": "expense_entries_organization_id_organizations_id_fk", + "tableFrom": "expense_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "expense_entries_establishment_id_establishments_id_fk": { + "name": "expense_entries_establishment_id_establishments_id_fk", + "tableFrom": "expense_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "expense_entries_created_by_users_id_fk": { + "name": "expense_entries_created_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "expense_entries_deleted_by_users_id_fk": { + "name": "expense_entries_deleted_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "deleted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "expense_entries_double_count_decided_by_users_id_fk": { + "name": "expense_entries_double_count_decided_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "double_count_decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "expenses_period_ck": { + "name": "expenses_period_ck", + "value": "\"expense_entries\".\"period_start\" <= \"expense_entries\".\"period_end\"" + }, + "expenses_recurrence_ck": { + "name": "expenses_recurrence_ck", + "value": "\"expense_entries\".\"recurrence\" IN ('none', 'monthly', 'quarterly', 'yearly')" + }, + "expenses_recurrence_until_ck": { + "name": "expenses_recurrence_until_ck", + "value": "\"expense_entries\".\"recurrence_until\" IS NULL OR (\"expense_entries\".\"recurrence\" <> 'none' AND \"expense_entries\".\"recurrence_until\" >= \"expense_entries\".\"period_start\")" + }, + "expenses_ttc_consistency_ck": { + "name": "expenses_ttc_consistency_ck", + "value": "\"expense_entries\".\"amount_ttc\" = \"expense_entries\".\"amount_ht\" + \"expense_entries\".\"vat_amount\"" + }, + "expense_double_count_ck": { + "name": "expense_double_count_ck", + "value": "\"expense_entries\".\"double_count_decision\" IS NULL OR \"expense_entries\".\"double_count_decision\" IN ('keep', 'exclude')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_ambassadors": { + "name": "feedback_ambassadors", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "appointed_by": { + "name": "appointed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_ambassadors_organization_id_organizations_id_fk": { + "name": "feedback_ambassadors_organization_id_organizations_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_ambassadors_user_id_users_id_fk": { + "name": "feedback_ambassadors_user_id_users_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_ambassadors_appointed_by_users_id_fk": { + "name": "feedback_ambassadors_appointed_by_users_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "users", + "columnsFrom": [ + "appointed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_ambassadors_organization_id_user_id_pk": { + "name": "feedback_ambassadors_organization_id_user_id_pk", + "columns": [ + "organization_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback_comments": { + "name": "feedback_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'commentaire'" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_status": { + "name": "from_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "to_status": { + "name": "to_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_comments_item_idx": { + "name": "feedback_comments_item_idx", + "columns": [ + { + "expression": "feedback_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_comments_organization_id_organizations_id_fk": { + "name": "feedback_comments_organization_id_organizations_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_comments_feedback_id_feedback_items_id_fk": { + "name": "feedback_comments_feedback_id_feedback_items_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "feedback_items", + "columnsFrom": [ + "feedback_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_comments_user_id_users_id_fk": { + "name": "feedback_comments_user_id_users_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_comments_kind_ck": { + "name": "feedback_comments_kind_ck", + "value": "\"feedback_comments\".\"kind\" IN ('commentaire', 'reponse', 'statut', 'fusion')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_items": { + "name": "feedback_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "page_path": { + "name": "page_path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_role": { + "name": "author_role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "screenshot": { + "name": "screenshot", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "screenshot_mime": { + "name": "screenshot_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'recue'" + }, + "status_note": { + "name": "status_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "release_version": { + "name": "release_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "merged_into_id": { + "name": "merged_into_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "first_response_at": { + "name": "first_response_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delivered_at": { + "name": "delivered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_items_number_uq": { + "name": "feedback_items_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "feedback_items_org_idx": { + "name": "feedback_items_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_items_organization_id_organizations_id_fk": { + "name": "feedback_items_organization_id_organizations_id_fk", + "tableFrom": "feedback_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_items_merged_into_id_feedback_items_id_fk": { + "name": "feedback_items_merged_into_id_feedback_items_id_fk", + "tableFrom": "feedback_items", + "tableTo": "feedback_items", + "columnsFrom": [ + "merged_into_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "feedback_items_author_id_users_id_fk": { + "name": "feedback_items_author_id_users_id_fk", + "tableFrom": "feedback_items", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_items_kind_ck": { + "name": "feedback_items_kind_ck", + "value": "\"feedback_items\".\"kind\" IN ('idee', 'probleme', 'question')" + }, + "feedback_items_status_ck": { + "name": "feedback_items_status_ck", + "value": "\"feedback_items\".\"status\" IN ('recue', 'etude', 'prevue', 'en_cours', 'livree', 'pas_maintenant')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_pulses": { + "name": "feedback_pulses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_pulses_once_uq": { + "name": "feedback_pulses_once_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "app_version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "feedback_pulses_org_idx": { + "name": "feedback_pulses_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_pulses_organization_id_organizations_id_fk": { + "name": "feedback_pulses_organization_id_organizations_id_fk", + "tableFrom": "feedback_pulses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_pulses_user_id_users_id_fk": { + "name": "feedback_pulses_user_id_users_id_fk", + "tableFrom": "feedback_pulses", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_pulses_answer_ck": { + "name": "feedback_pulses_answer_ck", + "value": "\"feedback_pulses\".\"answer\" IN ('oui', 'non')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_testers": { + "name": "feedback_testers", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_testers_organization_id_organizations_id_fk": { + "name": "feedback_testers_organization_id_organizations_id_fk", + "tableFrom": "feedback_testers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_testers_user_id_users_id_fk": { + "name": "feedback_testers_user_id_users_id_fk", + "tableFrom": "feedback_testers", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_testers_organization_id_user_id_pk": { + "name": "feedback_testers_organization_id_user_id_pk", + "columns": [ + "organization_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback_votes": { + "name": "feedback_votes", + "schema": "", + "columns": { + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_votes_feedback_id_feedback_items_id_fk": { + "name": "feedback_votes_feedback_id_feedback_items_id_fk", + "tableFrom": "feedback_votes", + "tableTo": "feedback_items", + "columnsFrom": [ + "feedback_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_votes_user_id_users_id_fk": { + "name": "feedback_votes_user_id_users_id_fk", + "tableFrom": "feedback_votes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_votes_feedback_id_user_id_pk": { + "name": "feedback_votes_feedback_id_user_id_pk", + "columns": [ + "feedback_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.file_downloads": { + "name": "file_downloads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sensitivity": { + "name": "sensitivity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disposition": { + "name": "disposition", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "file_downloads_entity_idx": { + "name": "file_downloads_entity_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "file_downloads_organization_id_organizations_id_fk": { + "name": "file_downloads_organization_id_organizations_id_fk", + "tableFrom": "file_downloads", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "file_downloads_user_id_users_id_fk": { + "name": "file_downloads_user_id_users_id_fk", + "tableFrom": "file_downloads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "file_downloads_source_ck": { + "name": "file_downloads_source_ck", + "value": "\"file_downloads\".\"source\" IN ('business_document', 'business_document_version', 'employee_file', 'vault_zip', 'privacy_export', 'signature_request', 'sos_zip', 'generated_report', 'generated_hr_document', 'data_export')" + }, + "file_downloads_disposition_ck": { + "name": "file_downloads_disposition_ck", + "value": "\"file_downloads\".\"disposition\" IN ('inline', 'attachment', 'zip')" + } + }, + "isRLSEnabled": false + }, + "public.fixed_assets": { + "name": "fixed_assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "financing": { + "name": "financing", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "acquired_on": { + "name": "acquired_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "useful_life_months": { + "name": "useful_life_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lease_monthly_ht": { + "name": "lease_monthly_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "lease_end_on": { + "name": "lease_end_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "lease_residual_ht": { + "name": "lease_residual_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "disposed_on": { + "name": "disposed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "disposal_reason": { + "name": "disposal_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "fixed_assets_est_idx": { + "name": "fixed_assets_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fixed_assets_invoice_uq": { + "name": "fixed_assets_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"fixed_assets\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "fixed_assets_pennylane_uq": { + "name": "fixed_assets_pennylane_uq", + "columns": [ + { + "expression": "pennylane_record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"fixed_assets\".\"pennylane_record_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "fixed_assets_organization_id_organizations_id_fk": { + "name": "fixed_assets_organization_id_organizations_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fixed_assets_establishment_id_establishments_id_fk": { + "name": "fixed_assets_establishment_id_establishments_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fixed_assets_supplier_id_suppliers_id_fk": { + "name": "fixed_assets_supplier_id_suppliers_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "fixed_assets_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_pennylane_record_id_pennylane_records_id_fk": { + "name": "fixed_assets_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_document_id_business_documents_id_fk": { + "name": "fixed_assets_document_id_business_documents_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_created_by_users_id_fk": { + "name": "fixed_assets_created_by_users_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "fixed_assets_category_ck": { + "name": "fixed_assets_category_ck", + "value": "\"fixed_assets\".\"category\" IN ('materiel_cuisine', 'mobilier', 'informatique', 'agencement', 'vehicule', 'autre')" + }, + "fixed_assets_financing_ck": { + "name": "fixed_assets_financing_ck", + "value": "\"fixed_assets\".\"financing\" IN ('achat', 'credit_bail', 'location_financiere')" + }, + "fixed_assets_purchase_ck": { + "name": "fixed_assets_purchase_ck", + "value": "\"fixed_assets\".\"financing\" <> 'achat' OR (\"fixed_assets\".\"amount_ht\" IS NOT NULL AND \"fixed_assets\".\"amount_ht\" > 0 AND \"fixed_assets\".\"useful_life_months\" IS NOT NULL)" + }, + "fixed_assets_lease_ck": { + "name": "fixed_assets_lease_ck", + "value": "\"fixed_assets\".\"financing\" = 'achat' OR (\"fixed_assets\".\"lease_monthly_ht\" IS NOT NULL AND \"fixed_assets\".\"lease_monthly_ht\" > 0 AND \"fixed_assets\".\"lease_end_on\" IS NOT NULL AND \"fixed_assets\".\"lease_end_on\" > \"fixed_assets\".\"acquired_on\")" + }, + "fixed_assets_life_ck": { + "name": "fixed_assets_life_ck", + "value": "\"fixed_assets\".\"useful_life_months\" IS NULL OR \"fixed_assets\".\"useful_life_months\" BETWEEN 1 AND 600" + }, + "fixed_assets_amounts_ck": { + "name": "fixed_assets_amounts_ck", + "value": "(\"fixed_assets\".\"amount_ht\" IS NULL OR \"fixed_assets\".\"amount_ht\" >= 0) AND (\"fixed_assets\".\"lease_residual_ht\" IS NULL OR \"fixed_assets\".\"lease_residual_ht\" >= 0)" + }, + "fixed_assets_disposal_ck": { + "name": "fixed_assets_disposal_ck", + "value": "\"fixed_assets\".\"disposed_on\" IS NULL OR (\"fixed_assets\".\"disposed_on\" >= \"fixed_assets\".\"acquired_on\" AND \"fixed_assets\".\"disposal_reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.floor_items": { + "name": "floor_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "shape": { + "name": "shape", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "w": { + "name": "w", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "h": { + "name": "h", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "rotation": { + "name": "rotation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "floor_items_room_idx": { + "name": "floor_items_room_idx", + "columns": [ + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "floor_items_table_label_uq": { + "name": "floor_items_table_label_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"label\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"floor_items\".\"kind\" = 'table' AND \"floor_items\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "floor_items_organization_id_organizations_id_fk": { + "name": "floor_items_organization_id_organizations_id_fk", + "tableFrom": "floor_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "floor_items_establishment_id_establishments_id_fk": { + "name": "floor_items_establishment_id_establishments_id_fk", + "tableFrom": "floor_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "floor_items_room_id_floor_rooms_id_fk": { + "name": "floor_items_room_id_floor_rooms_id_fk", + "tableFrom": "floor_items", + "tableTo": "floor_rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "floor_items_kind_ck": { + "name": "floor_items_kind_ck", + "value": "\"floor_items\".\"kind\" IN ('table', 'wall', 'bar', 'door', 'window', 'pillar', 'plant', 'zone', 'text')" + }, + "floor_items_table_ck": { + "name": "floor_items_table_ck", + "value": "\"floor_items\".\"kind\" <> 'table' OR (\"floor_items\".\"shape\" IN ('round', 'square', 'rect') AND \"floor_items\".\"label\" IS NOT NULL AND \"floor_items\".\"seats\" BETWEEN 1 AND 40)" + }, + "floor_items_size_ck": { + "name": "floor_items_size_ck", + "value": "\"floor_items\".\"w\" BETWEEN 5 AND 10000 AND \"floor_items\".\"h\" BETWEEN 5 AND 10000 AND \"floor_items\".\"rotation\" BETWEEN 0 AND 359" + } + }, + "isRLSEnabled": false + }, + "public.floor_rooms": { + "name": "floor_rooms", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width_cm": { + "name": "width_cm", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1200 + }, + "height_cm": { + "name": "height_cm", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 800 + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "floor_rooms_est_idx": { + "name": "floor_rooms_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "floor_rooms_organization_id_organizations_id_fk": { + "name": "floor_rooms_organization_id_organizations_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "floor_rooms_establishment_id_establishments_id_fk": { + "name": "floor_rooms_establishment_id_establishments_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "floor_rooms_created_by_users_id_fk": { + "name": "floor_rooms_created_by_users_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "floor_rooms_size_ck": { + "name": "floor_rooms_size_ck", + "value": "\"floor_rooms\".\"width_cm\" BETWEEN 200 AND 10000 AND \"floor_rooms\".\"height_cm\" BETWEEN 200 AND 10000" + } + }, + "isRLSEnabled": false + }, + "public.forecast_events": { + "name": "forecast_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_day": { + "name": "from_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "to_day": { + "name": "to_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "impact_pct": { + "name": "impact_pct", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forecast_events_org_idx": { + "name": "forecast_events_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forecast_events_organization_id_organizations_id_fk": { + "name": "forecast_events_organization_id_organizations_id_fk", + "tableFrom": "forecast_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forecast_events_establishment_id_establishments_id_fk": { + "name": "forecast_events_establishment_id_establishments_id_fk", + "tableFrom": "forecast_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forecast_events_created_by_users_id_fk": { + "name": "forecast_events_created_by_users_id_fk", + "tableFrom": "forecast_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "forecast_events_range_ck": { + "name": "forecast_events_range_ck", + "value": "\"forecast_events\".\"to_day\" >= \"forecast_events\".\"from_day\" AND \"forecast_events\".\"to_day\" - \"forecast_events\".\"from_day\" <= 92" + }, + "forecast_events_impact_ck": { + "name": "forecast_events_impact_ck", + "value": "\"forecast_events\".\"impact_pct\" IS NULL OR (\"forecast_events\".\"impact_pct\" >= -100 AND \"forecast_events\".\"impact_pct\" <= 500)" + } + }, + "isRLSEnabled": false + }, + "public.forum_replies": { + "name": "forum_replies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "topic_id": { + "name": "topic_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forum_replies_topic_idx": { + "name": "forum_replies_topic_idx", + "columns": [ + { + "expression": "topic_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forum_replies_organization_id_organizations_id_fk": { + "name": "forum_replies_organization_id_organizations_id_fk", + "tableFrom": "forum_replies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_replies_topic_id_forum_topics_id_fk": { + "name": "forum_replies_topic_id_forum_topics_id_fk", + "tableFrom": "forum_replies", + "tableTo": "forum_topics", + "columnsFrom": [ + "topic_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_replies_author_id_users_id_fk": { + "name": "forum_replies_author_id_users_id_fk", + "tableFrom": "forum_replies", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.forum_topics": { + "name": "forum_topics", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'question'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pinned": { + "name": "pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "solution_reply_id": { + "name": "solution_reply_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "idea_id": { + "name": "idea_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forum_topics_number_uq": { + "name": "forum_topics_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "forum_topics_org_idx": { + "name": "forum_topics_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "pinned", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_activity_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forum_topics_organization_id_organizations_id_fk": { + "name": "forum_topics_organization_id_organizations_id_fk", + "tableFrom": "forum_topics", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_topics_author_id_users_id_fk": { + "name": "forum_topics_author_id_users_id_fk", + "tableFrom": "forum_topics", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "forum_topics_idea_id_feedback_items_id_fk": { + "name": "forum_topics_idea_id_feedback_items_id_fk", + "tableFrom": "forum_topics", + "tableTo": "feedback_items", + "columnsFrom": [ + "idea_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "forum_topics_category_ck": { + "name": "forum_topics_category_ck", + "value": "\"forum_topics\".\"category\" IN ('question', 'astuce', 'discussion')" + } + }, + "isRLSEnabled": false + }, + "public.google_post_settings": { + "name": "google_post_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "schedule_mode": { + "name": "schedule_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'per_week'" + }, + "weekdays": { + "name": "weekdays", + "type": "integer[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[2,5]::integer[]" + }, + "per_week": { + "name": "per_week", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "post_time": { + "name": "post_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'10:00'" + }, + "lead_hours": { + "name": "lead_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 48 + }, + "src_menu": { + "name": "src_menu", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_events": { + "name": "src_events", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_hours": { + "name": "src_hours", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_best_sellers": { + "name": "src_best_sellers", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_seasonal": { + "name": "src_seasonal", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_reviews": { + "name": "src_reviews", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "review_min_rating": { + "name": "review_min_rating", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "default_cta_type": { + "name": "default_cta_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "default_cta_url": { + "name": "default_cta_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'fr'" + }, + "autopublish": { + "name": "autopublish", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enabled_by": { + "name": "enabled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "enabled_at": { + "name": "enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmation": { + "name": "confirmation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_generated_at": { + "name": "last_generated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "google_post_settings_org_idx": { + "name": "google_post_settings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "google_post_settings_establishment_id_establishments_id_fk": { + "name": "google_post_settings_establishment_id_establishments_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_post_settings_organization_id_organizations_id_fk": { + "name": "google_post_settings_organization_id_organizations_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_post_settings_enabled_by_users_id_fk": { + "name": "google_post_settings_enabled_by_users_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "users", + "columnsFrom": [ + "enabled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_post_settings_updated_by_users_id_fk": { + "name": "google_post_settings_updated_by_users_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "google_post_settings_mode_ck": { + "name": "google_post_settings_mode_ck", + "value": "\"google_post_settings\".\"schedule_mode\" IN ('weekdays', 'per_week')" + }, + "google_post_settings_weekdays_ck": { + "name": "google_post_settings_weekdays_ck", + "value": "cardinality(\"google_post_settings\".\"weekdays\") BETWEEN 1 AND 7 AND \"google_post_settings\".\"weekdays\" <@ ARRAY[1,2,3,4,5,6,7]::integer[]" + }, + "google_post_settings_per_week_ck": { + "name": "google_post_settings_per_week_ck", + "value": "\"google_post_settings\".\"per_week\" BETWEEN 1 AND 7" + }, + "google_post_settings_time_ck": { + "name": "google_post_settings_time_ck", + "value": "\"google_post_settings\".\"post_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "google_post_settings_lead_ck": { + "name": "google_post_settings_lead_ck", + "value": "\"google_post_settings\".\"lead_hours\" BETWEEN 12 AND 168" + }, + "google_post_settings_rating_ck": { + "name": "google_post_settings_rating_ck", + "value": "\"google_post_settings\".\"review_min_rating\" BETWEEN 4 AND 5" + }, + "google_post_settings_cta_ck": { + "name": "google_post_settings_cta_ck", + "value": "\"google_post_settings\".\"default_cta_type\" IS NULL OR \"google_post_settings\".\"default_cta_type\" IN ('BOOK', 'ORDER', 'SHOP', 'LEARN_MORE', 'SIGN_UP', 'CALL')" + }, + "google_post_settings_autopublish_ck": { + "name": "google_post_settings_autopublish_ck", + "value": "NOT \"google_post_settings\".\"autopublish\" OR \"google_post_settings\".\"confirmation\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.google_posts": { + "name": "google_posts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "generator": { + "name": "generator", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "facts": { + "name": "facts", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "topic_type": { + "name": "topic_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'STANDARD'" + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cta_type": { + "name": "cta_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cta_url": { + "name": "cta_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_title": { + "name": "event_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_start_date": { + "name": "event_start_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_start_time": { + "name": "event_start_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_end_date": { + "name": "event_end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_end_time": { + "name": "event_end_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_coupon": { + "name": "offer_coupon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_url": { + "name": "offer_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_terms": { + "name": "offer_terms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "visual_id": { + "name": "visual_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "image_mime": { + "name": "image_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blocked_words": { + "name": "blocked_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "google_name": { + "name": "google_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_state": { + "name": "google_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "search_url": { + "name": "search_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "ai_cost_usd": { + "name": "ai_cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "google_posts_due_idx": { + "name": "google_posts_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_cal_idx": { + "name": "google_posts_cal_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_for", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_source_uq": { + "name": "google_posts_source_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"google_posts\".\"source_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_token_uq": { + "name": "google_posts_token_uq", + "columns": [ + { + "expression": "public_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "google_posts_organization_id_organizations_id_fk": { + "name": "google_posts_organization_id_organizations_id_fk", + "tableFrom": "google_posts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_posts_establishment_id_establishments_id_fk": { + "name": "google_posts_establishment_id_establishments_id_fk", + "tableFrom": "google_posts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_posts_visual_id_studio_visuals_id_fk": { + "name": "google_posts_visual_id_studio_visuals_id_fk", + "tableFrom": "google_posts", + "tableTo": "studio_visuals", + "columnsFrom": [ + "visual_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_posts_approved_by_users_id_fk": { + "name": "google_posts_approved_by_users_id_fk", + "tableFrom": "google_posts", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_posts_created_by_users_id_fk": { + "name": "google_posts_created_by_users_id_fk", + "tableFrom": "google_posts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "google_posts_source_ck": { + "name": "google_posts_source_ck", + "value": "\"google_posts\".\"source\" IN ('manuel', 'menu_du_jour', 'evenement', 'horaires', 'meilleures_ventes', 'saison', 'avis')" + }, + "google_posts_generator_ck": { + "name": "google_posts_generator_ck", + "value": "\"google_posts\".\"generator\" IN ('ia', 'modele', 'humain')" + }, + "google_posts_topic_ck": { + "name": "google_posts_topic_ck", + "value": "\"google_posts\".\"topic_type\" IN ('STANDARD', 'EVENT', 'OFFER')" + }, + "google_posts_status_ck": { + "name": "google_posts_status_ck", + "value": "\"google_posts\".\"status\" IN ('brouillon', 'planifie', 'publishing', 'publie', 'echec', 'bloque', 'annule', 'expire', 'retire')" + }, + "google_posts_summary_ck": { + "name": "google_posts_summary_ck", + "value": "char_length(\"google_posts\".\"summary\") BETWEEN 1 AND 1500" + }, + "google_posts_cta_ck": { + "name": "google_posts_cta_ck", + "value": "\"google_posts\".\"cta_type\" IS NULL OR \"google_posts\".\"cta_type\" IN ('BOOK', 'ORDER', 'SHOP', 'LEARN_MORE', 'SIGN_UP', 'CALL')" + }, + "google_posts_image_ck": { + "name": "google_posts_image_ck", + "value": "(\"google_posts\".\"image\" IS NULL) = (\"google_posts\".\"image_mime\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.haccp_corrective_actions": { + "name": "haccp_corrective_actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_id": { + "name": "source_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dedup_key": { + "name": "dedup_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "detected_at": { + "name": "detected_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "action_taken": { + "name": "action_taken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "haccp_corrective_actions_dedup_uq": { + "name": "haccp_corrective_actions_dedup_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedup_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "haccp_corrective_actions_open_idx": { + "name": "haccp_corrective_actions_open_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "detected_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"haccp_corrective_actions\".\"closed_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "haccp_corrective_actions_organization_id_organizations_id_fk": { + "name": "haccp_corrective_actions_organization_id_organizations_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_corrective_actions_establishment_id_establishments_id_fk": { + "name": "haccp_corrective_actions_establishment_id_establishments_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_corrective_actions_closed_by_users_id_fk": { + "name": "haccp_corrective_actions_closed_by_users_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "haccp_corrective_actions_created_by_users_id_fk": { + "name": "haccp_corrective_actions_created_by_users_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "haccp_corrective_actions_source_ck": { + "name": "haccp_corrective_actions_source_ck", + "value": "\"haccp_corrective_actions\".\"source\" IN ('sonde_hors_plage', 'sonde_muette', 'releves_manquants', 'nettoyage_manquant', 'date_limite', 'manuel')" + }, + "haccp_corrective_actions_close_ck": { + "name": "haccp_corrective_actions_close_ck", + "value": "(\"haccp_corrective_actions\".\"closed_at\" IS NULL) = (\"haccp_corrective_actions\".\"action_taken\" IS NULL) AND (\"haccp_corrective_actions\".\"closed_at\" IS NULL) = (\"haccp_corrective_actions\".\"closed_by\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.incidents": { + "name": "incidents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actions_taken": { + "name": "actions_taken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "reported_by": { + "name": "reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reported_at": { + "name": "reported_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "incidents_est_idx": { + "name": "incidents_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurred_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "incidents_organization_id_organizations_id_fk": { + "name": "incidents_organization_id_organizations_id_fk", + "tableFrom": "incidents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "incidents_establishment_id_establishments_id_fk": { + "name": "incidents_establishment_id_establishments_id_fk", + "tableFrom": "incidents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "incidents_reported_by_users_id_fk": { + "name": "incidents_reported_by_users_id_fk", + "tableFrom": "incidents", + "tableTo": "users", + "columnsFrom": [ + "reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "incidents_closed_by_users_id_fk": { + "name": "incidents_closed_by_users_id_fk", + "tableFrom": "incidents", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "incidents_kind_ck": { + "name": "incidents_kind_ck", + "value": "\"incidents\".\"kind\" IN ('client', 'accident', 'casse', 'vol', 'securite', 'hygiene', 'livraison', 'autre')" + }, + "incidents_severity_ck": { + "name": "incidents_severity_ck", + "value": "\"incidents\".\"severity\" IN ('mineur', 'important', 'grave')" + }, + "incidents_status_ck": { + "name": "incidents_status_ck", + "value": "\"incidents\".\"status\" IN ('ouvert', 'clos')" + }, + "incidents_closed_ck": { + "name": "incidents_closed_ck", + "value": "\"incidents\".\"status\" = 'ouvert' OR (\"incidents\".\"closed_at\" IS NOT NULL AND \"incidents\".\"follow_up\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.inspection_shares": { + "name": "inspection_shares", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inspector_code": { + "name": "inspector_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_name": { + "name": "created_by_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "access_count": { + "name": "access_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_access_at": { + "name": "last_access_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inspection_shares_token_uq": { + "name": "inspection_shares_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inspection_shares_est_idx": { + "name": "inspection_shares_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inspection_shares_organization_id_organizations_id_fk": { + "name": "inspection_shares_organization_id_organizations_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inspection_shares_establishment_id_establishments_id_fk": { + "name": "inspection_shares_establishment_id_establishments_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inspection_shares_created_by_users_id_fk": { + "name": "inspection_shares_created_by_users_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_connections": { + "name": "integration_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "connection_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'not_configured'" + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_config": { + "name": "public_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_sync": { + "name": "auto_sync", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sync_interval_hours": { + "name": "sync_interval_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 24 + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integration_conn_uq": { + "name": "integration_conn_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_connections_organization_id_organizations_id_fk": { + "name": "integration_connections_organization_id_organizations_id_fk", + "tableFrom": "integration_connections", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_connections_establishment_id_establishments_id_fk": { + "name": "integration_connections_establishment_id_establishments_id_fk", + "tableFrom": "integration_connections", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "integration_conn_interval_ck": { + "name": "integration_conn_interval_ck", + "value": "\"integration_connections\".\"sync_interval_hours\" BETWEEN 1 AND 168" + }, + "integration_conn_failures_ck": { + "name": "integration_conn_failures_ck", + "value": "\"integration_connections\".\"consecutive_failures\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.integration_sync_runs": { + "name": "integration_sync_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "counts": { + "name": "counts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "errors": { + "name": "errors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "integration_sync_runs_idx": { + "name": "integration_sync_runs_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_sync_runs_organization_id_organizations_id_fk": { + "name": "integration_sync_runs_organization_id_organizations_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_sync_runs_establishment_id_establishments_id_fk": { + "name": "integration_sync_runs_establishment_id_establishments_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_sync_runs_user_id_users_id_fk": { + "name": "integration_sync_runs_user_id_users_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "integration_sync_runs_trigger_ck": { + "name": "integration_sync_runs_trigger_ck", + "value": "\"integration_sync_runs\".\"trigger\" IN ('manual', 'auto')" + }, + "integration_sync_runs_outcome_ck": { + "name": "integration_sync_runs_outcome_ck", + "value": "\"integration_sync_runs\".\"outcome\" IN ('success', 'partial', 'error')" + } + }, + "isRLSEnabled": false + }, + "public.intercompany_flows": { + "name": "intercompany_flows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payer_company_id": { + "name": "payer_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payee_company_id": { + "name": "payee_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "flow_date": { + "name": "flow_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "agreement_ref": { + "name": "agreement_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'saisie'" + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "bank_transaction_id": { + "name": "bank_transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "intercompany_flows_org_idx": { + "name": "intercompany_flows_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "flow_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "intercompany_flows_invoice_uq": { + "name": "intercompany_flows_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"intercompany_flows\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "intercompany_flows_bank_uq": { + "name": "intercompany_flows_bank_uq", + "columns": [ + { + "expression": "bank_transaction_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"intercompany_flows\".\"bank_transaction_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "intercompany_flows_organization_id_organizations_id_fk": { + "name": "intercompany_flows_organization_id_organizations_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_payer_company_id_companies_id_fk": { + "name": "intercompany_flows_payer_company_id_companies_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "companies", + "columnsFrom": [ + "payer_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_payee_company_id_companies_id_fk": { + "name": "intercompany_flows_payee_company_id_companies_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "companies", + "columnsFrom": [ + "payee_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "intercompany_flows_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "intercompany_flows_bank_transaction_id_bank_transactions_id_fk": { + "name": "intercompany_flows_bank_transaction_id_bank_transactions_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "bank_transactions", + "columnsFrom": [ + "bank_transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "intercompany_flows_created_by_users_id_fk": { + "name": "intercompany_flows_created_by_users_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "intercompany_flows_cancelled_by_users_id_fk": { + "name": "intercompany_flows_cancelled_by_users_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "intercompany_flows_pair_ck": { + "name": "intercompany_flows_pair_ck", + "value": "\"intercompany_flows\".\"payer_company_id\" <> \"intercompany_flows\".\"payee_company_id\"" + }, + "intercompany_flows_amount_ck": { + "name": "intercompany_flows_amount_ck", + "value": "\"intercompany_flows\".\"amount_ht\" > 0 AND (\"intercompany_flows\".\"vat_amount\" IS NULL OR \"intercompany_flows\".\"vat_amount\" >= 0)" + }, + "intercompany_flows_source_ck": { + "name": "intercompany_flows_source_ck", + "value": "\"intercompany_flows\".\"source\" IN ('saisie', 'facture', 'banque')" + }, + "intercompany_flows_kind_ck": { + "name": "intercompany_flows_kind_ck", + "value": "\"intercompany_flows\".\"kind\" IN ('refacturation', 'management_fees', 'loyer', 'vente', 'interets', 'dividendes', 'pret', 'remboursement_pret', 'apport_compte_courant', 'remboursement_compte_courant', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.inventories": { + "name": "inventories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "count_date": { + "name": "count_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "total_value": { + "name": "total_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inventories_est_idx": { + "name": "inventories_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "count_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inventories_validated_day_uq": { + "name": "inventories_validated_day_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "count_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"inventories\".\"status\" = 'validated'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inventories_organization_id_organizations_id_fk": { + "name": "inventories_organization_id_organizations_id_fk", + "tableFrom": "inventories", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventories_establishment_id_establishments_id_fk": { + "name": "inventories_establishment_id_establishments_id_fk", + "tableFrom": "inventories", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "inventories_created_by_users_id_fk": { + "name": "inventories_created_by_users_id_fk", + "tableFrom": "inventories", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventories_validated_by_users_id_fk": { + "name": "inventories_validated_by_users_id_fk", + "tableFrom": "inventories", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "inventories_status_ck": { + "name": "inventories_status_ck", + "value": "\"inventories\".\"status\" IN ('draft', 'validated')" + } + }, + "isRLSEnabled": false + }, + "public.inventory_lines": { + "name": "inventory_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inventory_id": { + "name": "inventory_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inventory_lines_item_uq": { + "name": "inventory_lines_item_uq", + "columns": [ + { + "expression": "inventory_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inventory_lines_organization_id_organizations_id_fk": { + "name": "inventory_lines_organization_id_organizations_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventory_lines_inventory_id_inventories_id_fk": { + "name": "inventory_lines_inventory_id_inventories_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "inventories", + "columnsFrom": [ + "inventory_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventory_lines_item_id_purchase_items_id_fk": { + "name": "inventory_lines_item_id_purchase_items_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "inventory_lines_qty_ck": { + "name": "inventory_lines_qty_ck", + "value": "\"inventory_lines\".\"quantity\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.investment_scenarios": { + "name": "investment_scenarios", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'etude'" + }, + "price": { + "name": "price", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "fees": { + "name": "fees", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "works": { + "name": "works", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "working_capital": { + "name": "working_capital", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "equity": { + "name": "equity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "loan_rate_pct": { + "name": "loan_rate_pct", + "type": "numeric(6, 3)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "loan_years": { + "name": "loan_years", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 7 + }, + "revenue_ht": { + "name": "revenue_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "ebe": { + "name": "ebe", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "adjustments": { + "name": "adjustments", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "owner_pay": { + "name": "owner_pay", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "maintenance_capex": { + "name": "maintenance_capex", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "investment_scenarios_org_idx": { + "name": "investment_scenarios_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "investment_scenarios_organization_id_organizations_id_fk": { + "name": "investment_scenarios_organization_id_organizations_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "investment_scenarios_establishment_id_establishments_id_fk": { + "name": "investment_scenarios_establishment_id_establishments_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "investment_scenarios_created_by_users_id_fk": { + "name": "investment_scenarios_created_by_users_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "investment_scenarios_updated_by_users_id_fk": { + "name": "investment_scenarios_updated_by_users_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "investment_scenarios_kind_ck": { + "name": "investment_scenarios_kind_ck", + "value": "\"investment_scenarios\".\"kind\" IN ('rachat_fonds', 'rachat_parts', 'travaux', 'equipement', 'ouverture', 'autre')" + }, + "investment_scenarios_status_ck": { + "name": "investment_scenarios_status_ck", + "value": "\"investment_scenarios\".\"status\" IN ('etude', 'retenu', 'abandonne', 'realise')" + }, + "investment_scenarios_years_ck": { + "name": "investment_scenarios_years_ck", + "value": "\"investment_scenarios\".\"loan_years\" BETWEEN 1 AND 30" + }, + "investment_scenarios_rate_ck": { + "name": "investment_scenarios_rate_ck", + "value": "\"investment_scenarios\".\"loan_rate_pct\" >= 0 AND \"investment_scenarios\".\"loan_rate_pct\" <= 20" + }, + "investment_scenarios_amounts_ck": { + "name": "investment_scenarios_amounts_ck", + "value": "\"investment_scenarios\".\"price\" >= 0 AND \"investment_scenarios\".\"fees\" >= 0 AND \"investment_scenarios\".\"works\" >= 0 AND \"investment_scenarios\".\"working_capital\" >= 0 AND \"investment_scenarios\".\"equity\" >= 0 AND \"investment_scenarios\".\"owner_pay\" >= 0 AND \"investment_scenarios\".\"maintenance_capex\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.invoice_label_links": { + "name": "invoice_label_links", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "link_key": { + "name": "link_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invoice_label_links_key_uq": { + "name": "invoice_label_links_key_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "link_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invoice_label_links_organization_id_organizations_id_fk": { + "name": "invoice_label_links_organization_id_organizations_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoice_label_links_item_id_purchase_items_id_fk": { + "name": "invoice_label_links_item_id_purchase_items_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoice_label_links_created_by_users_id_fk": { + "name": "invoice_label_links_created_by_users_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.item_stock_settings": { + "name": "item_stock_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "min_stock": { + "name": "min_stock", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "target_stock": { + "name": "target_stock", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "overstock_days": { + "name": "overstock_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "item_stock_settings_uq": { + "name": "item_stock_settings_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "item_stock_settings_organization_id_organizations_id_fk": { + "name": "item_stock_settings_organization_id_organizations_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "item_stock_settings_establishment_id_establishments_id_fk": { + "name": "item_stock_settings_establishment_id_establishments_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "item_stock_settings_item_id_purchase_items_id_fk": { + "name": "item_stock_settings_item_id_purchase_items_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "item_stock_settings_ck": { + "name": "item_stock_settings_ck", + "value": "(\"item_stock_settings\".\"min_stock\" IS NULL OR \"item_stock_settings\".\"min_stock\" >= 0) AND (\"item_stock_settings\".\"target_stock\" IS NULL OR \"item_stock_settings\".\"target_stock\" >= 0) AND (\"item_stock_settings\".\"overstock_days\" IS NULL OR \"item_stock_settings\".\"overstock_days\" BETWEEN 1 AND 365)" + } + }, + "isRLSEnabled": false + }, + "public.job_openings": { + "name": "job_openings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_kind": { + "name": "contract_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'cdi'" + }, + "weekly_hours": { + "name": "weekly_hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "start_wanted": { + "name": "start_wanted", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_openings_org_idx": { + "name": "job_openings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_openings_organization_id_organizations_id_fk": { + "name": "job_openings_organization_id_organizations_id_fk", + "tableFrom": "job_openings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_openings_establishment_id_establishments_id_fk": { + "name": "job_openings_establishment_id_establishments_id_fk", + "tableFrom": "job_openings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_openings_created_by_users_id_fk": { + "name": "job_openings_created_by_users_id_fk", + "tableFrom": "job_openings", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "job_openings_status_ck": { + "name": "job_openings_status_ck", + "value": "\"job_openings\".\"status\" IN ('ouvert', 'pourvu', 'ferme')" + }, + "job_openings_hours_ck": { + "name": "job_openings_hours_ck", + "value": "\"job_openings\".\"weekly_hours\" IS NULL OR (\"job_openings\".\"weekly_hours\" > 0 AND \"job_openings\".\"weekly_hours\" <= 48)" + } + }, + "isRLSEnabled": false + }, + "public.kitchen_labels": { + "name": "kitchen_labels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier_lot": { + "name": "supplier_lot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "produced_at": { + "name": "produced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "original_dlc": { + "name": "original_dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "shelf_life_days": { + "name": "shelf_life_days", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "ingredients": { + "name": "ingredients", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "storage_note": { + "name": "storage_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "copies": { + "name": "copies", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "trace_label_id": { + "name": "trace_label_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "printed_by": { + "name": "printed_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "kitchen_labels_est_idx": { + "name": "kitchen_labels_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "produced_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kitchen_labels_lot_uq": { + "name": "kitchen_labels_lot_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lot_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "kitchen_labels_organization_id_organizations_id_fk": { + "name": "kitchen_labels_organization_id_organizations_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "kitchen_labels_establishment_id_establishments_id_fk": { + "name": "kitchen_labels_establishment_id_establishments_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "kitchen_labels_recipe_id_recipes_id_fk": { + "name": "kitchen_labels_recipe_id_recipes_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "kitchen_labels_item_id_purchase_items_id_fk": { + "name": "kitchen_labels_item_id_purchase_items_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "kitchen_labels_trace_label_id_trace_labels_id_fk": { + "name": "kitchen_labels_trace_label_id_trace_labels_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "trace_labels", + "columnsFrom": [ + "trace_label_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "kitchen_labels_printed_by_users_id_fk": { + "name": "kitchen_labels_printed_by_users_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "users", + "columnsFrom": [ + "printed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "kitchen_labels_cancelled_by_users_id_fk": { + "name": "kitchen_labels_cancelled_by_users_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "kitchen_labels_kind_ck": { + "name": "kitchen_labels_kind_ck", + "value": "\"kitchen_labels\".\"kind\" IN ('production', 'ouverture', 'temoin')" + }, + "kitchen_labels_format_ck": { + "name": "kitchen_labels_format_ck", + "value": "\"kitchen_labels\".\"format\" IN ('62x29', '62x100', '102x152')" + }, + "kitchen_labels_copies_ck": { + "name": "kitchen_labels_copies_ck", + "value": "\"kitchen_labels\".\"copies\" BETWEEN 1 AND 50 AND \"kitchen_labels\".\"shelf_life_days\" BETWEEN 0 AND 90" + }, + "kitchen_labels_service_ck": { + "name": "kitchen_labels_service_ck", + "value": "\"kitchen_labels\".\"service\" IS NULL OR \"kitchen_labels\".\"service\" IN ('midi', 'soir')" + } + }, + "isRLSEnabled": false + }, + "public.known_devices": { + "name": "known_devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_ip": { + "name": "last_ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "alerted_at": { + "name": "alerted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "known_devices_uq": { + "name": "known_devices_uq", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "known_devices_user_idx": { + "name": "known_devices_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_seen_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "known_devices_user_id_users_id_fk": { + "name": "known_devices_user_id_users_id_fk", + "tableFrom": "known_devices", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lead_activities": { + "name": "lead_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "lead_id": { + "name": "lead_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "lead_activities_lead_idx": { + "name": "lead_activities_lead_idx", + "columns": [ + { + "expression": "lead_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "lead_activities_organization_id_organizations_id_fk": { + "name": "lead_activities_organization_id_organizations_id_fk", + "tableFrom": "lead_activities", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lead_activities_lead_id_leads_id_fk": { + "name": "lead_activities_lead_id_leads_id_fk", + "tableFrom": "lead_activities", + "tableTo": "leads", + "columnsFrom": [ + "lead_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lead_activities_created_by_users_id_fk": { + "name": "lead_activities_created_by_users_id_fk", + "tableFrom": "lead_activities", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.leads": { + "name": "leads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_kind": { + "name": "event_kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "guests": { + "name": "guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "budget_ttc": { + "name": "budget_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "company": { + "name": "company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'nouveau'" + }, + "lost_reason": { + "name": "lost_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_action_on": { + "name": "next_action_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "next_action": { + "name": "next_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "set_menu_id": { + "name": "set_menu_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "leads_org_stage_idx": { + "name": "leads_org_stage_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stage", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_action_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "leads_est_idx": { + "name": "leads_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "leads_organization_id_organizations_id_fk": { + "name": "leads_organization_id_organizations_id_fk", + "tableFrom": "leads", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leads_establishment_id_establishments_id_fk": { + "name": "leads_establishment_id_establishments_id_fk", + "tableFrom": "leads", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "leads_customer_id_customers_id_fk": { + "name": "leads_customer_id_customers_id_fk", + "tableFrom": "leads", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_owner_user_id_users_id_fk": { + "name": "leads_owner_user_id_users_id_fk", + "tableFrom": "leads", + "tableTo": "users", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_set_menu_id_set_menus_id_fk": { + "name": "leads_set_menu_id_set_menus_id_fk", + "tableFrom": "leads", + "tableTo": "set_menus", + "columnsFrom": [ + "set_menu_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_created_by_users_id_fk": { + "name": "leads_created_by_users_id_fk", + "tableFrom": "leads", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leads_stage_ck": { + "name": "leads_stage_ck", + "value": "\"leads\".\"stage\" IN ('nouveau', 'contacte', 'devis', 'negociation', 'gagne', 'perdu')" + }, + "leads_guests_ck": { + "name": "leads_guests_ck", + "value": "\"leads\".\"guests\" IS NULL OR (\"leads\".\"guests\" > 0 AND \"leads\".\"guests\" <= 5000)" + }, + "leads_budget_ck": { + "name": "leads_budget_ck", + "value": "\"leads\".\"budget_ttc\" IS NULL OR \"leads\".\"budget_ttc\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.leave_adjustments": { + "name": "leave_adjustments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counter": { + "name": "counter", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "leave_adjustments_emp_idx": { + "name": "leave_adjustments_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "leave_adjustments_organization_id_organizations_id_fk": { + "name": "leave_adjustments_organization_id_organizations_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_adjustments_employee_id_employees_id_fk": { + "name": "leave_adjustments_employee_id_employees_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_adjustments_created_by_users_id_fk": { + "name": "leave_adjustments_created_by_users_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leave_adjustments_counter_ck": { + "name": "leave_adjustments_counter_ck", + "value": "\"leave_adjustments\".\"counter\" IN ('cp_n1', 'cp_n', 'rc')" + }, + "leave_adjustments_amount_ck": { + "name": "leave_adjustments_amount_ck", + "value": "\"leave_adjustments\".\"amount\" <> 0 AND abs(\"leave_adjustments\".\"amount\") <= 500" + } + }, + "isRLSEnabled": false + }, + "public.leave_settings": { + "name": "leave_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cp_unit": { + "name": "cp_unit", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvrables'" + }, + "overtime_as_rest": { + "name": "overtime_as_rest", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "leave_settings_establishment_id_establishments_id_fk": { + "name": "leave_settings_establishment_id_establishments_id_fk", + "tableFrom": "leave_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_settings_organization_id_organizations_id_fk": { + "name": "leave_settings_organization_id_organizations_id_fk", + "tableFrom": "leave_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_settings_updated_by_users_id_fk": { + "name": "leave_settings_updated_by_users_id_fk", + "tableFrom": "leave_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leave_settings_unit_ck": { + "name": "leave_settings_unit_ck", + "value": "\"leave_settings\".\"cp_unit\" IN ('ouvrables', 'ouvres')" + } + }, + "isRLSEnabled": false + }, + "public.logbook_entries": { + "name": "logbook_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "important": { + "name": "important", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "done_note": { + "name": "done_note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "logbook_entries_est_idx": { + "name": "logbook_entries_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "logbook_entries_organization_id_organizations_id_fk": { + "name": "logbook_entries_organization_id_organizations_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "logbook_entries_establishment_id_establishments_id_fk": { + "name": "logbook_entries_establishment_id_establishments_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "logbook_entries_author_id_users_id_fk": { + "name": "logbook_entries_author_id_users_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "logbook_entries_done_by_users_id_fk": { + "name": "logbook_entries_done_by_users_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "logbook_entries_category_ck": { + "name": "logbook_entries_category_ck", + "value": "\"logbook_entries\".\"category\" IN ('info', 'a_traiter', 'client', 'livraison', 'equipe')" + } + }, + "isRLSEnabled": false + }, + "public.logbook_reads": { + "name": "logbook_reads", + "schema": "", + "columns": { + "entry_id": { + "name": "entry_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "logbook_reads_entry_id_logbook_entries_id_fk": { + "name": "logbook_reads_entry_id_logbook_entries_id_fk", + "tableFrom": "logbook_reads", + "tableTo": "logbook_entries", + "columnsFrom": [ + "entry_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "logbook_reads_user_id_users_id_fk": { + "name": "logbook_reads_user_id_users_id_fk", + "tableFrom": "logbook_reads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "logbook_reads_entry_id_user_id_pk": { + "name": "logbook_reads_entry_id_user_id_pk", + "columns": [ + "entry_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.loyalty_events": { + "name": "loyalty_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visits": { + "name": "visits", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "loyalty_events_customer_idx": { + "name": "loyalty_events_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "loyalty_events_est_idx": { + "name": "loyalty_events_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "loyalty_events_organization_id_organizations_id_fk": { + "name": "loyalty_events_organization_id_organizations_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_establishment_id_establishments_id_fk": { + "name": "loyalty_events_establishment_id_establishments_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_customer_id_customers_id_fk": { + "name": "loyalty_events_customer_id_customers_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_created_by_users_id_fk": { + "name": "loyalty_events_created_by_users_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "loyalty_events_kind_ck": { + "name": "loyalty_events_kind_ck", + "value": "\"loyalty_events\".\"kind\" IN ('ajustement', 'recompense')" + }, + "loyalty_events_visits_ck": { + "name": "loyalty_events_visits_ck", + "value": "\"loyalty_events\".\"visits\" <> 0 AND (\"loyalty_events\".\"kind\" <> 'recompense' OR \"loyalty_events\".\"visits\" < 0)" + } + }, + "isRLSEnabled": false + }, + "public.loyalty_programs": { + "name": "loyalty_programs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "visits_per_reward": { + "name": "visits_per_reward", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reward_label": { + "name": "reward_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starts_on": { + "name": "starts_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "loyalty_programs_est_uq": { + "name": "loyalty_programs_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "loyalty_programs_org_idx": { + "name": "loyalty_programs_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "loyalty_programs_organization_id_organizations_id_fk": { + "name": "loyalty_programs_organization_id_organizations_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_programs_establishment_id_establishments_id_fk": { + "name": "loyalty_programs_establishment_id_establishments_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_programs_updated_by_users_id_fk": { + "name": "loyalty_programs_updated_by_users_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "loyalty_programs_visits_ck": { + "name": "loyalty_programs_visits_ck", + "value": "\"loyalty_programs\".\"visits_per_reward\" BETWEEN 2 AND 50" + } + }, + "isRLSEnabled": false + }, + "public.mail_accounts": { + "name": "mail_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gmail'" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'connected'" + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "cursor_ms": { + "name": "cursor_ms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_by": { + "name": "connected_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_accounts_email_uq": { + "name": "mail_accounts_email_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_accounts_organization_id_organizations_id_fk": { + "name": "mail_accounts_organization_id_organizations_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_accounts_establishment_id_establishments_id_fk": { + "name": "mail_accounts_establishment_id_establishments_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_accounts_connected_by_users_id_fk": { + "name": "mail_accounts_connected_by_users_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "users", + "columnsFrom": [ + "connected_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_accounts_provider_ck": { + "name": "mail_accounts_provider_ck", + "value": "\"mail_accounts\".\"provider\" IN ('gmail', 'outlook')" + }, + "mail_accounts_status_ck": { + "name": "mail_accounts_status_ck", + "value": "\"mail_accounts\".\"status\" IN ('connected', 'error', 'disabled')" + }, + "mail_accounts_failures_ck": { + "name": "mail_accounts_failures_ck", + "value": "\"mail_accounts\".\"consecutive_failures\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.mail_documents": { + "name": "mail_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "part_id": { + "name": "part_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_verifier'" + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "suggested_issue_id": { + "name": "suggested_issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "match_reason": { + "name": "match_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "business_document_id": { + "name": "business_document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "maintenance_invoice_id": { + "name": "maintenance_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_documents_part_uq": { + "name": "mail_documents_part_uq", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "part_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_documents_org_idx": { + "name": "mail_documents_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_documents_organization_id_organizations_id_fk": { + "name": "mail_documents_organization_id_organizations_id_fk", + "tableFrom": "mail_documents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_documents_message_id_mail_messages_id_fk": { + "name": "mail_documents_message_id_mail_messages_id_fk", + "tableFrom": "mail_documents", + "tableTo": "mail_messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_documents_establishment_id_establishments_id_fk": { + "name": "mail_documents_establishment_id_establishments_id_fk", + "tableFrom": "mail_documents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_supplier_id_suppliers_id_fk": { + "name": "mail_documents_supplier_id_suppliers_id_fk", + "tableFrom": "mail_documents", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_pennylane_record_id_pennylane_records_id_fk": { + "name": "mail_documents_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "mail_documents", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_suggested_issue_id_maintenance_issues_id_fk": { + "name": "mail_documents_suggested_issue_id_maintenance_issues_id_fk", + "tableFrom": "mail_documents", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "suggested_issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_business_document_id_business_documents_id_fk": { + "name": "mail_documents_business_document_id_business_documents_id_fk", + "tableFrom": "mail_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "business_document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_maintenance_invoice_id_maintenance_invoices_id_fk": { + "name": "mail_documents_maintenance_invoice_id_maintenance_invoices_id_fk", + "tableFrom": "mail_documents", + "tableTo": "maintenance_invoices", + "columnsFrom": [ + "maintenance_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_decided_by_users_id_fk": { + "name": "mail_documents_decided_by_users_id_fk", + "tableFrom": "mail_documents", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_documents_kind_ck": { + "name": "mail_documents_kind_ck", + "value": "\"mail_documents\".\"kind\" IN ('facture', 'devis', 'attestation', 'autre')" + }, + "mail_documents_status_ck": { + "name": "mail_documents_status_ck", + "value": "\"mail_documents\".\"status\" IN ('a_verifier', 'verifiee', 'classee', 'ignoree')" + }, + "mail_documents_size_ck": { + "name": "mail_documents_size_ck", + "value": "\"mail_documents\".\"size\" <= 4718592" + } + }, + "isRLSEnabled": false + }, + "public.mail_messages": { + "name": "mail_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_id": { + "name": "thread_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_email": { + "name": "from_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "to_text": { + "name": "to_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "attachment_count": { + "name": "attachment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_messages_ext_uq": { + "name": "mail_messages_ext_uq", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_messages_org_idx": { + "name": "mail_messages_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_messages_organization_id_organizations_id_fk": { + "name": "mail_messages_organization_id_organizations_id_fk", + "tableFrom": "mail_messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_messages_account_id_mail_accounts_id_fk": { + "name": "mail_messages_account_id_mail_accounts_id_fk", + "tableFrom": "mail_messages", + "tableTo": "mail_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_messages_category_ck": { + "name": "mail_messages_category_ck", + "value": "\"mail_messages\".\"category\" IN ('facture', 'devis', 'attestation', 'reservation', 'commande', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.mail_reply_drafts": { + "name": "mail_reply_drafts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_valider'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "outbox_id": { + "name": "outbox_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_reply_drafts_message_uq": { + "name": "mail_reply_drafts_message_uq", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_reply_drafts_org_idx": { + "name": "mail_reply_drafts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_reply_drafts_organization_id_organizations_id_fk": { + "name": "mail_reply_drafts_organization_id_organizations_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_account_id_mail_accounts_id_fk": { + "name": "mail_reply_drafts_account_id_mail_accounts_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_message_id_mail_messages_id_fk": { + "name": "mail_reply_drafts_message_id_mail_messages_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_template_id_mail_reply_templates_id_fk": { + "name": "mail_reply_drafts_template_id_mail_reply_templates_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_reply_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_reply_drafts_decided_by_users_id_fk": { + "name": "mail_reply_drafts_decided_by_users_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_reply_drafts_status_ck": { + "name": "mail_reply_drafts_status_ck", + "value": "\"mail_reply_drafts\".\"status\" IN ('a_valider', 'envoye', 'ecarte')" + } + }, + "isRLSEnabled": false + }, + "public.mail_reply_templates": { + "name": "mail_reply_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "mail_reply_templates_org_idx": { + "name": "mail_reply_templates_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_reply_templates_organization_id_organizations_id_fk": { + "name": "mail_reply_templates_organization_id_organizations_id_fk", + "tableFrom": "mail_reply_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_templates_created_by_users_id_fk": { + "name": "mail_reply_templates_created_by_users_id_fk", + "tableFrom": "mail_reply_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_reply_templates_category_ck": { + "name": "mail_reply_templates_category_ck", + "value": "\"mail_reply_templates\".\"category\" IN ('facture', 'devis', 'attestation', 'reservation', 'commande', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_interventions": { + "name": "maintenance_interventions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "performed_on": { + "name": "performed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cost_ht": { + "name": "cost_ht", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": false + }, + "invoice_ref": { + "name": "invoice_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_due_on": { + "name": "next_due_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_interventions_eq_idx": { + "name": "maintenance_interventions_eq_idx", + "columns": [ + { + "expression": "equipment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "performed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_interventions_organization_id_organizations_id_fk": { + "name": "maintenance_interventions_organization_id_organizations_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_interventions_establishment_id_establishments_id_fk": { + "name": "maintenance_interventions_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_equipment_id_equipment_id_fk": { + "name": "maintenance_interventions_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_interventions_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_recorded_by_users_id_fk": { + "name": "maintenance_interventions_recorded_by_users_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_interventions_cancelled_by_users_id_fk": { + "name": "maintenance_interventions_cancelled_by_users_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_interventions_kind_ck": { + "name": "maintenance_interventions_kind_ck", + "value": "\"maintenance_interventions\".\"kind\" IN ('preventive', 'curative', 'reglementaire')" + }, + "maintenance_interventions_cost_ck": { + "name": "maintenance_interventions_cost_ck", + "value": "\"maintenance_interventions\".\"cost_ht\" IS NULL OR \"maintenance_interventions\".\"cost_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_invoices": { + "name": "maintenance_invoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quote_id": { + "name": "quote_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'reparation'" + }, + "repairer": { + "name": "repairer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "document_mime": { + "name": "document_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_name": { + "name": "document_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "match_reason": { + "name": "match_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "linked_by": { + "name": "linked_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_invoices_est_idx": { + "name": "maintenance_invoices_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_invoices_issue_idx": { + "name": "maintenance_invoices_issue_idx", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_invoices_pennylane_uq": { + "name": "maintenance_invoices_pennylane_uq", + "columns": [ + { + "expression": "pennylane_record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"maintenance_invoices\".\"pennylane_record_id\" IS NOT NULL AND \"maintenance_invoices\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_invoices_organization_id_organizations_id_fk": { + "name": "maintenance_invoices_organization_id_organizations_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_invoices_establishment_id_establishments_id_fk": { + "name": "maintenance_invoices_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_equipment_id_equipment_id_fk": { + "name": "maintenance_invoices_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_invoices_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_quote_id_maintenance_quotes_id_fk": { + "name": "maintenance_invoices_quote_id_maintenance_quotes_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "maintenance_quotes", + "columnsFrom": [ + "quote_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_pennylane_record_id_pennylane_records_id_fk": { + "name": "maintenance_invoices_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_invoices_linked_by_users_id_fk": { + "name": "maintenance_invoices_linked_by_users_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "users", + "columnsFrom": [ + "linked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_invoices_cancelled_by_users_id_fk": { + "name": "maintenance_invoices_cancelled_by_users_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_invoices_source_ck": { + "name": "maintenance_invoices_source_ck", + "value": "\"maintenance_invoices\".\"source\" IN ('pennylane', 'document', 'saisie')" + }, + "maintenance_invoices_kind_ck": { + "name": "maintenance_invoices_kind_ck", + "value": "\"maintenance_invoices\".\"kind\" IN ('entretien', 'reparation', 'controle')" + }, + "maintenance_invoices_amount_ck": { + "name": "maintenance_invoices_amount_ck", + "value": "(\"maintenance_invoices\".\"amount_ht\" IS NOT NULL OR \"maintenance_invoices\".\"amount_ttc\" IS NOT NULL) AND (\"maintenance_invoices\".\"amount_ht\" IS NULL OR \"maintenance_invoices\".\"amount_ht\" >= 0) AND (\"maintenance_invoices\".\"amount_ttc\" IS NULL OR \"maintenance_invoices\".\"amount_ttc\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_issues": { + "name": "maintenance_issues", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "reported_by": { + "name": "reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reported_at": { + "name": "reported_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "resolved_at": { + "name": "resolved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "resolution": { + "name": "resolution", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_issues_est_idx": { + "name": "maintenance_issues_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_issues_organization_id_organizations_id_fk": { + "name": "maintenance_issues_organization_id_organizations_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_issues_establishment_id_establishments_id_fk": { + "name": "maintenance_issues_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_issues_equipment_id_equipment_id_fk": { + "name": "maintenance_issues_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_issues_reported_by_users_id_fk": { + "name": "maintenance_issues_reported_by_users_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "users", + "columnsFrom": [ + "reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_issues_resolved_by_users_id_fk": { + "name": "maintenance_issues_resolved_by_users_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "users", + "columnsFrom": [ + "resolved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_issues_severity_ck": { + "name": "maintenance_issues_severity_ck", + "value": "\"maintenance_issues\".\"severity\" IN ('bloquant', 'genant', 'mineur')" + }, + "maintenance_issues_status_ck": { + "name": "maintenance_issues_status_ck", + "value": "\"maintenance_issues\".\"status\" IN ('ouvert', 'en_cours', 'resolu')" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_quotes": { + "name": "maintenance_quotes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "repairer": { + "name": "repairer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quote_ref": { + "name": "quote_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "document_mime": { + "name": "document_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_name": { + "name": "document_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_valider'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_quotes_issue_idx": { + "name": "maintenance_quotes_issue_idx", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_quotes_est_idx": { + "name": "maintenance_quotes_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_quotes_one_valid_uq": { + "name": "maintenance_quotes_one_valid_uq", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"maintenance_quotes\".\"status\" = 'valide'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_quotes_organization_id_organizations_id_fk": { + "name": "maintenance_quotes_organization_id_organizations_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_quotes_establishment_id_establishments_id_fk": { + "name": "maintenance_quotes_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_quotes_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_quotes_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_quotes_decided_by_users_id_fk": { + "name": "maintenance_quotes_decided_by_users_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_quotes_created_by_users_id_fk": { + "name": "maintenance_quotes_created_by_users_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_quotes_status_ck": { + "name": "maintenance_quotes_status_ck", + "value": "\"maintenance_quotes\".\"status\" IN ('a_valider', 'valide', 'refuse')" + }, + "maintenance_quotes_amount_ck": { + "name": "maintenance_quotes_amount_ck", + "value": "(\"maintenance_quotes\".\"amount_ht\" IS NOT NULL OR \"maintenance_quotes\".\"amount_ttc\" IS NOT NULL) AND (\"maintenance_quotes\".\"amount_ht\" IS NULL OR \"maintenance_quotes\".\"amount_ht\" >= 0) AND (\"maintenance_quotes\".\"amount_ttc\" IS NULL OR \"maintenance_quotes\".\"amount_ttc\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.marketing_campaigns": { + "name": "marketing_campaigns", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "segment": { + "name": "segment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sms_text": { + "name": "sms_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "recipients_count": { + "name": "recipients_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "marketing_campaigns_org_idx": { + "name": "marketing_campaigns_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "marketing_campaigns_organization_id_organizations_id_fk": { + "name": "marketing_campaigns_organization_id_organizations_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "marketing_campaigns_establishment_id_establishments_id_fk": { + "name": "marketing_campaigns_establishment_id_establishments_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "marketing_campaigns_created_by_users_id_fk": { + "name": "marketing_campaigns_created_by_users_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "marketing_campaigns_status_ck": { + "name": "marketing_campaigns_status_ck", + "value": "\"marketing_campaigns\".\"status\" IN ('brouillon', 'envoyee')" + } + }, + "isRLSEnabled": false + }, + "public.media_assets": { + "name": "media_assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'upload'" + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_count": { + "name": "used_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "media_assets_org_idx": { + "name": "media_assets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_assets_recipe_idx": { + "name": "media_assets_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_assets_hash_uq": { + "name": "media_assets_hash_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "media_assets_organization_id_organizations_id_fk": { + "name": "media_assets_organization_id_organizations_id_fk", + "tableFrom": "media_assets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "media_assets_establishment_id_establishments_id_fk": { + "name": "media_assets_establishment_id_establishments_id_fk", + "tableFrom": "media_assets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "media_assets_recipe_id_recipes_id_fk": { + "name": "media_assets_recipe_id_recipes_id_fk", + "tableFrom": "media_assets", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "media_assets_created_by_users_id_fk": { + "name": "media_assets_created_by_users_id_fk", + "tableFrom": "media_assets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "media_assets_source_ck": { + "name": "media_assets_source_ck", + "value": "\"media_assets\".\"source\" IN ('upload', 'fiche', 'studio')" + }, + "media_assets_mime_ck": { + "name": "media_assets_mime_ck", + "value": "\"media_assets\".\"mime\" IN ('image/jpeg', 'image/png', 'image/webp')" + }, + "media_assets_size_ck": { + "name": "media_assets_size_ck", + "value": "\"media_assets\".\"size\" BETWEEN 1 AND 5242880" + }, + "media_assets_title_ck": { + "name": "media_assets_title_ck", + "value": "char_length(\"media_assets\".\"title\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + }, + "public.membership_establishments": { + "name": "membership_establishments", + "schema": "", + "columns": { + "membership_id": { + "name": "membership_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "membership_establishments_membership_id_memberships_id_fk": { + "name": "membership_establishments_membership_id_memberships_id_fk", + "tableFrom": "membership_establishments", + "tableTo": "memberships", + "columnsFrom": [ + "membership_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "membership_establishments_establishment_id_establishments_id_fk": { + "name": "membership_establishments_establishment_id_establishments_id_fk", + "tableFrom": "membership_establishments", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "membership_establishments_membership_id_establishment_id_pk": { + "name": "membership_establishments_membership_id_establishment_id_pk", + "columns": [ + "membership_id", + "establishment_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memberships": { + "name": "memberships", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "all_establishments": { + "name": "all_establishments", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "permissions_added": { + "name": "permissions_added", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "permissions_removed": { + "name": "permissions_removed", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "memberships_user_org_uq": { + "name": "memberships_user_org_uq", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memberships_user_id_users_id_fk": { + "name": "memberships_user_id_users_id_fk", + "tableFrom": "memberships", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memberships_organization_id_organizations_id_fk": { + "name": "memberships_organization_id_organizations_id_fk", + "tableFrom": "memberships", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "messages_conv_idx": { + "name": "messages_conv_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "messages_organization_id_organizations_id_fk": { + "name": "messages_organization_id_organizations_id_fk", + "tableFrom": "messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_conversation_id_conversations_id_fk": { + "name": "messages_conversation_id_conversations_id_fk", + "tableFrom": "messages", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_user_id_users_id_fk": { + "name": "messages_user_id_users_id_fk", + "tableFrom": "messages", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mfa_challenges": { + "name": "mfa_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mfa_challenges_user_idx": { + "name": "mfa_challenges_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mfa_challenges_user_id_users_id_fk": { + "name": "mfa_challenges_user_id_users_id_fk", + "tableFrom": "mfa_challenges", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.monthly_budgets": { + "name": "monthly_budgets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "month": { + "name": "month", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "revenue_ht": { + "name": "revenue_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "charges_ht": { + "name": "charges_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "food_cost_pct": { + "name": "food_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "beverage_cost_pct": { + "name": "beverage_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "labor_cost_pct": { + "name": "labor_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "monthly_budgets_est_month_uq": { + "name": "monthly_budgets_est_month_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "monthly_budgets_org_idx": { + "name": "monthly_budgets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "monthly_budgets_organization_id_organizations_id_fk": { + "name": "monthly_budgets_organization_id_organizations_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "monthly_budgets_establishment_id_establishments_id_fk": { + "name": "monthly_budgets_establishment_id_establishments_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "monthly_budgets_updated_by_users_id_fk": { + "name": "monthly_budgets_updated_by_users_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "monthly_budgets_month_ck": { + "name": "monthly_budgets_month_ck", + "value": "extract(day from \"monthly_budgets\".\"month\") = 1" + }, + "monthly_budgets_values_ck": { + "name": "monthly_budgets_values_ck", + "value": "(\"monthly_budgets\".\"revenue_ht\" IS NULL OR \"monthly_budgets\".\"revenue_ht\" >= 0) AND (\"monthly_budgets\".\"charges_ht\" IS NULL OR \"monthly_budgets\".\"charges_ht\" >= 0) AND (\"monthly_budgets\".\"covers\" IS NULL OR \"monthly_budgets\".\"covers\" >= 0)\n AND (\"monthly_budgets\".\"food_cost_pct\" IS NULL OR \"monthly_budgets\".\"food_cost_pct\" BETWEEN 0 AND 100) AND (\"monthly_budgets\".\"beverage_cost_pct\" IS NULL OR \"monthly_budgets\".\"beverage_cost_pct\" BETWEEN 0 AND 100) AND (\"monthly_budgets\".\"labor_cost_pct\" IS NULL OR \"monthly_budgets\".\"labor_cost_pct\" BETWEEN 0 AND 100)" + } + }, + "isRLSEnabled": false + }, + "public.notification_deliveries": { + "name": "notification_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "notification_id": { + "name": "notification_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_outbox_id": { + "name": "email_outbox_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "push_subscription_id": { + "name": "push_subscription_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_deliveries_org_idx": { + "name": "notification_deliveries_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_deliveries_user_idx": { + "name": "notification_deliveries_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_deliveries_pending_idx": { + "name": "notification_deliveries_pending_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_deliveries_organization_id_organizations_id_fk": { + "name": "notification_deliveries_organization_id_organizations_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_deliveries_user_id_users_id_fk": { + "name": "notification_deliveries_user_id_users_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_deliveries_notification_id_notifications_id_fk": { + "name": "notification_deliveries_notification_id_notifications_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "notifications", + "columnsFrom": [ + "notification_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "notification_deliveries_email_outbox_id_email_outbox_id_fk": { + "name": "notification_deliveries_email_outbox_id_email_outbox_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "email_outbox", + "columnsFrom": [ + "email_outbox_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "notification_deliveries_push_subscription_id_push_subscriptions_id_fk": { + "name": "notification_deliveries_push_subscription_id_push_subscriptions_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "push_subscriptions", + "columnsFrom": [ + "push_subscription_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_deliveries_channel_ck": { + "name": "notification_deliveries_channel_ck", + "value": "\"notification_deliveries\".\"channel\" IN ('in_app', 'email', 'push', 'sms')" + }, + "notification_deliveries_status_ck": { + "name": "notification_deliveries_status_ck", + "value": "\"notification_deliveries\".\"status\" IN ('envoye', 'en_attente', 'echec', 'simule', 'desactive', 'indisponible')" + } + }, + "isRLSEnabled": false + }, + "public.notification_preferences": { + "name": "notification_preferences", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notification_preferences_organization_id_organizations_id_fk": { + "name": "notification_preferences_organization_id_organizations_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_preferences_user_id_users_id_fk": { + "name": "notification_preferences_user_id_users_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "notification_preferences_organization_id_user_id_category_channel_pk": { + "name": "notification_preferences_organization_id_user_id_category_channel_pk", + "columns": [ + "organization_id", + "user_id", + "category", + "channel" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_preferences_channel_ck": { + "name": "notification_preferences_channel_ck", + "value": "\"notification_preferences\".\"channel\" IN ('in_app', 'email', 'push', 'sms')" + } + }, + "isRLSEnabled": false + }, + "public.notification_templates": { + "name": "notification_templates", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notification_templates_organization_id_organizations_id_fk": { + "name": "notification_templates_organization_id_organizations_id_fk", + "tableFrom": "notification_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_templates_updated_by_users_id_fk": { + "name": "notification_templates_updated_by_users_id_fk", + "tableFrom": "notification_templates", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "notification_templates_organization_id_category_channel_pk": { + "name": "notification_templates_organization_id_category_channel_pk", + "columns": [ + "organization_id", + "category", + "channel" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_templates_channel_ck": { + "name": "notification_templates_channel_ck", + "value": "\"notification_templates\".\"channel\" IN ('email', 'push', 'sms')" + } + }, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_user_idx": { + "name": "notifications_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_organization_id_organizations_id_fk": { + "name": "notifications_organization_id_organizations_id_fk", + "tableFrom": "notifications", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oil_checks": { + "name": "oil_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "polar_pct": { + "name": "polar_pct", + "type": "numeric(4, 1)", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "oil_checks_est_idx": { + "name": "oil_checks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oil_checks_organization_id_organizations_id_fk": { + "name": "oil_checks_organization_id_organizations_id_fk", + "tableFrom": "oil_checks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oil_checks_establishment_id_establishments_id_fk": { + "name": "oil_checks_establishment_id_establishments_id_fk", + "tableFrom": "oil_checks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "oil_checks_equipment_id_equipment_id_fk": { + "name": "oil_checks_equipment_id_equipment_id_fk", + "tableFrom": "oil_checks", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "oil_checks_recorded_by_users_id_fk": { + "name": "oil_checks_recorded_by_users_id_fk", + "tableFrom": "oil_checks", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "oil_checks_cancelled_by_users_id_fk": { + "name": "oil_checks_cancelled_by_users_id_fk", + "tableFrom": "oil_checks", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "oil_checks_kind_ck": { + "name": "oil_checks_kind_ck", + "value": "\"oil_checks\".\"kind\" IN ('controle', 'filtrage', 'changement')" + }, + "oil_checks_action_ck": { + "name": "oil_checks_action_ck", + "value": "\"oil_checks\".\"conform\" OR \"oil_checks\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.onboarding_items": { + "name": "onboarding_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "step_id": { + "name": "step_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "due_on": { + "name": "due_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "auto_check": { + "name": "auto_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "done_how": { + "name": "done_how", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_items_emp_idx": { + "name": "onboarding_items_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "onboarding_items_step_uq": { + "name": "onboarding_items_step_uq", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "step_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"onboarding_items\".\"step_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_items_organization_id_organizations_id_fk": { + "name": "onboarding_items_organization_id_organizations_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_items_employee_id_employees_id_fk": { + "name": "onboarding_items_employee_id_employees_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_items_step_id_onboarding_steps_id_fk": { + "name": "onboarding_items_step_id_onboarding_steps_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "onboarding_steps", + "columnsFrom": [ + "step_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "onboarding_items_done_by_users_id_fk": { + "name": "onboarding_items_done_by_users_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "onboarding_items_how_ck": { + "name": "onboarding_items_how_ck", + "value": "\"onboarding_items\".\"done_how\" IS NULL OR \"onboarding_items\".\"done_how\" IN ('manuel', 'auto')" + } + }, + "isRLSEnabled": false + }, + "public.onboarding_steps": { + "name": "onboarding_steps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "day_offset": { + "name": "day_offset", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "auto_check": { + "name": "auto_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_steps_org_idx": { + "name": "onboarding_steps_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_steps_organization_id_organizations_id_fk": { + "name": "onboarding_steps_organization_id_organizations_id_fk", + "tableFrom": "onboarding_steps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "onboarding_steps_offset_ck": { + "name": "onboarding_steps_offset_ck", + "value": "\"onboarding_steps\".\"day_offset\" BETWEEN -60 AND 365" + } + }, + "isRLSEnabled": false + }, + "public.organizations": { + "name": "organizations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_demo": { + "name": "is_demo", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "stock_valuation": { + "name": "stock_valuation", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'dernier_prix'" + }, + "require_mfa": { + "name": "require_mfa", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_via": { + "name": "created_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "onboarding_dismissed_at": { + "name": "onboarding_dismissed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "onboarding_skipped": { + "name": "onboarding_skipped", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "is_test": { + "name": "is_test", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "suspended_at": { + "name": "suspended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organizations_slug_unique": { + "name": "organizations_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": { + "organizations_stock_valuation_ck": { + "name": "organizations_stock_valuation_ck", + "value": "\"organizations\".\"stock_valuation\" IN ('dernier_prix', 'cump', 'fifo')" + }, + "organizations_demo_or_test_ck": { + "name": "organizations_demo_or_test_ck", + "value": "NOT (\"organizations\".\"is_demo\" AND \"organizations\".\"is_test\")" + } + }, + "isRLSEnabled": false + }, + "public.partner_booking_imports": { + "name": "partner_booking_imports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "partner": { + "name": "partner", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created": { + "name": "created", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated": { + "name": "updated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cancelled": { + "name": "cancelled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "unchanged": { + "name": "unchanged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skipped": { + "name": "skipped", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "notes": { + "name": "notes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "partner_booking_imports_est_idx": { + "name": "partner_booking_imports_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "partner_booking_imports_organization_id_organizations_id_fk": { + "name": "partner_booking_imports_organization_id_organizations_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "partner_booking_imports_establishment_id_establishments_id_fk": { + "name": "partner_booking_imports_establishment_id_establishments_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "partner_booking_imports_created_by_users_id_fk": { + "name": "partner_booking_imports_created_by_users_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "partner_booking_imports_partner_ck": { + "name": "partner_booking_imports_partner_ck", + "value": "\"partner_booking_imports\".\"partner\" IN ('thefork', 'opentable', 'google')" + }, + "partner_booking_imports_origin_ck": { + "name": "partner_booking_imports_origin_ck", + "value": "\"partner_booking_imports\".\"origin\" IN ('api', 'fichier', 'demo')" + } + }, + "isRLSEnabled": false + }, + "public.payroll_bonuses": { + "name": "payroll_bonuses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount_gross": { + "name": "amount_gross", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payroll_bonuses_est_date_idx": { + "name": "payroll_bonuses_est_date_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payroll_bonuses_org_idx": { + "name": "payroll_bonuses_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payroll_bonuses_organization_id_organizations_id_fk": { + "name": "payroll_bonuses_organization_id_organizations_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_establishment_id_establishments_id_fk": { + "name": "payroll_bonuses_establishment_id_establishments_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_employee_id_employees_id_fk": { + "name": "payroll_bonuses_employee_id_employees_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_created_by_users_id_fk": { + "name": "payroll_bonuses_created_by_users_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "payroll_bonuses_amount_ck": { + "name": "payroll_bonuses_amount_ck", + "value": "\"payroll_bonuses\".\"amount_gross\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.payroll_parameters": { + "name": "payroll_parameters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "effective_from": { + "name": "effective_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "employer_charge_pct": { + "name": "employer_charge_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "labor_alert_pct": { + "name": "labor_alert_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "source_note": { + "name": "source_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "min_productivity_ht": { + "name": "min_productivity_ht", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "meal_value": { + "name": "meal_value", + "type": "numeric(8, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payroll_parameters_est_from_uq": { + "name": "payroll_parameters_est_from_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payroll_parameters_org_idx": { + "name": "payroll_parameters_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payroll_parameters_organization_id_organizations_id_fk": { + "name": "payroll_parameters_organization_id_organizations_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_parameters_establishment_id_establishments_id_fk": { + "name": "payroll_parameters_establishment_id_establishments_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_parameters_created_by_users_id_fk": { + "name": "payroll_parameters_created_by_users_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "payroll_parameters_pct_ck": { + "name": "payroll_parameters_pct_ck", + "value": "(\"payroll_parameters\".\"employer_charge_pct\" IS NULL OR \"payroll_parameters\".\"employer_charge_pct\" BETWEEN 0 AND 100) AND (\"payroll_parameters\".\"labor_alert_pct\" IS NULL OR \"payroll_parameters\".\"labor_alert_pct\" BETWEEN 0 AND 100)" + }, + "payroll_parameters_prod_ck": { + "name": "payroll_parameters_prod_ck", + "value": "\"payroll_parameters\".\"min_productivity_ht\" IS NULL OR \"payroll_parameters\".\"min_productivity_ht\" > 0" + }, + "payroll_parameters_meal_ck": { + "name": "payroll_parameters_meal_ck", + "value": "\"payroll_parameters\".\"meal_value\" IS NULL OR \"payroll_parameters\".\"meal_value\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.pennylane_category_mappings": { + "name": "pennylane_category_mappings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category_key": { + "name": "category_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_category_mappings_uq": { + "name": "pennylane_category_mappings_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "category_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_category_mappings_organization_id_organizations_id_fk": { + "name": "pennylane_category_mappings_organization_id_organizations_id_fk", + "tableFrom": "pennylane_category_mappings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_category_mappings_updated_by_users_id_fk": { + "name": "pennylane_category_mappings_updated_by_users_id_fk", + "tableFrom": "pennylane_category_mappings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.pennylane_item_prices": { + "name": "pennylane_item_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "record_id": { + "name": "record_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "line_index": { + "name": "line_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_item_prices_line_uq": { + "name": "pennylane_item_prices_line_uq", + "columns": [ + { + "expression": "record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "line_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pennylane_item_prices_item_idx": { + "name": "pennylane_item_prices_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_item_prices_organization_id_organizations_id_fk": { + "name": "pennylane_item_prices_organization_id_organizations_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_establishment_id_establishments_id_fk": { + "name": "pennylane_item_prices_establishment_id_establishments_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_record_id_pennylane_records_id_fk": { + "name": "pennylane_item_prices_record_id_pennylane_records_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "pennylane_records", + "columnsFrom": [ + "record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_item_id_purchase_items_id_fk": { + "name": "pennylane_item_prices_item_id_purchase_items_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pennylane_item_prices_method_ck": { + "name": "pennylane_item_prices_method_ck", + "value": "\"pennylane_item_prices\".\"method\" IN ('confirme', 'reference', 'libelle')" + }, + "pennylane_item_prices_values_ck": { + "name": "pennylane_item_prices_values_ck", + "value": "\"pennylane_item_prices\".\"quantity\" > 0 AND \"pennylane_item_prices\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.pennylane_records": { + "name": "pennylane_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "third_party": { + "name": "third_party", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "remaining": { + "name": "remaining", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "payment_status": { + "name": "payment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unknown'" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tax": { + "name": "tax", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "bank_account_ref": { + "name": "bank_account_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "raw": { + "name": "raw", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "synced_at": { + "name": "synced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_records_uq": { + "name": "pennylane_records_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pennylane_records_date_idx": { + "name": "pennylane_records_date_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_records_organization_id_organizations_id_fk": { + "name": "pennylane_records_organization_id_organizations_id_fk", + "tableFrom": "pennylane_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_records_establishment_id_establishments_id_fk": { + "name": "pennylane_records_establishment_id_establishments_id_fk", + "tableFrom": "pennylane_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pennylane_records_kind_ck": { + "name": "pennylane_records_kind_ck", + "value": "\"pennylane_records\".\"kind\" IN ('supplier_invoice', 'customer_invoice', 'transaction', 'bank_account')" + } + }, + "isRLSEnabled": false + }, + "public.planning_absences": { + "name": "planning_absences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "part": { + "name": "part", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'journee'" + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_absences_uq": { + "name": "planning_absences_uq", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "part", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_absences_organization_id_organizations_id_fk": { + "name": "planning_absences_organization_id_organizations_id_fk", + "tableFrom": "planning_absences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_absences_employee_id_employees_id_fk": { + "name": "planning_absences_employee_id_employees_id_fk", + "tableFrom": "planning_absences", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_absences_created_by_users_id_fk": { + "name": "planning_absences_created_by_users_id_fk", + "tableFrom": "planning_absences", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_absences_part_ck": { + "name": "planning_absences_part_ck", + "value": "\"planning_absences\".\"part\" IN ('journee', 'matin', 'apres_midi')" + } + }, + "isRLSEnabled": false + }, + "public.planning_day_budgets": { + "name": "planning_day_budgets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "sales_ht": { + "name": "sales_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_day_budgets_uq": { + "name": "planning_day_budgets_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "planning_day_budgets_org_idx": { + "name": "planning_day_budgets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_day_budgets_organization_id_organizations_id_fk": { + "name": "planning_day_budgets_organization_id_organizations_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_budgets_establishment_id_establishments_id_fk": { + "name": "planning_day_budgets_establishment_id_establishments_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_budgets_updated_by_users_id_fk": { + "name": "planning_day_budgets_updated_by_users_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_day_budgets_ck": { + "name": "planning_day_budgets_ck", + "value": "\"planning_day_budgets\".\"sales_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.planning_day_notes": { + "name": "planning_day_notes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_day_notes_uq": { + "name": "planning_day_notes_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_day_notes_organization_id_organizations_id_fk": { + "name": "planning_day_notes_organization_id_organizations_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_notes_establishment_id_establishments_id_fk": { + "name": "planning_day_notes_establishment_id_establishments_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_notes_updated_by_users_id_fk": { + "name": "planning_day_notes_updated_by_users_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_day_notes_len_ck": { + "name": "planning_day_notes_len_ck", + "value": "char_length(\"planning_day_notes\".\"text\") BETWEEN 1 AND 500" + } + }, + "isRLSEnabled": false + }, + "public.planning_weeks": { + "name": "planning_weeks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "week_start": { + "name": "week_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_by": { + "name": "published_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "changed_at": { + "name": "changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sales_forecast_ht": { + "name": "sales_forecast_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "hours_budget": { + "name": "hours_budget", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": false + }, + "published_teams": { + "name": "published_teams", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "published_pdf": { + "name": "published_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_weeks_uq": { + "name": "planning_weeks_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "week_start", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_weeks_organization_id_organizations_id_fk": { + "name": "planning_weeks_organization_id_organizations_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_weeks_establishment_id_establishments_id_fk": { + "name": "planning_weeks_establishment_id_establishments_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_weeks_published_by_users_id_fk": { + "name": "planning_weeks_published_by_users_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "users", + "columnsFrom": [ + "published_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_settings": { + "name": "platform_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "default": 1 + }, + "signup_open": { + "name": "signup_open", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "mail_organization_id": { + "name": "mail_organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "vapid_public_key": { + "name": "vapid_public_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vapid_private_enc": { + "name": "vapid_private_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "platform_settings_mail_organization_id_organizations_id_fk": { + "name": "platform_settings_mail_organization_id_organizations_id_fk", + "tableFrom": "platform_settings", + "tableTo": "organizations", + "columnsFrom": [ + "mail_organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "platform_settings_updated_by_users_id_fk": { + "name": "platform_settings_updated_by_users_id_fk", + "tableFrom": "platform_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "platform_settings_single_ck": { + "name": "platform_settings_single_ck", + "value": "\"platform_settings\".\"id\" = 1" + } + }, + "isRLSEnabled": false + }, + "public.posting_records": { + "name": "posting_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "values": { + "name": "values", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installed_on": { + "name": "installed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_size": { + "name": "photo_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "validated_by_name": { + "name": "validated_by_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "posting_records_uq": { + "name": "posting_records_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "posting_records_org_idx": { + "name": "posting_records_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "posting_records_organization_id_organizations_id_fk": { + "name": "posting_records_organization_id_organizations_id_fk", + "tableFrom": "posting_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "posting_records_establishment_id_establishments_id_fk": { + "name": "posting_records_establishment_id_establishments_id_fk", + "tableFrom": "posting_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "posting_records_validated_by_users_id_fk": { + "name": "posting_records_validated_by_users_id_fk", + "tableFrom": "posting_records", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "posting_records_updated_by_users_id_fk": { + "name": "posting_records_updated_by_users_id_fk", + "tableFrom": "posting_records", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "posting_records_photo_ck": { + "name": "posting_records_photo_ck", + "value": "(\"posting_records\".\"photo\" IS NULL) = (\"posting_records\".\"photo_mime\" IS NULL) AND (\"posting_records\".\"photo\" IS NULL OR \"posting_records\".\"photo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + }, + "posting_records_validation_ck": { + "name": "posting_records_validation_ck", + "value": "(\"posting_records\".\"validated_at\" IS NULL) = (\"posting_records\".\"validated_by_name\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.price_request_lines": { + "name": "price_request_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "price_request_lines_item_uq": { + "name": "price_request_lines_item_uq", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_lines_organization_id_organizations_id_fk": { + "name": "price_request_lines_organization_id_organizations_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_lines_request_id_price_requests_id_fk": { + "name": "price_request_lines_request_id_price_requests_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "price_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_lines_item_id_purchase_items_id_fk": { + "name": "price_request_lines_item_id_purchase_items_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_lines_amount_ck": { + "name": "price_request_lines_amount_ck", + "value": "\"price_request_lines\".\"amount\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.price_request_offers": { + "name": "price_request_offers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_supplier_id": { + "name": "request_supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "line_id": { + "name": "line_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "awarded": { + "name": "awarded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_request_offers_uq": { + "name": "price_request_offers_uq", + "columns": [ + { + "expression": "request_supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "line_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_offers_organization_id_organizations_id_fk": { + "name": "price_request_offers_organization_id_organizations_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_offers_request_supplier_id_price_request_suppliers_id_fk": { + "name": "price_request_offers_request_supplier_id_price_request_suppliers_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "price_request_suppliers", + "columnsFrom": [ + "request_supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_offers_line_id_price_request_lines_id_fk": { + "name": "price_request_offers_line_id_price_request_lines_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "price_request_lines", + "columnsFrom": [ + "line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_offers_price_ck": { + "name": "price_request_offers_price_ck", + "value": "\"price_request_offers\".\"unit_price_ht\" IS NULL OR \"price_request_offers\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.price_request_suppliers": { + "name": "price_request_suppliers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emailed": { + "name": "emailed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "answered_at": { + "name": "answered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "answered_via": { + "name": "answered_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answered_name": { + "name": "answered_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answer_note": { + "name": "answer_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_request_suppliers_uq": { + "name": "price_request_suppliers_uq", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "price_request_suppliers_token_uq": { + "name": "price_request_suppliers_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_suppliers_organization_id_organizations_id_fk": { + "name": "price_request_suppliers_organization_id_organizations_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_suppliers_request_id_price_requests_id_fk": { + "name": "price_request_suppliers_request_id_price_requests_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "price_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_suppliers_supplier_id_suppliers_id_fk": { + "name": "price_request_suppliers_supplier_id_suppliers_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_suppliers_via_ck": { + "name": "price_request_suppliers_via_ck", + "value": "\"price_request_suppliers\".\"answered_via\" IS NULL OR \"price_request_suppliers\".\"answered_via\" IN ('en_ligne', 'saisie')" + } + }, + "isRLSEnabled": false + }, + "public.price_requests": { + "name": "price_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_by": { + "name": "reply_by", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "needed_by": { + "name": "needed_by", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "awarded_at": { + "name": "awarded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_requests_number_uq": { + "name": "price_requests_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "price_requests_est_idx": { + "name": "price_requests_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_requests_organization_id_organizations_id_fk": { + "name": "price_requests_organization_id_organizations_id_fk", + "tableFrom": "price_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_requests_establishment_id_establishments_id_fk": { + "name": "price_requests_establishment_id_establishments_id_fk", + "tableFrom": "price_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "price_requests_created_by_users_id_fk": { + "name": "price_requests_created_by_users_id_fk", + "tableFrom": "price_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_requests_status_ck": { + "name": "price_requests_status_ck", + "value": "\"price_requests\".\"status\" IN ('brouillon', 'envoyee', 'attribuee', 'annulee')" + } + }, + "isRLSEnabled": false + }, + "public.privacy_requests": { + "name": "privacy_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_kind": { + "name": "subject_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_label": { + "name": "subject_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_type": { + "name": "request_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "target_on": { + "name": "target_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'recue'" + }, + "responded_on": { + "name": "responded_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "handled_by": { + "name": "handled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "privacy_requests_org_idx": { + "name": "privacy_requests_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "privacy_requests_organization_id_organizations_id_fk": { + "name": "privacy_requests_organization_id_organizations_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "privacy_requests_establishment_id_establishments_id_fk": { + "name": "privacy_requests_establishment_id_establishments_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "privacy_requests_employee_id_employees_id_fk": { + "name": "privacy_requests_employee_id_employees_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_customer_id_customers_id_fk": { + "name": "privacy_requests_customer_id_customers_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_handled_by_users_id_fk": { + "name": "privacy_requests_handled_by_users_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "users", + "columnsFrom": [ + "handled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_created_by_users_id_fk": { + "name": "privacy_requests_created_by_users_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "privacy_requests_kind_ck": { + "name": "privacy_requests_kind_ck", + "value": "\"privacy_requests\".\"subject_kind\" IN ('salarie', 'client', 'autre')" + }, + "privacy_requests_type_ck": { + "name": "privacy_requests_type_ck", + "value": "\"privacy_requests\".\"request_type\" IN ('acces', 'rectification', 'effacement', 'opposition')" + }, + "privacy_requests_channel_ck": { + "name": "privacy_requests_channel_ck", + "value": "\"privacy_requests\".\"channel\" IN ('email', 'courrier', 'oral', 'sur_place', 'autre')" + }, + "privacy_requests_status_ck": { + "name": "privacy_requests_status_ck", + "value": "\"privacy_requests\".\"status\" IN ('recue', 'en_cours', 'traitee', 'refusee', 'sans_suite')" + }, + "privacy_requests_done_ck": { + "name": "privacy_requests_done_ck", + "value": "\"privacy_requests\".\"status\" NOT IN ('traitee', 'refusee') OR \"privacy_requests\".\"responded_on\" IS NOT NULL" + }, + "privacy_requests_refused_ck": { + "name": "privacy_requests_refused_ck", + "value": "\"privacy_requests\".\"status\" <> 'refusee' OR \"privacy_requests\".\"outcome\" IS NOT NULL" + }, + "privacy_requests_dates_ck": { + "name": "privacy_requests_dates_ck", + "value": "\"privacy_requests\".\"responded_on\" IS NULL OR \"privacy_requests\".\"responded_on\" >= \"privacy_requests\".\"received_on\"" + } + }, + "isRLSEnabled": false + }, + "public.product_temperatures": { + "name": "product_temperatures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_at": { + "name": "start_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "start_temp": { + "name": "start_temp", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": true + }, + "end_at": { + "name": "end_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "end_temp": { + "name": "end_temp", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "completed_by": { + "name": "completed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "product_temperatures_est_idx": { + "name": "product_temperatures_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "start_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "product_temperatures_organization_id_organizations_id_fk": { + "name": "product_temperatures_organization_id_organizations_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_temperatures_establishment_id_establishments_id_fk": { + "name": "product_temperatures_establishment_id_establishments_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "product_temperatures_recorded_by_users_id_fk": { + "name": "product_temperatures_recorded_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_temperatures_completed_by_users_id_fk": { + "name": "product_temperatures_completed_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "completed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_temperatures_cancelled_by_users_id_fk": { + "name": "product_temperatures_cancelled_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "product_temperatures_kind_ck": { + "name": "product_temperatures_kind_ck", + "value": "\"product_temperatures\".\"kind\" IN ('refroidissement', 'remise_en_temperature', 'coeur_chaud', 'coeur_froid')" + }, + "product_temperatures_status_ck": { + "name": "product_temperatures_status_ck", + "value": "\"product_temperatures\".\"status\" IN ('en_cours', 'termine')" + }, + "product_temperatures_action_ck": { + "name": "product_temperatures_action_ck", + "value": "\"product_temperatures\".\"conform\" IS NOT FALSE OR \"product_temperatures\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.purchase_control_settings": { + "name": "purchase_control_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rise_threshold_pct": { + "name": "rise_threshold_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "rise_window_days": { + "name": "rise_window_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "reception_tolerance_pct": { + "name": "reception_tolerance_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_control_settings_org_uq": { + "name": "purchase_control_settings_org_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_control_settings\".\"establishment_id\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_control_settings_est_uq": { + "name": "purchase_control_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_control_settings\".\"establishment_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_control_settings_organization_id_organizations_id_fk": { + "name": "purchase_control_settings_organization_id_organizations_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_control_settings_establishment_id_establishments_id_fk": { + "name": "purchase_control_settings_establishment_id_establishments_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_control_settings_updated_by_users_id_fk": { + "name": "purchase_control_settings_updated_by_users_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_control_settings_ck": { + "name": "purchase_control_settings_ck", + "value": "(\"purchase_control_settings\".\"rise_threshold_pct\" IS NULL OR (\"purchase_control_settings\".\"rise_threshold_pct\" > 0 AND \"purchase_control_settings\".\"rise_threshold_pct\" <= 100)) AND (\"purchase_control_settings\".\"rise_window_days\" IS NULL OR \"purchase_control_settings\".\"rise_window_days\" BETWEEN 7 AND 365) AND (\"purchase_control_settings\".\"reception_tolerance_pct\" IS NULL OR (\"purchase_control_settings\".\"reception_tolerance_pct\" >= 0 AND \"purchase_control_settings\".\"reception_tolerance_pct\" <= 50))" + } + }, + "isRLSEnabled": false + }, + "public.purchase_invoice_lines": { + "name": "purchase_invoice_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "line_ht": { + "name": "line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_lines_invoice_idx": { + "name": "purchase_lines_invoice_idx", + "columns": [ + { + "expression": "invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_lines_item_idx": { + "name": "purchase_lines_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_invoice_lines_organization_id_organizations_id_fk": { + "name": "purchase_invoice_lines_organization_id_organizations_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoice_lines_invoice_id_purchase_invoices_id_fk": { + "name": "purchase_invoice_lines_invoice_id_purchase_invoices_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoice_lines_item_id_purchase_items_id_fk": { + "name": "purchase_invoice_lines_item_id_purchase_items_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_lines_qty_ck": { + "name": "purchase_lines_qty_ck", + "value": "\"purchase_invoice_lines\".\"quantity\" > 0" + }, + "purchase_lines_price_ck": { + "name": "purchase_lines_price_ck", + "value": "\"purchase_invoice_lines\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.purchase_invoices": { + "name": "purchase_invoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'invoice'" + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_vat": { + "name": "total_vat", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "printed_ttc": { + "name": "printed_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "credit_request_id": { + "name": "credit_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paid_at": { + "name": "paid_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_invoices_period_idx": { + "name": "purchase_invoices_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_number_uq": { + "name": "purchase_invoices_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"invoice_number\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_credit_request_uq": { + "name": "purchase_invoices_credit_request_uq", + "columns": [ + { + "expression": "credit_request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL AND \"purchase_invoices\".\"credit_request_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_order_uq": { + "name": "purchase_invoices_order_uq", + "columns": [ + { + "expression": "purchase_order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL AND \"purchase_invoices\".\"kind\" = 'invoice' AND \"purchase_invoices\".\"purchase_order_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_invoices_organization_id_organizations_id_fk": { + "name": "purchase_invoices_organization_id_organizations_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoices_establishment_id_establishments_id_fk": { + "name": "purchase_invoices_establishment_id_establishments_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_supplier_id_suppliers_id_fk": { + "name": "purchase_invoices_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_purchase_order_id_purchase_orders_id_fk": { + "name": "purchase_invoices_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_credit_request_id_credit_requests_id_fk": { + "name": "purchase_invoices_credit_request_id_credit_requests_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "credit_requests", + "columnsFrom": [ + "credit_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_created_by_users_id_fk": { + "name": "purchase_invoices_created_by_users_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_invoices_cancelled_by_users_id_fk": { + "name": "purchase_invoices_cancelled_by_users_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_invoices_kind_ck": { + "name": "purchase_invoices_kind_ck", + "value": "\"purchase_invoices\".\"kind\" IN ('invoice', 'credit_note')" + }, + "purchase_invoices_ttc_ck": { + "name": "purchase_invoices_ttc_ck", + "value": "\"purchase_invoices\".\"total_ttc\" = \"purchase_invoices\".\"total_ht\" + \"purchase_invoices\".\"total_vat\"" + }, + "purchase_invoices_due_ck": { + "name": "purchase_invoices_due_ck", + "value": "\"purchase_invoices\".\"due_date\" IS NULL OR \"purchase_invoices\".\"due_date\" >= \"purchase_invoices\".\"invoice_date\"" + } + }, + "isRLSEnabled": false + }, + "public.purchase_items": { + "name": "purchase_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "storage_zone": { + "name": "storage_zone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "default_supplier_id": { + "name": "default_supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_ref": { + "name": "supplier_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "barcode": { + "name": "barcode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "catalog_price_ht": { + "name": "catalog_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "catalog_price_date": { + "name": "catalog_price_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "opened_shelf_life_days": { + "name": "opened_shelf_life_days", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_items_org_idx": { + "name": "purchase_items_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_items_org_name_unit_uq": { + "name": "purchase_items_org_name_unit_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "unit", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_items_org_barcode_uq": { + "name": "purchase_items_org_barcode_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "barcode", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_items\".\"barcode\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_items_organization_id_organizations_id_fk": { + "name": "purchase_items_organization_id_organizations_id_fk", + "tableFrom": "purchase_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_items_default_supplier_id_suppliers_id_fk": { + "name": "purchase_items_default_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_items", + "tableTo": "suppliers", + "columnsFrom": [ + "default_supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_items_opened_life_ck": { + "name": "purchase_items_opened_life_ck", + "value": "\"purchase_items\".\"opened_shelf_life_days\" IS NULL OR \"purchase_items\".\"opened_shelf_life_days\" BETWEEN 1 AND 60" + }, + "purchase_items_pack_ck": { + "name": "purchase_items_pack_ck", + "value": "\"purchase_items\".\"pack_size\" IS NULL OR \"purchase_items\".\"pack_size\" > 0" + }, + "purchase_items_catalog_ck": { + "name": "purchase_items_catalog_ck", + "value": "\"purchase_items\".\"catalog_price_ht\" IS NULL OR \"purchase_items\".\"catalog_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.purchase_order_groups": { + "name": "purchase_order_groups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expected_date": { + "name": "expected_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_order_groups_number_uq": { + "name": "purchase_order_groups_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_order_groups_organization_id_organizations_id_fk": { + "name": "purchase_order_groups_organization_id_organizations_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_groups_supplier_id_suppliers_id_fk": { + "name": "purchase_order_groups_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_order_groups_created_by_users_id_fk": { + "name": "purchase_order_groups_created_by_users_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_order_groups_status_ck": { + "name": "purchase_order_groups_status_ck", + "value": "\"purchase_order_groups\".\"status\" IN ('draft', 'sent', 'cancelled')" + } + }, + "isRLSEnabled": false + }, + "public.purchase_order_lines": { + "name": "purchase_order_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "packs": { + "name": "packs", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "line_ht": { + "name": "line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "received_quantity": { + "name": "received_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "received_unit_price_ht": { + "name": "received_unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "received_line_ht": { + "name": "received_line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "reception_note": { + "name": "reception_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_order_lines_order_idx": { + "name": "purchase_order_lines_order_idx", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_order_lines_item_uq": { + "name": "purchase_order_lines_item_uq", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_order_lines_organization_id_organizations_id_fk": { + "name": "purchase_order_lines_organization_id_organizations_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_lines_order_id_purchase_orders_id_fk": { + "name": "purchase_order_lines_order_id_purchase_orders_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "purchase_orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_lines_item_id_purchase_items_id_fk": { + "name": "purchase_order_lines_item_id_purchase_items_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_order_lines_qty_ck": { + "name": "purchase_order_lines_qty_ck", + "value": "\"purchase_order_lines\".\"quantity\" > 0 AND \"purchase_order_lines\".\"unit_price_ht\" >= 0 AND (\"purchase_order_lines\".\"received_quantity\" IS NULL OR \"purchase_order_lines\".\"received_quantity\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.purchase_orders": { + "name": "purchase_orders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "expected_date": { + "name": "expected_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines_ht": { + "name": "lines_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "delivery_fee_ht": { + "name": "delivery_fee_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "ordered_at": { + "name": "ordered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "received_date": { + "name": "received_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "received_time": { + "name": "received_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "delivery_note_number": { + "name": "delivery_note_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplier_gaps_ack_at": { + "name": "supplier_gaps_ack_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "supplier_gaps_ack_by": { + "name": "supplier_gaps_ack_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "received_ht": { + "name": "received_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "reception_comment": { + "name": "reception_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_by": { + "name": "received_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_request_id": { + "name": "price_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_orders_group_idx": { + "name": "purchase_orders_group_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_orders_est_idx": { + "name": "purchase_orders_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_orders_number_uq": { + "name": "purchase_orders_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_orders_organization_id_organizations_id_fk": { + "name": "purchase_orders_organization_id_organizations_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_orders_establishment_id_establishments_id_fk": { + "name": "purchase_orders_establishment_id_establishments_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_supplier_id_suppliers_id_fk": { + "name": "purchase_orders_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_supplier_gaps_ack_by_users_id_fk": { + "name": "purchase_orders_supplier_gaps_ack_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "supplier_gaps_ack_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_orders_received_by_users_id_fk": { + "name": "purchase_orders_received_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "received_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_orders_price_request_id_price_requests_id_fk": { + "name": "purchase_orders_price_request_id_price_requests_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "price_requests", + "columnsFrom": [ + "price_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_group_id_purchase_order_groups_id_fk": { + "name": "purchase_orders_group_id_purchase_order_groups_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "purchase_order_groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_created_by_users_id_fk": { + "name": "purchase_orders_created_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_orders_status_ck": { + "name": "purchase_orders_status_ck", + "value": "\"purchase_orders\".\"status\" IN ('draft', 'sent', 'confirmed', 'received', 'cancelled')" + }, + "purchase_orders_time_ck": { + "name": "purchase_orders_time_ck", + "value": "\"purchase_orders\".\"received_time\" IS NULL OR \"purchase_orders\".\"received_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + } + }, + "isRLSEnabled": false + }, + "public.push_subscriptions": { + "name": "push_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Appareil'" + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "push_subscriptions_endpoint_uq": { + "name": "push_subscriptions_endpoint_uq", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "push_subscriptions_user_idx": { + "name": "push_subscriptions_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "push_subscriptions_organization_id_organizations_id_fk": { + "name": "push_subscriptions_organization_id_organizations_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.quotes": { + "name": "quotes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_kind": { + "name": "event_kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_time": { + "name": "event_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "guests": { + "name": "guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "client_name": { + "name": "client_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_company": { + "name": "client_company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_email": { + "name": "client_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_phone": { + "name": "client_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_address": { + "name": "client_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "issued_on": { + "name": "issued_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_vat": { + "name": "total_vat", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "deposit_percent": { + "name": "deposit_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "deposit_amount": { + "name": "deposit_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "deposit_received_on": { + "name": "deposit_received_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "terms": { + "name": "terms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "viewed_at": { + "name": "viewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_name": { + "name": "accepted_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_via": { + "name": "accepted_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_meta": { + "name": "accepted_meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "refused_reason": { + "name": "refused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lead_id": { + "name": "lead_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "quotes_number_uq": { + "name": "quotes_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "quotes_token_uq": { + "name": "quotes_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"quotes\".\"token_hash\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "quotes_org_idx": { + "name": "quotes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "quotes_organization_id_organizations_id_fk": { + "name": "quotes_organization_id_organizations_id_fk", + "tableFrom": "quotes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "quotes_establishment_id_establishments_id_fk": { + "name": "quotes_establishment_id_establishments_id_fk", + "tableFrom": "quotes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "quotes_customer_id_customers_id_fk": { + "name": "quotes_customer_id_customers_id_fk", + "tableFrom": "quotes", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_reservation_id_reservations_id_fk": { + "name": "quotes_reservation_id_reservations_id_fk", + "tableFrom": "quotes", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_lead_id_leads_id_fk": { + "name": "quotes_lead_id_leads_id_fk", + "tableFrom": "quotes", + "tableTo": "leads", + "columnsFrom": [ + "lead_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_created_by_users_id_fk": { + "name": "quotes_created_by_users_id_fk", + "tableFrom": "quotes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "quotes_status_ck": { + "name": "quotes_status_ck", + "value": "\"quotes\".\"status\" IN ('brouillon', 'envoye', 'accepte', 'refuse', 'annule')" + }, + "quotes_valid_ck": { + "name": "quotes_valid_ck", + "value": "\"quotes\".\"valid_until\" >= \"quotes\".\"issued_on\"" + }, + "quotes_guests_ck": { + "name": "quotes_guests_ck", + "value": "\"quotes\".\"guests\" IS NULL OR \"quotes\".\"guests\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reception_control_lines": { + "name": "reception_control_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "control_id": { + "name": "control_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "stock_lot_id": { + "name": "stock_lot_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "packaging_ok": { + "name": "packaging_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "label_ok": { + "name": "label_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "reception_control_lines_ctl_idx": { + "name": "reception_control_lines_ctl_idx", + "columns": [ + { + "expression": "control_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reception_control_lines_organization_id_organizations_id_fk": { + "name": "reception_control_lines_organization_id_organizations_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_control_lines_control_id_reception_controls_id_fk": { + "name": "reception_control_lines_control_id_reception_controls_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "reception_controls", + "columnsFrom": [ + "control_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_control_lines_item_id_purchase_items_id_fk": { + "name": "reception_control_lines_item_id_purchase_items_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reception_control_lines_stock_lot_id_stock_expiry_lots_id_fk": { + "name": "reception_control_lines_stock_lot_id_stock_expiry_lots_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "stock_expiry_lots", + "columnsFrom": [ + "stock_lot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reception_controls": { + "name": "reception_controls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delivery_note": { + "name": "delivery_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "truck_temperature": { + "name": "truck_temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "vehicle_clean": { + "name": "vehicle_clean", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "decision": { + "name": "decision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reception_controls_est_idx": { + "name": "reception_controls_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reception_controls_organization_id_organizations_id_fk": { + "name": "reception_controls_organization_id_organizations_id_fk", + "tableFrom": "reception_controls", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_controls_establishment_id_establishments_id_fk": { + "name": "reception_controls_establishment_id_establishments_id_fk", + "tableFrom": "reception_controls", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reception_controls_supplier_id_suppliers_id_fk": { + "name": "reception_controls_supplier_id_suppliers_id_fk", + "tableFrom": "reception_controls", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reception_controls_purchase_order_id_purchase_orders_id_fk": { + "name": "reception_controls_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "reception_controls", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reception_controls_recorded_by_users_id_fk": { + "name": "reception_controls_recorded_by_users_id_fk", + "tableFrom": "reception_controls", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reception_controls_cancelled_by_users_id_fk": { + "name": "reception_controls_cancelled_by_users_id_fk", + "tableFrom": "reception_controls", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reception_controls_decision_ck": { + "name": "reception_controls_decision_ck", + "value": "\"reception_controls\".\"decision\" IN ('accepte', 'accepte_reserve', 'refuse')" + }, + "reception_controls_action_ck": { + "name": "reception_controls_action_ck", + "value": "\"reception_controls\".\"conform\" OR \"reception_controls\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.recipe_lines": { + "name": "recipe_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sub_recipe_id": { + "name": "sub_recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "waste_pct": { + "name": "waste_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_lines_recipe_idx": { + "name": "recipe_lines_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_lines_sub_idx": { + "name": "recipe_lines_sub_idx", + "columns": [ + { + "expression": "sub_recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_lines_organization_id_organizations_id_fk": { + "name": "recipe_lines_organization_id_organizations_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_lines_recipe_id_recipes_id_fk": { + "name": "recipe_lines_recipe_id_recipes_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_lines_item_id_purchase_items_id_fk": { + "name": "recipe_lines_item_id_purchase_items_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "recipe_lines_sub_recipe_id_recipes_id_fk": { + "name": "recipe_lines_sub_recipe_id_recipes_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "recipes", + "columnsFrom": [ + "sub_recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipe_lines_waste_ck": { + "name": "recipe_lines_waste_ck", + "value": "\"recipe_lines\".\"waste_pct\" IS NULL OR (\"recipe_lines\".\"waste_pct\" >= 0 AND \"recipe_lines\".\"waste_pct\" < 100)" + }, + "recipe_lines_qty_ck": { + "name": "recipe_lines_qty_ck", + "value": "\"recipe_lines\".\"quantity\" > 0" + }, + "recipe_lines_source_ck": { + "name": "recipe_lines_source_ck", + "value": "(\"recipe_lines\".\"item_id\" IS NULL) <> (\"recipe_lines\".\"sub_recipe_id\" IS NULL)" + }, + "recipe_lines_self_ck": { + "name": "recipe_lines_self_ck", + "value": "\"recipe_lines\".\"sub_recipe_id\" IS NULL OR \"recipe_lines\".\"sub_recipe_id\" <> \"recipe_lines\".\"recipe_id\"" + } + }, + "isRLSEnabled": false + }, + "public.recipe_versions": { + "name": "recipe_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "effective_from": { + "name": "effective_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "yield_quantity": { + "name": "yield_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "yield_unit": { + "name": "yield_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_versions_no_uq": { + "name": "recipe_versions_no_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_from_uq": { + "name": "recipe_versions_from_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_origin_uq": { + "name": "recipe_versions_origin_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"recipe_versions\".\"effective_from\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_org_idx": { + "name": "recipe_versions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_versions_organization_id_organizations_id_fk": { + "name": "recipe_versions_organization_id_organizations_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_versions_recipe_id_recipes_id_fk": { + "name": "recipe_versions_recipe_id_recipes_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_versions_created_by_users_id_fk": { + "name": "recipe_versions_created_by_users_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipe_versions_ck": { + "name": "recipe_versions_ck", + "value": "\"recipe_versions\".\"version\" >= 1 AND \"recipe_versions\".\"portions\" > 0 AND ((\"recipe_versions\".\"version\" = 1) = (\"recipe_versions\".\"effective_from\" IS NULL))" + } + }, + "isRLSEnabled": false + }, + "public.recipes": { + "name": "recipes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "course": { + "name": "course", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'plat'" + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'1'" + }, + "selling_price_ttc": { + "name": "selling_price_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.10'" + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "yield_quantity": { + "name": "yield_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "yield_unit": { + "name": "yield_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "target_margin_pct": { + "name": "target_margin_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "portion_weight_g": { + "name": "portion_weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "quality_tolerance_pct": { + "name": "quality_tolerance_pct", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "plating_standard": { + "name": "plating_standard", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "shelf_life_days": { + "name": "shelf_life_days", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "storage_note": { + "name": "storage_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipes_org_idx": { + "name": "recipes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipes_org_name_uq": { + "name": "recipes_org_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipes_organization_id_organizations_id_fk": { + "name": "recipes_organization_id_organizations_id_fk", + "tableFrom": "recipes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipes_created_by_users_id_fk": { + "name": "recipes_created_by_users_id_fk", + "tableFrom": "recipes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipes_shelf_life_ck": { + "name": "recipes_shelf_life_ck", + "value": "\"recipes\".\"shelf_life_days\" IS NULL OR \"recipes\".\"shelf_life_days\" BETWEEN 1 AND 90" + }, + "recipes_portions_ck": { + "name": "recipes_portions_ck", + "value": "\"recipes\".\"portions\" > 0" + }, + "recipes_yield_ck": { + "name": "recipes_yield_ck", + "value": "(\"recipes\".\"yield_quantity\" IS NULL AND \"recipes\".\"yield_unit\" IS NULL) OR (\"recipes\".\"yield_quantity\" > 0 AND \"recipes\".\"yield_unit\" IS NOT NULL)" + }, + "recipes_margin_ck": { + "name": "recipes_margin_ck", + "value": "\"recipes\".\"target_margin_pct\" IS NULL OR (\"recipes\".\"target_margin_pct\" >= 0 AND \"recipes\".\"target_margin_pct\" < 100)" + }, + "recipes_quality_ck": { + "name": "recipes_quality_ck", + "value": "(\"recipes\".\"portion_weight_g\" IS NULL OR \"recipes\".\"portion_weight_g\" BETWEEN 1 AND 20000) AND (\"recipes\".\"quality_tolerance_pct\" IS NULL OR \"recipes\".\"quality_tolerance_pct\" BETWEEN 1 AND 50)" + } + }, + "isRLSEnabled": false + }, + "public.recovery_codes": { + "name": "recovery_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recovery_codes_user_idx": { + "name": "recovery_codes_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recovery_codes_user_id_users_id_fk": { + "name": "recovery_codes_user_id_users_id_fk", + "tableFrom": "recovery_codes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.register_entries": { + "name": "register_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "topic": { + "name": "topic", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "organism": { + "name": "organism", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "performed_on": { + "name": "performed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "next_due_on": { + "name": "next_due_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "participants": { + "name": "participants", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "observations": { + "name": "observations", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'saisie'" + }, + "source_ref": { + "name": "source_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "register_entries_est_idx": { + "name": "register_entries_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "performed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "register_entries_source_uq": { + "name": "register_entries_source_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"register_entries\".\"source_ref\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "register_entries_organization_id_organizations_id_fk": { + "name": "register_entries_organization_id_organizations_id_fk", + "tableFrom": "register_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "register_entries_establishment_id_establishments_id_fk": { + "name": "register_entries_establishment_id_establishments_id_fk", + "tableFrom": "register_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "register_entries_employee_id_employees_id_fk": { + "name": "register_entries_employee_id_employees_id_fk", + "tableFrom": "register_entries", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_supplier_id_suppliers_id_fk": { + "name": "register_entries_supplier_id_suppliers_id_fk", + "tableFrom": "register_entries", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_document_id_business_documents_id_fk": { + "name": "register_entries_document_id_business_documents_id_fk", + "tableFrom": "register_entries", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_created_by_users_id_fk": { + "name": "register_entries_created_by_users_id_fk", + "tableFrom": "register_entries", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "register_entries_cancelled_by_users_id_fk": { + "name": "register_entries_cancelled_by_users_id_fk", + "tableFrom": "register_entries", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "register_entries_kind_ck": { + "name": "register_entries_kind_ck", + "value": "\"register_entries\".\"kind\" IN ('epi', 'exercice_incendie', 'controle', 'vigilance')" + }, + "register_entries_result_ck": { + "name": "register_entries_result_ck", + "value": "\"register_entries\".\"result\" IS NULL OR \"register_entries\".\"result\" IN ('conforme', 'reserves', 'non_conforme')" + }, + "register_entries_source_ck": { + "name": "register_entries_source_ck", + "value": "\"register_entries\".\"source\" IN ('saisie', 'document')" + }, + "register_entries_due_ck": { + "name": "register_entries_due_ck", + "value": "\"register_entries\".\"next_due_on\" IS NULL OR \"register_entries\".\"next_due_on\" >= \"register_entries\".\"performed_on\"" + }, + "register_entries_counts_ck": { + "name": "register_entries_counts_ck", + "value": "(\"register_entries\".\"quantity\" IS NULL OR \"register_entries\".\"quantity\" BETWEEN 1 AND 1000) AND (\"register_entries\".\"participants\" IS NULL OR \"register_entries\".\"participants\" BETWEEN 0 AND 10000) AND (\"register_entries\".\"duration_minutes\" IS NULL OR \"register_entries\".\"duration_minutes\" BETWEEN 1 AND 1440)" + }, + "register_entries_cancel_ck": { + "name": "register_entries_cancel_ck", + "value": "\"register_entries\".\"cancelled_at\" IS NULL OR (\"register_entries\".\"cancelled_by\" IS NOT NULL AND \"register_entries\".\"cancel_reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.regulatory_obligations": { + "name": "regulatory_obligations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "applicability": { + "name": "applicability", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source_status": { + "name": "source_status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_reference": { + "name": "source_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference_origin": { + "name": "reference_origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "catalogued_on": { + "name": "catalogued_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "verified_at": { + "name": "verified_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "validation_status": { + "name": "validation_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'non_validee'" + }, + "validator_name": { + "name": "validator_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validator_quality": { + "name": "validator_quality", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validated_on": { + "name": "validated_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "legal_delay_text": { + "name": "legal_delay_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hr_check": { + "name": "hr_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "regulatory_obligations_code_uq": { + "name": "regulatory_obligations_code_uq", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "regulatory_obligations_domain_ck": { + "name": "regulatory_obligations_domain_ck", + "value": "\"regulatory_obligations\".\"domain\" IN ('hygiene', 'social', 'securite', 'fiscal', 'affichage', 'licences', 'consommateurs', 'environnement', 'donnees_personnelles')" + }, + "regulatory_obligations_source_ck": { + "name": "regulatory_obligations_source_ck", + "value": "\"regulatory_obligations\".\"source_status\" IN ('documentee', 'a_documenter') AND (\"regulatory_obligations\".\"source_status\" = 'a_documenter' OR \"regulatory_obligations\".\"source_reference\" IS NOT NULL)" + }, + "regulatory_obligations_validation_ck": { + "name": "regulatory_obligations_validation_ck", + "value": "\"regulatory_obligations\".\"validation_status\" IN ('non_validee', 'validee_par_professionnel') AND (\"regulatory_obligations\".\"validation_status\" = 'non_validee' OR (\"regulatory_obligations\".\"validator_name\" IS NOT NULL AND \"regulatory_obligations\".\"validator_quality\" IS NOT NULL AND \"regulatory_obligations\".\"validated_on\" IS NOT NULL))" + }, + "regulatory_obligations_active_ck": { + "name": "regulatory_obligations_active_ck", + "value": "NOT \"regulatory_obligations\".\"active\" OR (\"regulatory_obligations\".\"validation_status\" = 'validee_par_professionnel' AND \"regulatory_obligations\".\"source_status\" = 'documentee' AND \"regulatory_obligations\".\"source_url\" IS NOT NULL AND \"regulatory_obligations\".\"verified_at\" IS NOT NULL)" + }, + "regulatory_obligations_hr_ck": { + "name": "regulatory_obligations_hr_ck", + "value": "\"regulatory_obligations\".\"hr_check\" IS NULL OR \"regulatory_obligations\".\"hr_check\" IN ('work_permit', 'medical_visit', 'dpae')" + } + }, + "isRLSEnabled": false + }, + "public.report_schedules": { + "name": "report_schedules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gestion'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Rapport de gestion'" + }, + "send_time": { + "name": "send_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'07:00'" + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "attach_pdf": { + "name": "attach_pdf", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notify_in_app": { + "name": "notify_in_app", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "recipients": { + "name": "recipients", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "last_period_from": { + "name": "last_period_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "last_sent_at": { + "name": "last_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "indicators": { + "name": "indicators", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "send_condition": { + "name": "send_condition", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "report_schedules_org_idx": { + "name": "report_schedules_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "report_schedules_organization_id_organizations_id_fk": { + "name": "report_schedules_organization_id_organizations_id_fk", + "tableFrom": "report_schedules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_schedules_establishment_id_establishments_id_fk": { + "name": "report_schedules_establishment_id_establishments_id_fk", + "tableFrom": "report_schedules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_schedules_created_by_users_id_fk": { + "name": "report_schedules_created_by_users_id_fk", + "tableFrom": "report_schedules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "report_schedules_audience_ck": { + "name": "report_schedules_audience_ck", + "value": "\"report_schedules\".\"audience\" IS NULL OR \"report_schedules\".\"audience\" IN ('proprietaire', 'direction', 'comptable', 'equipe', 'cuisine')" + }, + "report_schedules_freq_ck": { + "name": "report_schedules_freq_ck", + "value": "\"report_schedules\".\"frequency\" IN ('daily', 'weekly', 'monthly')" + }, + "report_schedules_time_ck": { + "name": "report_schedules_time_ck", + "value": "\"report_schedules\".\"send_time\" ~ '^(0[5-9]|1[0-9]|2[0-2]):(00|15|30|45)$'" + }, + "report_schedules_days_ck": { + "name": "report_schedules_days_ck", + "value": "\"report_schedules\".\"frequency\" <> 'daily' OR (CASE WHEN jsonb_typeof(\"report_schedules\".\"weekdays\") = 'array' THEN jsonb_array_length(\"report_schedules\".\"weekdays\") >= 1 ELSE false END)" + }, + "report_schedules_kind_ck": { + "name": "report_schedules_kind_ck", + "value": "\"report_schedules\".\"kind\" IN ('gestion', 'fermeture', 'groupe')" + }, + "report_schedules_closing_ck": { + "name": "report_schedules_closing_ck", + "value": "\"report_schedules\".\"kind\" <> 'fermeture' OR (\"report_schedules\".\"frequency\" = 'daily' AND \"report_schedules\".\"establishment_id\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.reputation_policies": { + "name": "reputation_policies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "levels": { + "name": "levels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "forbidden_words": { + "name": "forbidden_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "email_alerts": { + "name": "email_alerts", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "escalate_to": { + "name": "escalate_to", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reputation_policies_org_uq": { + "name": "reputation_policies_org_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reputation_policies\".\"establishment_id\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "reputation_policies_est_uq": { + "name": "reputation_policies_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reputation_policies\".\"establishment_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reputation_policies_organization_id_organizations_id_fk": { + "name": "reputation_policies_organization_id_organizations_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_policies_establishment_id_establishments_id_fk": { + "name": "reputation_policies_establishment_id_establishments_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_policies_escalate_to_users_id_fk": { + "name": "reputation_policies_escalate_to_users_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "users", + "columnsFrom": [ + "escalate_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reputation_policies_updated_by_users_id_fk": { + "name": "reputation_policies_updated_by_users_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reputation_policies_tone_ck": { + "name": "reputation_policies_tone_ck", + "value": "\"reputation_policies\".\"tone\" IS NULL OR \"reputation_policies\".\"tone\" IN ('formel', 'chaleureux', 'sobre')" + }, + "reputation_policies_lang_ck": { + "name": "reputation_policies_lang_ck", + "value": "\"reputation_policies\".\"language\" IS NULL OR \"reputation_policies\".\"language\" IN ('fr', 'en')" + } + }, + "isRLSEnabled": false + }, + "public.reputation_settings": { + "name": "reputation_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "review_url": { + "name": "review_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signature": { + "name": "signature", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reputation_settings_establishment_id_establishments_id_fk": { + "name": "reputation_settings_establishment_id_establishments_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_settings_organization_id_organizations_id_fk": { + "name": "reputation_settings_organization_id_organizations_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_settings_updated_by_users_id_fk": { + "name": "reputation_settings_updated_by_users_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reservation_exceptions": { + "name": "reservation_exceptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "service_id": { + "name": "service_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed": { + "name": "closed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "service_capacity": { + "name": "service_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_exceptions_day_idx": { + "name": "reservation_exceptions_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_exceptions_organization_id_organizations_id_fk": { + "name": "reservation_exceptions_organization_id_organizations_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_exceptions_establishment_id_establishments_id_fk": { + "name": "reservation_exceptions_establishment_id_establishments_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservation_exceptions_service_id_reservation_services_id_fk": { + "name": "reservation_exceptions_service_id_reservation_services_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "reservation_services", + "columnsFrom": [ + "service_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_exceptions_created_by_users_id_fk": { + "name": "reservation_exceptions_created_by_users_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_exceptions_cap_ck": { + "name": "reservation_exceptions_cap_ck", + "value": "\"reservation_exceptions\".\"closed\" OR \"reservation_exceptions\".\"service_capacity\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reservation_services": { + "name": "reservation_services", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "first_time": { + "name": "first_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_time": { + "name": "last_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slot_minutes": { + "name": "slot_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "slot_capacity": { + "name": "slot_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "service_capacity": { + "name": "service_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_services_est_idx": { + "name": "reservation_services_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_services_organization_id_organizations_id_fk": { + "name": "reservation_services_organization_id_organizations_id_fk", + "tableFrom": "reservation_services", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_services_establishment_id_establishments_id_fk": { + "name": "reservation_services_establishment_id_establishments_id_fk", + "tableFrom": "reservation_services", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_services_time_ck": { + "name": "reservation_services_time_ck", + "value": "\"reservation_services\".\"first_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_services\".\"last_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "reservation_services_slot_ck": { + "name": "reservation_services_slot_ck", + "value": "\"reservation_services\".\"slot_minutes\" IN (15, 30, 60) AND \"reservation_services\".\"duration_minutes\" BETWEEN 15 AND 720" + }, + "reservation_services_cap_ck": { + "name": "reservation_services_cap_ck", + "value": "(\"reservation_services\".\"slot_capacity\" IS NULL OR \"reservation_services\".\"slot_capacity\" > 0) AND (\"reservation_services\".\"service_capacity\" IS NULL OR \"reservation_services\".\"service_capacity\" > 0)" + } + }, + "isRLSEnabled": false + }, + "public.reservation_settings": { + "name": "reservation_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reminder_email": { + "name": "reminder_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reminder_hour": { + "name": "reminder_hour", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "online_enabled": { + "name": "online_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "online_token": { + "name": "online_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "online_by": { + "name": "online_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "online_max_covers": { + "name": "online_max_covers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 8 + }, + "waitlist_auto_offer": { + "name": "waitlist_auto_offer", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "online_auto_confirm": { + "name": "online_auto_confirm", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "online_lead_minutes": { + "name": "online_lead_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "online_days": { + "name": "online_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 60 + }, + "online_message": { + "name": "online_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "online_groups": { + "name": "online_groups", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "self_cancel_enabled": { + "name": "self_cancel_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "self_cancel_minutes": { + "name": "self_cancel_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_settings_online_token_uq": { + "name": "reservation_settings_online_token_uq", + "columns": [ + { + "expression": "online_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_settings_establishment_id_establishments_id_fk": { + "name": "reservation_settings_establishment_id_establishments_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_settings_organization_id_organizations_id_fk": { + "name": "reservation_settings_organization_id_organizations_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_settings_online_by_users_id_fk": { + "name": "reservation_settings_online_by_users_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "users", + "columnsFrom": [ + "online_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_settings_hour_ck": { + "name": "reservation_settings_hour_ck", + "value": "\"reservation_settings\".\"reminder_hour\" BETWEEN 7 AND 21" + }, + "reservation_settings_online_ck": { + "name": "reservation_settings_online_ck", + "value": "\"reservation_settings\".\"online_max_covers\" BETWEEN 1 AND 50 AND \"reservation_settings\".\"online_lead_minutes\" BETWEEN 0 AND 2880 AND \"reservation_settings\".\"online_days\" BETWEEN 1 AND 365" + }, + "reservation_settings_self_cancel_ck": { + "name": "reservation_settings_self_cancel_ck", + "value": "\"reservation_settings\".\"self_cancel_minutes\" BETWEEN 0 AND 10080" + } + }, + "isRLSEnabled": false + }, + "public.reservation_tables": { + "name": "reservation_tables", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "starts_at": { + "name": "starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ends_at": { + "name": "ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "released_at": { + "name": "released_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_tables_res_idx": { + "name": "reservation_tables_res_idx", + "columns": [ + { + "expression": "reservation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservation_tables_table_idx": { + "name": "reservation_tables_table_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "starts_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_tables_organization_id_organizations_id_fk": { + "name": "reservation_tables_organization_id_organizations_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_tables_establishment_id_establishments_id_fk": { + "name": "reservation_tables_establishment_id_establishments_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservation_tables_reservation_id_reservations_id_fk": { + "name": "reservation_tables_reservation_id_reservations_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_tables_table_id_floor_items_id_fk": { + "name": "reservation_tables_table_id_floor_items_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "floor_items", + "columnsFrom": [ + "table_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_tables_range_ck": { + "name": "reservation_tables_range_ck", + "value": "\"reservation_tables\".\"ends_at\" > \"reservation_tables\".\"starts_at\"" + } + }, + "isRLSEnabled": false + }, + "public.reservation_waitlist": { + "name": "reservation_waitlist", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "time_from": { + "name": "time_from", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "time_to": { + "name": "time_to", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "offered_at": { + "name": "offered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "offered_from_reservation_id": { + "name": "offered_from_reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "offered_time": { + "name": "offered_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "close_reason": { + "name": "close_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_waitlist_day_idx": { + "name": "reservation_waitlist_day_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_waitlist_organization_id_organizations_id_fk": { + "name": "reservation_waitlist_organization_id_organizations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_waitlist_establishment_id_establishments_id_fk": { + "name": "reservation_waitlist_establishment_id_establishments_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_waitlist_offered_from_reservation_id_reservations_id_fk": { + "name": "reservation_waitlist_offered_from_reservation_id_reservations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "reservations", + "columnsFrom": [ + "offered_from_reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservation_waitlist_reservation_id_reservations_id_fk": { + "name": "reservation_waitlist_reservation_id_reservations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservation_waitlist_created_by_users_id_fk": { + "name": "reservation_waitlist_created_by_users_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_waitlist_status_ck": { + "name": "reservation_waitlist_status_ck", + "value": "\"reservation_waitlist\".\"status\" IN ('en_attente', 'proposee', 'convertie', 'annulee')" + }, + "reservation_waitlist_covers_ck": { + "name": "reservation_waitlist_covers_ck", + "value": "\"reservation_waitlist\".\"covers\" BETWEEN 1 AND 500" + }, + "reservation_waitlist_time_ck": { + "name": "reservation_waitlist_time_ck", + "value": "\"reservation_waitlist\".\"time_from\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_waitlist\".\"time_to\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_waitlist\".\"time_to\" >= \"reservation_waitlist\".\"time_from\"" + }, + "reservation_waitlist_contact_ck": { + "name": "reservation_waitlist_contact_ck", + "value": "\"reservation_waitlist\".\"phone\" IS NOT NULL OR \"reservation_waitlist\".\"email\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.reservations": { + "name": "reservations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "service_id": { + "name": "service_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "time": { + "name": "time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starts_at": { + "name": "starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ends_at": { + "name": "ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'confirmee'" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'telephone'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request": { + "name": "request", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "arrived_at": { + "name": "arrived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "confirmation_sent_at": { + "name": "confirmation_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reminder_sent_at": { + "name": "reminder_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "external_ref": { + "name": "external_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manage_token": { + "name": "manage_token", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "replace(gen_random_uuid()::text, '-', '') || replace(gen_random_uuid()::text, '-', '')" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservations_day_idx": { + "name": "reservations_day_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_customer_idx": { + "name": "reservations_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_manage_token_uq": { + "name": "reservations_manage_token_uq", + "columns": [ + { + "expression": "manage_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_external_ref_uq": { + "name": "reservations_external_ref_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reservations\".\"external_ref\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservations_organization_id_organizations_id_fk": { + "name": "reservations_organization_id_organizations_id_fk", + "tableFrom": "reservations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservations_establishment_id_establishments_id_fk": { + "name": "reservations_establishment_id_establishments_id_fk", + "tableFrom": "reservations", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservations_service_id_reservation_services_id_fk": { + "name": "reservations_service_id_reservation_services_id_fk", + "tableFrom": "reservations", + "tableTo": "reservation_services", + "columnsFrom": [ + "service_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservations_customer_id_customers_id_fk": { + "name": "reservations_customer_id_customers_id_fk", + "tableFrom": "reservations", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservations_created_by_users_id_fk": { + "name": "reservations_created_by_users_id_fk", + "tableFrom": "reservations", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservations_status_ck": { + "name": "reservations_status_ck", + "value": "\"reservations\".\"status\" IN ('en_attente', 'confirmee', 'arrivee', 'terminee', 'no_show', 'annulee')" + }, + "reservations_covers_ck": { + "name": "reservations_covers_ck", + "value": "\"reservations\".\"covers\" BETWEEN 1 AND 500" + }, + "reservations_time_ck": { + "name": "reservations_time_ck", + "value": "\"reservations\".\"time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservations\".\"ends_at\" > \"reservations\".\"starts_at\"" + } + }, + "isRLSEnabled": false + }, + "public.review_autopublish": { + "name": "review_autopublish", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "levels": { + "name": "levels", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled_by": { + "name": "enabled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "enabled_at": { + "name": "enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmation": { + "name": "confirmation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "review_autopublish_establishment_id_establishments_id_fk": { + "name": "review_autopublish_establishment_id_establishments_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_autopublish_organization_id_organizations_id_fk": { + "name": "review_autopublish_organization_id_organizations_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_autopublish_enabled_by_users_id_fk": { + "name": "review_autopublish_enabled_by_users_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "users", + "columnsFrom": [ + "enabled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "review_autopublish_updated_by_users_id_fk": { + "name": "review_autopublish_updated_by_users_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.review_publications": { + "name": "review_publications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "review_id": { + "name": "review_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blocked_words": { + "name": "blocked_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "google_reply_state": { + "name": "google_reply_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "review_publications_review_uq": { + "name": "review_publications_review_uq", + "columns": [ + { + "expression": "review_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "review_publications_due_idx": { + "name": "review_publications_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "review_publications_organization_id_organizations_id_fk": { + "name": "review_publications_organization_id_organizations_id_fk", + "tableFrom": "review_publications", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_publications_establishment_id_establishments_id_fk": { + "name": "review_publications_establishment_id_establishments_id_fk", + "tableFrom": "review_publications", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_publications_review_id_reviews_id_fk": { + "name": "review_publications_review_id_reviews_id_fk", + "tableFrom": "review_publications", + "tableTo": "reviews", + "columnsFrom": [ + "review_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "review_publications_status_ck": { + "name": "review_publications_status_ck", + "value": "\"review_publications\".\"status\" IN ('scheduled', 'publishing', 'published', 'failed', 'blocked', 'cancelled', 'skipped')" + } + }, + "isRLSEnabled": false + }, + "public.reviews": { + "name": "reviews", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reviewed_on": { + "name": "reviewed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fingerprint": { + "name": "fingerprint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_text": { + "name": "reply_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "replied_at": { + "name": "replied_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "replied_by": { + "name": "replied_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assigned_to": { + "name": "assigned_to", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "assigned_by": { + "name": "assigned_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rule_action": { + "name": "rule_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "alerted_at": { + "name": "alerted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_name": { + "name": "external_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_updated_at": { + "name": "external_updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reply_origin": { + "name": "reply_origin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reviews_fingerprint_uq": { + "name": "reviews_fingerprint_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "fingerprint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_external_uq": { + "name": "reviews_external_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reviews\".\"external_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_est_day_idx": { + "name": "reviews_est_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reviewed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_assigned_idx": { + "name": "reviews_assigned_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "assigned_to", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"reviews\".\"assigned_to\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reviews_organization_id_organizations_id_fk": { + "name": "reviews_organization_id_organizations_id_fk", + "tableFrom": "reviews", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reviews_establishment_id_establishments_id_fk": { + "name": "reviews_establishment_id_establishments_id_fk", + "tableFrom": "reviews", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reviews_replied_by_users_id_fk": { + "name": "reviews_replied_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "replied_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reviews_assigned_to_users_id_fk": { + "name": "reviews_assigned_to_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "assigned_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reviews_assigned_by_users_id_fk": { + "name": "reviews_assigned_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "assigned_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reviews_created_by_users_id_fk": { + "name": "reviews_created_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reviews_reply_origin_ck": { + "name": "reviews_reply_origin_ck", + "value": "\"reviews\".\"reply_origin\" IS NULL OR \"reviews\".\"reply_origin\" IN ('manuel', 'google', 'auto')" + }, + "reviews_rating_ck": { + "name": "reviews_rating_ck", + "value": "\"reviews\".\"rating\" BETWEEN 1 AND 5" + }, + "reviews_source_ck": { + "name": "reviews_source_ck", + "value": "\"reviews\".\"source\" IN ('google', 'tripadvisor', 'thefork', 'facebook', 'direct', 'autre')" + }, + "reviews_rule_action_ck": { + "name": "reviews_rule_action_ck", + "value": "\"reviews\".\"rule_action\" IS NULL OR \"reviews\".\"rule_action\" IN ('remercier', 'remercier_inviter', 'demander_retour', 'transmettre', 'alerte')" + } + }, + "isRLSEnabled": false + }, + "public.sales_challenges": { + "name": "sales_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'perso'" + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keywords": { + "name": "keywords", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "from_day": { + "name": "from_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "to_day": { + "name": "to_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "rewards": { + "name": "rewards", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "target_value": { + "name": "target_value", + "type": "numeric(14, 3)", + "primaryKey": false, + "notNull": false + }, + "results": { + "name": "results", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_challenges_org_idx": { + "name": "sales_challenges_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_challenges_organization_id_organizations_id_fk": { + "name": "sales_challenges_organization_id_organizations_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_challenges_establishment_id_establishments_id_fk": { + "name": "sales_challenges_establishment_id_establishments_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_challenges_created_by_users_id_fk": { + "name": "sales_challenges_created_by_users_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_challenges_metric_ck": { + "name": "sales_challenges_metric_ck", + "value": "\"sales_challenges\".\"metric\" IN ('quantite', 'ca_ht', 'ca_heure')" + }, + "sales_challenges_range_ck": { + "name": "sales_challenges_range_ck", + "value": "\"sales_challenges\".\"to_day\" >= \"sales_challenges\".\"from_day\" AND \"sales_challenges\".\"to_day\" - \"sales_challenges\".\"from_day\" <= 366" + }, + "sales_challenges_target_ck": { + "name": "sales_challenges_target_ck", + "value": "\"sales_challenges\".\"target_value\" IS NULL OR \"sales_challenges\".\"target_value\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.sales_entries": { + "name": "sales_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "batch_id": { + "name": "batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_date": { + "name": "business_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "ticket_ref": { + "name": "ticket_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "payment_method": { + "name": "payment_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "format_version": { + "name": "format_version", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "line_ref": { + "name": "line_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sold_time": { + "name": "sold_time", + "type": "time", + "primaryKey": false, + "notNull": false + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "product": { + "name": "product", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(12, 3)", + "primaryKey": false, + "notNull": false + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "table_label": { + "name": "table_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discount_ttc": { + "name": "discount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "comp_ttc": { + "name": "comp_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "product_code": { + "name": "product_code", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sales_entries_row_uq": { + "name": "sales_entries_row_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_entries_period_idx": { + "name": "sales_entries_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_entries_ticket_idx": { + "name": "sales_entries_ticket_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ticket_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_entries_organization_id_organizations_id_fk": { + "name": "sales_entries_organization_id_organizations_id_fk", + "tableFrom": "sales_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_entries_establishment_id_establishments_id_fk": { + "name": "sales_entries_establishment_id_establishments_id_fk", + "tableFrom": "sales_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_entries_batch_id_sales_import_batches_id_fk": { + "name": "sales_entries_batch_id_sales_import_batches_id_fk", + "tableFrom": "sales_entries", + "tableTo": "sales_import_batches", + "columnsFrom": [ + "batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_ttc_consistency_ck": { + "name": "sales_ttc_consistency_ck", + "value": "\"sales_entries\".\"amount_ttc\" = \"sales_entries\".\"amount_ht\" + \"sales_entries\".\"vat_amount\"" + }, + "sales_format_version_ck": { + "name": "sales_format_version_ck", + "value": "\"sales_entries\".\"format_version\" IN (1, 2)" + }, + "sales_channel_ck": { + "name": "sales_channel_ck", + "value": "\"sales_entries\".\"channel\" IS NULL OR \"sales_entries\".\"channel\" IN ('sur_place', 'emporter', 'livraison', 'click_collect', 'autre')" + }, + "sales_discount_ck": { + "name": "sales_discount_ck", + "value": "\"sales_entries\".\"discount_ttc\" IS NULL OR \"sales_entries\".\"discount_ttc\" >= 0" + }, + "sales_comp_ck": { + "name": "sales_comp_ck", + "value": "\"sales_entries\".\"comp_ttc\" IS NULL OR \"sales_entries\".\"comp_ttc\" >= 0" + }, + "sales_quantity_ck": { + "name": "sales_quantity_ck", + "value": "\"sales_entries\".\"quantity\" IS NULL OR \"sales_entries\".\"quantity\" <> 0" + } + }, + "isRLSEnabled": false + }, + "public.sales_families": { + "name": "sales_families", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_families_name_uq": { + "name": "sales_families_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_families_organization_id_organizations_id_fk": { + "name": "sales_families_organization_id_organizations_id_fk", + "tableFrom": "sales_families", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_families_created_by_users_id_fk": { + "name": "sales_families_created_by_users_id_fk", + "tableFrom": "sales_families", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_family_rules": { + "name": "sales_family_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "family_id": { + "name": "family_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_kind": { + "name": "match_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_family_rules_uq": { + "name": "sales_family_rules_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_family_rules_organization_id_organizations_id_fk": { + "name": "sales_family_rules_organization_id_organizations_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_family_rules_family_id_sales_families_id_fk": { + "name": "sales_family_rules_family_id_sales_families_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "sales_families", + "columnsFrom": [ + "family_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_family_rules_created_by_users_id_fk": { + "name": "sales_family_rules_created_by_users_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_family_rules_kind_ck": { + "name": "sales_family_rules_kind_ck", + "value": "\"sales_family_rules\".\"match_kind\" IN ('category', 'product')" + } + }, + "isRLSEnabled": false + }, + "public.sales_import_batches": { + "name": "sales_import_batches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_sha256": { + "name": "file_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "row_count": { + "name": "row_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "period_from": { + "name": "period_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_to": { + "name": "period_to", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "import_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "imported_by": { + "name": "imported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reverted_at": { + "name": "reverted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reverted_by": { + "name": "reverted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payment_count": { + "name": "payment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_batches_file_uq": { + "name": "sales_batches_file_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "file_sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_import_batches_organization_id_organizations_id_fk": { + "name": "sales_import_batches_organization_id_organizations_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_import_batches_establishment_id_establishments_id_fk": { + "name": "sales_import_batches_establishment_id_establishments_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_import_batches_imported_by_users_id_fk": { + "name": "sales_import_batches_imported_by_users_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "users", + "columnsFrom": [ + "imported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sales_import_batches_reverted_by_users_id_fk": { + "name": "sales_import_batches_reverted_by_users_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "users", + "columnsFrom": [ + "reverted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_import_profiles": { + "name": "sales_import_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header_signature": { + "name": "header_signature", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "headers": { + "name": "headers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "mapping": { + "name": "mapping", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "use_count": { + "name": "use_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_import_profiles_sig_uq": { + "name": "sales_import_profiles_sig_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "header_signature", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_import_profiles_organization_id_organizations_id_fk": { + "name": "sales_import_profiles_organization_id_organizations_id_fk", + "tableFrom": "sales_import_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_import_profiles_created_by_users_id_fk": { + "name": "sales_import_profiles_created_by_users_id_fk", + "tableFrom": "sales_import_profiles", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_import_profiles_name_ck": { + "name": "sales_import_profiles_name_ck", + "value": "length(\"sales_import_profiles\".\"name\") BETWEEN 1 AND 80" + } + }, + "isRLSEnabled": false + }, + "public.sales_payments": { + "name": "sales_payments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "batch_id": { + "name": "batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_date": { + "name": "business_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "ticket_ref": { + "name": "ticket_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_payments_row_uq": { + "name": "sales_payments_row_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_payments_period_idx": { + "name": "sales_payments_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_payments_organization_id_organizations_id_fk": { + "name": "sales_payments_organization_id_organizations_id_fk", + "tableFrom": "sales_payments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_payments_establishment_id_establishments_id_fk": { + "name": "sales_payments_establishment_id_establishments_id_fk", + "tableFrom": "sales_payments", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_payments_batch_id_sales_import_batches_id_fk": { + "name": "sales_payments_batch_id_sales_import_batches_id_fk", + "tableFrom": "sales_payments", + "tableTo": "sales_import_batches", + "columnsFrom": [ + "batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_product_recipe_history": { + "name": "sales_product_recipe_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "portions_per_sale": { + "name": "portions_per_sale", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_product_recipe_history_uq": { + "name": "sales_product_recipe_history_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "valid_until", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_product_recipe_history_organization_id_organizations_id_fk": { + "name": "sales_product_recipe_history_organization_id_organizations_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_product_recipe_history_recipe_id_recipes_id_fk": { + "name": "sales_product_recipe_history_recipe_id_recipes_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_product_recipe_history_created_by_users_id_fk": { + "name": "sales_product_recipe_history_created_by_users_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_product_recipes": { + "name": "sales_product_recipes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "portions_per_sale": { + "name": "portions_per_sale", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "match_code": { + "name": "match_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_product_recipes_key_uq": { + "name": "sales_product_recipes_key_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_product_recipes_code_uq": { + "name": "sales_product_recipes_code_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"sales_product_recipes\".\"match_code\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_product_recipes_recipe_idx": { + "name": "sales_product_recipes_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_product_recipes_organization_id_organizations_id_fk": { + "name": "sales_product_recipes_organization_id_organizations_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_product_recipes_recipe_id_recipes_id_fk": { + "name": "sales_product_recipes_recipe_id_recipes_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_product_recipes_created_by_users_id_fk": { + "name": "sales_product_recipes_created_by_users_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sales_product_recipes_updated_by_users_id_fk": { + "name": "sales_product_recipes_updated_by_users_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_product_recipes_ck": { + "name": "sales_product_recipes_ck", + "value": "(\"sales_product_recipes\".\"recipe_id\" IS NULL AND \"sales_product_recipes\".\"portions_per_sale\" IS NULL) OR (\"sales_product_recipes\".\"recipe_id\" IS NOT NULL AND \"sales_product_recipes\".\"portions_per_sale\" > 0)" + } + }, + "isRLSEnabled": false + }, + "public.sales_server_links": { + "name": "sales_server_links", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "server_key": { + "name": "server_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "server_label": { + "name": "server_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_server_links_uq": { + "name": "sales_server_links_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "server_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_server_links_org_idx": { + "name": "sales_server_links_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_server_links_organization_id_organizations_id_fk": { + "name": "sales_server_links_organization_id_organizations_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_establishment_id_establishments_id_fk": { + "name": "sales_server_links_establishment_id_establishments_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_employee_id_employees_id_fk": { + "name": "sales_server_links_employee_id_employees_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_created_by_users_id_fk": { + "name": "sales_server_links_created_by_users_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_server_links_key_ck": { + "name": "sales_server_links_key_ck", + "value": "length(\"sales_server_links\".\"server_key\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + }, + "public.sales_service_periods": { + "name": "sales_service_periods", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_service_periods_name_uq": { + "name": "sales_service_periods_name_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_service_periods_organization_id_organizations_id_fk": { + "name": "sales_service_periods_organization_id_organizations_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_service_periods_establishment_id_establishments_id_fk": { + "name": "sales_service_periods_establishment_id_establishments_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_service_periods_created_by_users_id_fk": { + "name": "sales_service_periods_created_by_users_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_service_periods_time_ck": { + "name": "sales_service_periods_time_ck", + "value": "\"sales_service_periods\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"sales_service_periods\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"sales_service_periods\".\"start_time\" <> \"sales_service_periods\".\"end_time\"" + } + }, + "isRLSEnabled": false + }, + "public.sensitive_views": { + "name": "sensitive_views", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "area": { + "name": "area", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "viewed_at": { + "name": "viewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sensitive_views_org_idx": { + "name": "sensitive_views_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "viewed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sensitive_views_user_idx": { + "name": "sensitive_views_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "viewed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sensitive_views_organization_id_organizations_id_fk": { + "name": "sensitive_views_organization_id_organizations_id_fk", + "tableFrom": "sensitive_views", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sensitive_views_user_id_users_id_fk": { + "name": "sensitive_views_user_id_users_id_fk", + "tableFrom": "sensitive_views", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.seo_listings": { + "name": "seo_listings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "directory": { + "name": "directory", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nap_hash": { + "name": "nap_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "checked_by": { + "name": "checked_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_listings_est_dir_uq": { + "name": "seo_listings_est_dir_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "directory", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_listings_org_idx": { + "name": "seo_listings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_listings_organization_id_organizations_id_fk": { + "name": "seo_listings_organization_id_organizations_id_fk", + "tableFrom": "seo_listings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_listings_establishment_id_establishments_id_fk": { + "name": "seo_listings_establishment_id_establishments_id_fk", + "tableFrom": "seo_listings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_listings_checked_by_users_id_fk": { + "name": "seo_listings_checked_by_users_id_fk", + "tableFrom": "seo_listings", + "tableTo": "users", + "columnsFrom": [ + "checked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "seo_listings_status_ck": { + "name": "seo_listings_status_ck", + "value": "\"seo_listings\".\"status\" IN ('en_ligne', 'absent', 'non_concerne')" + } + }, + "isRLSEnabled": false + }, + "public.seo_profiles": { + "name": "seo_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cuisines": { + "name": "cuisines", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "price_range": { + "name": "price_range", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "menu_url": { + "name": "menu_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "links": { + "name": "links", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "keywords": { + "name": "keywords", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_profiles_est_uq": { + "name": "seo_profiles_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_profiles_org_idx": { + "name": "seo_profiles_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_profiles_organization_id_organizations_id_fk": { + "name": "seo_profiles_organization_id_organizations_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_profiles_establishment_id_establishments_id_fk": { + "name": "seo_profiles_establishment_id_establishments_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_profiles_updated_by_users_id_fk": { + "name": "seo_profiles_updated_by_users_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "seo_profiles_price_ck": { + "name": "seo_profiles_price_ck", + "value": "\"seo_profiles\".\"price_range\" IS NULL OR \"seo_profiles\".\"price_range\" IN ('\u20ac', '\u20ac\u20ac', '\u20ac\u20ac\u20ac', '\u20ac\u20ac\u20ac\u20ac')" + } + }, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sessions_user_idx": { + "name": "sessions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sessions_organization_id_organizations_id_fk": { + "name": "sessions_organization_id_organizations_id_fk", + "tableFrom": "sessions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.set_menus": { + "name": "set_menus", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "occasion": { + "name": "occasion", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "min_guests": { + "name": "min_guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_guests": { + "name": "max_guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "available_from": { + "name": "available_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "available_to": { + "name": "available_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "recipe_ids": { + "name": "recipe_ids", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::uuid[]" + }, + "courses": { + "name": "courses", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "set_menus_est_idx": { + "name": "set_menus_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "set_menus_organization_id_organizations_id_fk": { + "name": "set_menus_organization_id_organizations_id_fk", + "tableFrom": "set_menus", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "set_menus_establishment_id_establishments_id_fk": { + "name": "set_menus_establishment_id_establishments_id_fk", + "tableFrom": "set_menus", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "set_menus_created_by_users_id_fk": { + "name": "set_menus_created_by_users_id_fk", + "tableFrom": "set_menus", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "set_menus_category_ck": { + "name": "set_menus_category_ck", + "value": "\"set_menus\".\"category\" IN ('carte', 'groupe', 'evenement')" + }, + "set_menus_guests_ck": { + "name": "set_menus_guests_ck", + "value": "(\"set_menus\".\"min_guests\" IS NULL OR \"set_menus\".\"min_guests\" > 0) AND (\"set_menus\".\"max_guests\" IS NULL OR \"set_menus\".\"max_guests\" > 0) AND (\"set_menus\".\"min_guests\" IS NULL OR \"set_menus\".\"max_guests\" IS NULL OR \"set_menus\".\"min_guests\" <= \"set_menus\".\"max_guests\")" + }, + "set_menus_dates_ck": { + "name": "set_menus_dates_ck", + "value": "\"set_menus\".\"available_from\" IS NULL OR \"set_menus\".\"available_to\" IS NULL OR \"set_menus\".\"available_from\" <= \"set_menus\".\"available_to\"" + } + }, + "isRLSEnabled": false + }, + "public.shift_swaps": { + "name": "shift_swaps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "shift_id": { + "name": "shift_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "from_employee_id": { + "name": "from_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_employee_id": { + "name": "to_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counter_shift_id": { + "name": "counter_shift_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "shift_snapshot": { + "name": "shift_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counter_snapshot": { + "name": "counter_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'attente_collegue'" + }, + "colleague_answered_at": { + "name": "colleague_answered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shift_swaps_est_status_idx": { + "name": "shift_swaps_est_status_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shift_swaps_from_idx": { + "name": "shift_swaps_from_idx", + "columns": [ + { + "expression": "from_employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shift_swaps_to_idx": { + "name": "shift_swaps_to_idx", + "columns": [ + { + "expression": "to_employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shift_swaps_organization_id_organizations_id_fk": { + "name": "shift_swaps_organization_id_organizations_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_establishment_id_establishments_id_fk": { + "name": "shift_swaps_establishment_id_establishments_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_shift_id_shifts_id_fk": { + "name": "shift_swaps_shift_id_shifts_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "shifts", + "columnsFrom": [ + "shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "shift_swaps_from_employee_id_employees_id_fk": { + "name": "shift_swaps_from_employee_id_employees_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "employees", + "columnsFrom": [ + "from_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_to_employee_id_employees_id_fk": { + "name": "shift_swaps_to_employee_id_employees_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "employees", + "columnsFrom": [ + "to_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_counter_shift_id_shifts_id_fk": { + "name": "shift_swaps_counter_shift_id_shifts_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "shifts", + "columnsFrom": [ + "counter_shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "shift_swaps_decided_by_users_id_fk": { + "name": "shift_swaps_decided_by_users_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shift_swaps_created_by_users_id_fk": { + "name": "shift_swaps_created_by_users_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shift_swaps_status_ck": { + "name": "shift_swaps_status_ck", + "value": "\"shift_swaps\".\"status\" IN ('attente_collegue', 'attente_responsable', 'acceptee', 'refusee', 'annulee', 'expiree')" + }, + "shift_swaps_people_ck": { + "name": "shift_swaps_people_ck", + "value": "\"shift_swaps\".\"from_employee_id\" <> \"shift_swaps\".\"to_employee_id\"" + } + }, + "isRLSEnabled": false + }, + "public.shift_templates": { + "name": "shift_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "break_minutes": { + "name": "break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shift_templates_est_idx": { + "name": "shift_templates_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shift_templates_organization_id_organizations_id_fk": { + "name": "shift_templates_organization_id_organizations_id_fk", + "tableFrom": "shift_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_templates_establishment_id_establishments_id_fk": { + "name": "shift_templates_establishment_id_establishments_id_fk", + "tableFrom": "shift_templates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_templates_created_by_users_id_fk": { + "name": "shift_templates_created_by_users_id_fk", + "tableFrom": "shift_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shift_templates_time_ck": { + "name": "shift_templates_time_ck", + "value": "\"shift_templates\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shift_templates\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shift_templates\".\"start_time\" <> \"shift_templates\".\"end_time\"" + }, + "shift_templates_break_ck": { + "name": "shift_templates_break_ck", + "value": "\"shift_templates\".\"break_minutes\" >= 0 AND \"shift_templates\".\"break_minutes\" <= 240" + } + }, + "isRLSEnabled": false + }, + "public.shifts": { + "name": "shifts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "break_minutes": { + "name": "break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_start": { + "name": "actual_start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_end": { + "name": "actual_end", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_break_minutes": { + "name": "actual_break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "meals": { + "name": "meals", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "no_show": { + "name": "no_show", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shifts_est_date_idx": { + "name": "shifts_est_date_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shifts_emp_date_idx": { + "name": "shifts_emp_date_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shifts_organization_id_organizations_id_fk": { + "name": "shifts_organization_id_organizations_id_fk", + "tableFrom": "shifts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_establishment_id_establishments_id_fk": { + "name": "shifts_establishment_id_establishments_id_fk", + "tableFrom": "shifts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_employee_id_employees_id_fk": { + "name": "shifts_employee_id_employees_id_fk", + "tableFrom": "shifts", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_validated_by_users_id_fk": { + "name": "shifts_validated_by_users_id_fk", + "tableFrom": "shifts", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shifts_created_by_users_id_fk": { + "name": "shifts_created_by_users_id_fk", + "tableFrom": "shifts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shifts_meals_ck": { + "name": "shifts_meals_ck", + "value": "\"shifts\".\"meals\" >= 0 AND \"shifts\".\"meals\" <= 3" + }, + "shifts_time_ck": { + "name": "shifts_time_ck", + "value": "\"shifts\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shifts\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shifts\".\"start_time\" <> \"shifts\".\"end_time\"" + }, + "shifts_break_ck": { + "name": "shifts_break_ck", + "value": "\"shifts\".\"break_minutes\" >= 0 AND \"shifts\".\"break_minutes\" <= 240" + } + }, + "isRLSEnabled": false + }, + "public.signature_requests": { + "name": "signature_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_id": { + "name": "contract_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_pdf": { + "name": "document_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "document_sha256": { + "name": "document_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "signer_email": { + "name": "signer_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employer_name": { + "name": "employer_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code_expires_at": { + "name": "code_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "code_sent_at": { + "name": "code_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "codes_sent": { + "name": "codes_sent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "code_attempts": { + "name": "code_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "signed_at": { + "name": "signed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "signed_name": { + "name": "signed_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signed_pdf": { + "name": "signed_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "signed_sha256": { + "name": "signed_sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refusal_note": { + "name": "refusal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "drawn_signature": { + "name": "drawn_signature", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "reminders_sent": { + "name": "reminders_sent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_reminder_at": { + "name": "last_reminder_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "signature_requests_token_uq": { + "name": "signature_requests_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "signature_requests_emp_idx": { + "name": "signature_requests_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "signature_requests_organization_id_organizations_id_fk": { + "name": "signature_requests_organization_id_organizations_id_fk", + "tableFrom": "signature_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_establishment_id_establishments_id_fk": { + "name": "signature_requests_establishment_id_establishments_id_fk", + "tableFrom": "signature_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_employee_id_employees_id_fk": { + "name": "signature_requests_employee_id_employees_id_fk", + "tableFrom": "signature_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_file_id_employee_files_id_fk": { + "name": "signature_requests_file_id_employee_files_id_fk", + "tableFrom": "signature_requests", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "signature_requests_created_by_users_id_fk": { + "name": "signature_requests_created_by_users_id_fk", + "tableFrom": "signature_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "signature_requests_status_ck": { + "name": "signature_requests_status_ck", + "value": "\"signature_requests\".\"status\" IN ('en_attente', 'signe', 'refuse', 'annule')" + } + }, + "isRLSEnabled": false + }, + "public.skills": { + "name": "skills", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "skills_name_uq": { + "name": "skills_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"skills\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "skills_organization_id_organizations_id_fk": { + "name": "skills_organization_id_organizations_id_fk", + "tableFrom": "skills", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.social_posts": { + "name": "social_posts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "visual_id": { + "name": "visual_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "networks": { + "name": "networks", + "type": "text[]", + "primaryKey": false, + "notNull": true + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_mime": { + "name": "image_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "image_format": { + "name": "image_format", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external": { + "name": "external", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stats": { + "name": "stats", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stats_at": { + "name": "stats_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "social_posts_cal_idx": { + "name": "social_posts_cal_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_due_idx": { + "name": "social_posts_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_source_uq": { + "name": "social_posts_source_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"social_posts\".\"source_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_token_uq": { + "name": "social_posts_token_uq", + "columns": [ + { + "expression": "public_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "social_posts_organization_id_organizations_id_fk": { + "name": "social_posts_organization_id_organizations_id_fk", + "tableFrom": "social_posts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_posts_establishment_id_establishments_id_fk": { + "name": "social_posts_establishment_id_establishments_id_fk", + "tableFrom": "social_posts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_posts_visual_id_studio_visuals_id_fk": { + "name": "social_posts_visual_id_studio_visuals_id_fk", + "tableFrom": "social_posts", + "tableTo": "studio_visuals", + "columnsFrom": [ + "visual_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "social_posts_approved_by_users_id_fk": { + "name": "social_posts_approved_by_users_id_fk", + "tableFrom": "social_posts", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "social_posts_created_by_users_id_fk": { + "name": "social_posts_created_by_users_id_fk", + "tableFrom": "social_posts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "social_posts_source_ck": { + "name": "social_posts_source_ck", + "value": "\"social_posts\".\"source\" IN ('manuel', 'menu_du_jour', 'evenement', 'fermeture', 'avis')" + }, + "social_posts_status_ck": { + "name": "social_posts_status_ck", + "value": "\"social_posts\".\"status\" IN ('a_valider', 'planifie', 'publie', 'partiel', 'echec', 'annule')" + }, + "social_posts_networks_ck": { + "name": "social_posts_networks_ck", + "value": "\"social_posts\".\"networks\" <@ ARRAY['instagram','facebook']::text[] AND cardinality(\"social_posts\".\"networks\") >= 1" + }, + "social_posts_image_ck": { + "name": "social_posts_image_ck", + "value": "(\"social_posts\".\"image\" IS NULL) = (\"social_posts\".\"image_mime\" IS NULL) AND (\"social_posts\".\"image_mime\" IS NULL OR \"social_posts\".\"image_mime\" = 'image/png')" + }, + "social_posts_format_ck": { + "name": "social_posts_format_ck", + "value": "\"social_posts\".\"image_format\" IS NULL OR \"social_posts\".\"image_format\" IN ('carre', 'portrait', 'facebook')" + }, + "social_posts_caption_ck": { + "name": "social_posts_caption_ck", + "value": "char_length(\"social_posts\".\"caption\") BETWEEN 1 AND 2200" + } + }, + "isRLSEnabled": false + }, + "public.social_settings": { + "name": "social_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "networks": { + "name": "networks", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY['instagram','facebook']::text[]" + }, + "require_approval": { + "name": "require_approval", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "auto_menu": { + "name": "auto_menu", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "menu_time": { + "name": "menu_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'11:00'" + }, + "auto_events": { + "name": "auto_events", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "event_time": { + "name": "event_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'18:00'" + }, + "closure_days_before": { + "name": "closure_days_before", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "auto_reviews": { + "name": "auto_reviews", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "review_min_rating": { + "name": "review_min_rating", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "review_time": { + "name": "review_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'17:30'" + }, + "hashtags": { + "name": "hashtags", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_posts_per_day": { + "name": "max_posts_per_day", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "repeat_days": { + "name": "repeat_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 14 + }, + "auto_best_times": { + "name": "auto_best_times", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "social_settings_org_idx": { + "name": "social_settings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "social_settings_establishment_id_establishments_id_fk": { + "name": "social_settings_establishment_id_establishments_id_fk", + "tableFrom": "social_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_settings_organization_id_organizations_id_fk": { + "name": "social_settings_organization_id_organizations_id_fk", + "tableFrom": "social_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_settings_updated_by_users_id_fk": { + "name": "social_settings_updated_by_users_id_fk", + "tableFrom": "social_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "social_settings_repeat_ck": { + "name": "social_settings_repeat_ck", + "value": "\"social_settings\".\"max_posts_per_day\" BETWEEN 1 AND 5 AND \"social_settings\".\"repeat_days\" BETWEEN 0 AND 90" + }, + "social_settings_networks_ck": { + "name": "social_settings_networks_ck", + "value": "\"social_settings\".\"networks\" <@ ARRAY['instagram','facebook']::text[] AND cardinality(\"social_settings\".\"networks\") >= 1" + }, + "social_settings_times_ck": { + "name": "social_settings_times_ck", + "value": "\"social_settings\".\"menu_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"social_settings\".\"event_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"social_settings\".\"review_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "social_settings_rating_ck": { + "name": "social_settings_rating_ck", + "value": "\"social_settings\".\"review_min_rating\" BETWEEN 4 AND 5" + }, + "social_settings_days_ck": { + "name": "social_settings_days_ck", + "value": "\"social_settings\".\"closure_days_before\" BETWEEN 0 AND 14" + } + }, + "isRLSEnabled": false + }, + "public.staff_meals": { + "name": "staff_meals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "meal_date": { + "name": "meal_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "beneficiary_name": { + "name": "beneficiary_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dish_label": { + "name": "dish_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'1'" + }, + "pricing": { + "name": "pricing", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "total_cost": { + "name": "total_cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_paid": { + "name": "amount_paid", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "meal_value": { + "name": "meal_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "staff_meals_est_idx": { + "name": "staff_meals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "meal_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "staff_meals_emp_idx": { + "name": "staff_meals_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "meal_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "staff_meals_organization_id_organizations_id_fk": { + "name": "staff_meals_organization_id_organizations_id_fk", + "tableFrom": "staff_meals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "staff_meals_establishment_id_establishments_id_fk": { + "name": "staff_meals_establishment_id_establishments_id_fk", + "tableFrom": "staff_meals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "staff_meals_employee_id_employees_id_fk": { + "name": "staff_meals_employee_id_employees_id_fk", + "tableFrom": "staff_meals", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "staff_meals_recipe_id_recipes_id_fk": { + "name": "staff_meals_recipe_id_recipes_id_fk", + "tableFrom": "staff_meals", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "staff_meals_created_by_users_id_fk": { + "name": "staff_meals_created_by_users_id_fk", + "tableFrom": "staff_meals", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_meals_cancelled_by_users_id_fk": { + "name": "staff_meals_cancelled_by_users_id_fk", + "tableFrom": "staff_meals", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "staff_meals_pricing_ck": { + "name": "staff_meals_pricing_ck", + "value": "\"staff_meals\".\"pricing\" IN ('offert', 'cout', 'prix_libre')" + }, + "staff_meals_beneficiary_ck": { + "name": "staff_meals_beneficiary_ck", + "value": "(\"staff_meals\".\"employee_id\" IS NULL) <> (\"staff_meals\".\"beneficiary_name\" IS NULL)" + }, + "staff_meals_amounts_ck": { + "name": "staff_meals_amounts_ck", + "value": "\"staff_meals\".\"portions\" > 0 AND \"staff_meals\".\"portions\" <= 20 AND \"staff_meals\".\"amount_paid\" >= 0 AND (\"staff_meals\".\"pricing\" <> 'offert' OR \"staff_meals\".\"amount_paid\" = 0)" + }, + "staff_meals_service_ck": { + "name": "staff_meals_service_ck", + "value": "\"staff_meals\".\"service\" IS NULL OR \"staff_meals\".\"service\" IN ('midi', 'soir')" + } + }, + "isRLSEnabled": false + }, + "public.stock_expiry_lots": { + "name": "stock_expiry_lots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_on": { + "name": "expires_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_line_id": { + "name": "order_line_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_reason": { + "name": "closed_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "loss_id": { + "name": "loss_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_expiry_lots_loss_idx": { + "name": "stock_expiry_lots_loss_idx", + "columns": [ + { + "expression": "loss_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"stock_expiry_lots\".\"loss_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_expiry_lots_open_idx": { + "name": "stock_expiry_lots_open_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"stock_expiry_lots\".\"closed_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_expiry_lots_item_idx": { + "name": "stock_expiry_lots_item_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_expiry_lots_organization_id_organizations_id_fk": { + "name": "stock_expiry_lots_organization_id_organizations_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_establishment_id_establishments_id_fk": { + "name": "stock_expiry_lots_establishment_id_establishments_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_item_id_purchase_items_id_fk": { + "name": "stock_expiry_lots_item_id_purchase_items_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_order_line_id_purchase_order_lines_id_fk": { + "name": "stock_expiry_lots_order_line_id_purchase_order_lines_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "purchase_order_lines", + "columnsFrom": [ + "order_line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "stock_expiry_lots_closed_by_users_id_fk": { + "name": "stock_expiry_lots_closed_by_users_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_expiry_lots_loss_id_stock_losses_id_fk": { + "name": "stock_expiry_lots_loss_id_stock_losses_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "stock_losses", + "columnsFrom": [ + "loss_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "stock_expiry_lots_created_by_users_id_fk": { + "name": "stock_expiry_lots_created_by_users_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_expiry_lots_kind_ck": { + "name": "stock_expiry_lots_kind_ck", + "value": "\"stock_expiry_lots\".\"kind\" IN ('dlc', 'ddm')" + }, + "stock_expiry_lots_qty_ck": { + "name": "stock_expiry_lots_qty_ck", + "value": "\"stock_expiry_lots\".\"quantity\" > 0" + }, + "stock_expiry_lots_close_ck": { + "name": "stock_expiry_lots_close_ck", + "value": "(\"stock_expiry_lots\".\"closed_at\" IS NULL) = (\"stock_expiry_lots\".\"closed_reason\" IS NULL) AND (\"stock_expiry_lots\".\"closed_reason\" IS NULL OR \"stock_expiry_lots\".\"closed_reason\" IN ('ecoule', 'perte', 'retour', 'erreur'))" + } + }, + "isRLSEnabled": false + }, + "public.stock_losses": { + "name": "stock_losses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "loss_date": { + "name": "loss_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credit_request_id": { + "name": "credit_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_losses_est_idx": { + "name": "stock_losses_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "loss_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_losses_organization_id_organizations_id_fk": { + "name": "stock_losses_organization_id_organizations_id_fk", + "tableFrom": "stock_losses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_losses_establishment_id_establishments_id_fk": { + "name": "stock_losses_establishment_id_establishments_id_fk", + "tableFrom": "stock_losses", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_losses_item_id_purchase_items_id_fk": { + "name": "stock_losses_item_id_purchase_items_id_fk", + "tableFrom": "stock_losses", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_losses_created_by_users_id_fk": { + "name": "stock_losses_created_by_users_id_fk", + "tableFrom": "stock_losses", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_losses_cancelled_by_users_id_fk": { + "name": "stock_losses_cancelled_by_users_id_fk", + "tableFrom": "stock_losses", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_losses_credit_request_id_credit_requests_id_fk": { + "name": "stock_losses_credit_request_id_credit_requests_id_fk", + "tableFrom": "stock_losses", + "tableTo": "credit_requests", + "columnsFrom": [ + "credit_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_losses_qty_ck": { + "name": "stock_losses_qty_ck", + "value": "\"stock_losses\".\"quantity\" > 0" + }, + "stock_losses_reason_ck": { + "name": "stock_losses_reason_ck", + "value": "\"stock_losses\".\"reason\" IN ('peremption', 'casse', 'erreur_production', 'retour_client', 'repas_personnel', 'offert', 'vol', 'retour_fournisseur', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.stock_rotation_settings": { + "name": "stock_rotation_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "overstock_days": { + "name": "overstock_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "lookback_days": { + "name": "lookback_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 28 + }, + "level_basis": { + "name": "level_basis", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'compte'" + }, + "expiry_alert_days": { + "name": "expiry_alert_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_rotation_settings_est_uq": { + "name": "stock_rotation_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_rotation_settings_organization_id_organizations_id_fk": { + "name": "stock_rotation_settings_organization_id_organizations_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_rotation_settings_establishment_id_establishments_id_fk": { + "name": "stock_rotation_settings_establishment_id_establishments_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_rotation_settings_updated_by_users_id_fk": { + "name": "stock_rotation_settings_updated_by_users_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_rotation_overstock_ck": { + "name": "stock_rotation_overstock_ck", + "value": "\"stock_rotation_settings\".\"overstock_days\" IS NULL OR \"stock_rotation_settings\".\"overstock_days\" BETWEEN 1 AND 365" + }, + "stock_rotation_lookback_ck": { + "name": "stock_rotation_lookback_ck", + "value": "\"stock_rotation_settings\".\"lookback_days\" BETWEEN 7 AND 365" + }, + "stock_rotation_basis_ck": { + "name": "stock_rotation_basis_ck", + "value": "\"stock_rotation_settings\".\"level_basis\" IN ('compte', 'theorique')" + }, + "stock_rotation_expiry_ck": { + "name": "stock_rotation_expiry_ck", + "value": "\"stock_rotation_settings\".\"expiry_alert_days\" BETWEEN 0 AND 30" + } + }, + "isRLSEnabled": false + }, + "public.stock_transfer_lines": { + "name": "stock_transfer_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "transfer_id": { + "name": "transfer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_transfer_lines_item_uq": { + "name": "stock_transfer_lines_item_uq", + "columns": [ + { + "expression": "transfer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfer_lines_item_idx": { + "name": "stock_transfer_lines_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_transfer_lines_organization_id_organizations_id_fk": { + "name": "stock_transfer_lines_organization_id_organizations_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfer_lines_transfer_id_stock_transfers_id_fk": { + "name": "stock_transfer_lines_transfer_id_stock_transfers_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "stock_transfers", + "columnsFrom": [ + "transfer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfer_lines_item_id_purchase_items_id_fk": { + "name": "stock_transfer_lines_item_id_purchase_items_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_transfer_lines_ck": { + "name": "stock_transfer_lines_ck", + "value": "\"stock_transfer_lines\".\"quantity\" > 0 AND \"stock_transfer_lines\".\"unit_cost\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.stock_transfers": { + "name": "stock_transfers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "from_establishment_id": { + "name": "from_establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_establishment_id": { + "name": "to_establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "transfer_date": { + "name": "transfer_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_value": { + "name": "total_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_transfers_number_uq": { + "name": "stock_transfers_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfers_from_idx": { + "name": "stock_transfers_from_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "transfer_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfers_to_idx": { + "name": "stock_transfers_to_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "transfer_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_transfers_organization_id_organizations_id_fk": { + "name": "stock_transfers_organization_id_organizations_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfers_from_establishment_id_establishments_id_fk": { + "name": "stock_transfers_from_establishment_id_establishments_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "establishments", + "columnsFrom": [ + "from_establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_transfers_to_establishment_id_establishments_id_fk": { + "name": "stock_transfers_to_establishment_id_establishments_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "establishments", + "columnsFrom": [ + "to_establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_transfers_created_by_users_id_fk": { + "name": "stock_transfers_created_by_users_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_transfers_cancelled_by_users_id_fk": { + "name": "stock_transfers_cancelled_by_users_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_transfers_distinct_ck": { + "name": "stock_transfers_distinct_ck", + "value": "\"stock_transfers\".\"from_establishment_id\" <> \"stock_transfers\".\"to_establishment_id\"" + } + }, + "isRLSEnabled": false + }, + "public.studio_brands": { + "name": "studio_brands", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "handle": { + "name": "handle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "background": { + "name": "background", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#1f2a24'" + }, + "primary": { + "name": "primary", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#d9a441'" + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#fbf7ee'" + }, + "font": { + "name": "font", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'classique'" + }, + "logo_mime": { + "name": "logo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo": { + "name": "logo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "studio_brands_org_idx": { + "name": "studio_brands_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "studio_brands_establishment_id_establishments_id_fk": { + "name": "studio_brands_establishment_id_establishments_id_fk", + "tableFrom": "studio_brands", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_brands_organization_id_organizations_id_fk": { + "name": "studio_brands_organization_id_organizations_id_fk", + "tableFrom": "studio_brands", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_brands_updated_by_users_id_fk": { + "name": "studio_brands_updated_by_users_id_fk", + "tableFrom": "studio_brands", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "studio_brands_colors_ck": { + "name": "studio_brands_colors_ck", + "value": "\"studio_brands\".\"background\" ~ '^#[0-9a-f]{6}$' AND \"studio_brands\".\"primary\" ~ '^#[0-9a-f]{6}$' AND \"studio_brands\".\"text\" ~ '^#[0-9a-f]{6}$'" + }, + "studio_brands_font_ck": { + "name": "studio_brands_font_ck", + "value": "\"studio_brands\".\"font\" IN ('classique', 'moderne', 'elegant')" + }, + "studio_brands_logo_ck": { + "name": "studio_brands_logo_ck", + "value": "(\"studio_brands\".\"logo\" IS NULL) = (\"studio_brands\".\"logo_mime\" IS NULL) AND (\"studio_brands\".\"logo_mime\" IS NULL OR \"studio_brands\".\"logo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + } + }, + "isRLSEnabled": false + }, + "public.studio_visuals": { + "name": "studio_visuals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "studio_visuals_est_idx": { + "name": "studio_visuals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "studio_visuals_organization_id_organizations_id_fk": { + "name": "studio_visuals_organization_id_organizations_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_visuals_establishment_id_establishments_id_fk": { + "name": "studio_visuals_establishment_id_establishments_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_visuals_created_by_users_id_fk": { + "name": "studio_visuals_created_by_users_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "studio_visuals_template_ck": { + "name": "studio_visuals_template_ck", + "value": "\"studio_visuals\".\"template\" IN ('menu_du_jour', 'plat', 'evenement', 'avis')" + }, + "studio_visuals_format_ck": { + "name": "studio_visuals_format_ck", + "value": "\"studio_visuals\".\"format\" IN ('carre', 'portrait', 'story', 'facebook')" + }, + "studio_visuals_photo_ck": { + "name": "studio_visuals_photo_ck", + "value": "(\"studio_visuals\".\"photo\" IS NULL) = (\"studio_visuals\".\"photo_mime\" IS NULL) AND (\"studio_visuals\".\"photo_mime\" IS NULL OR \"studio_visuals\".\"photo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + } + }, + "isRLSEnabled": false + }, + "public.supplier_offer_prices": { + "name": "supplier_offer_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "offer_id": { + "name": "offer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "price_ht": { + "name": "price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "content_quantity": { + "name": "content_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "content_unit": { + "name": "content_unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_offer_prices_offer_idx": { + "name": "supplier_offer_prices_offer_idx", + "columns": [ + { + "expression": "offer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_offer_prices_organization_id_organizations_id_fk": { + "name": "supplier_offer_prices_organization_id_organizations_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offer_prices_offer_id_supplier_offers_id_fk": { + "name": "supplier_offer_prices_offer_id_supplier_offers_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "supplier_offers", + "columnsFrom": [ + "offer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offer_prices_created_by_users_id_fk": { + "name": "supplier_offer_prices_created_by_users_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "supplier_offer_prices_source_ck": { + "name": "supplier_offer_prices_source_ck", + "value": "\"supplier_offer_prices\".\"source\" IN ('manual', 'import', 'migration', 'demande_prix')" + }, + "supplier_offer_prices_price_ck": { + "name": "supplier_offer_prices_price_ck", + "value": "\"supplier_offer_prices\".\"price_ht\" >= 0 AND \"supplier_offer_prices\".\"content_quantity\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.supplier_offers": { + "name": "supplier_offers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_ref": { + "name": "supplier_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_ht": { + "name": "price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "content_quantity": { + "name": "content_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "content_unit": { + "name": "content_unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price_date": { + "name": "price_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_offers_item_idx": { + "name": "supplier_offers_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "supplier_offers_supplier_idx": { + "name": "supplier_offers_supplier_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "supplier_offers_active_uq": { + "name": "supplier_offers_active_uq", + "columns": [ + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(coalesce(\"supplier_ref\", ''))", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"supplier_offers\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_offers_organization_id_organizations_id_fk": { + "name": "supplier_offers_organization_id_organizations_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offers_item_id_purchase_items_id_fk": { + "name": "supplier_offers_item_id_purchase_items_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offers_supplier_id_suppliers_id_fk": { + "name": "supplier_offers_supplier_id_suppliers_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "supplier_offers_created_by_users_id_fk": { + "name": "supplier_offers_created_by_users_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "supplier_offers_updated_by_users_id_fk": { + "name": "supplier_offers_updated_by_users_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "supplier_offers_price_ck": { + "name": "supplier_offers_price_ck", + "value": "\"supplier_offers\".\"price_ht\" >= 0 AND \"supplier_offers\".\"content_quantity\" > 0" + }, + "supplier_offers_unit_ck": { + "name": "supplier_offers_unit_ck", + "value": "\"supplier_offers\".\"content_unit\" IN ('kg', 'g', 'L', 'cl', 'pi\u00e8ce', 'botte', 'carton', 'colis', 'bouteille', 'f\u00fbt', 'lot', 'heure', 'forfait')" + }, + "supplier_offers_source_ck": { + "name": "supplier_offers_source_ck", + "value": "\"supplier_offers\".\"source\" IN ('manual', 'import', 'migration', 'demande_prix')" + } + }, + "isRLSEnabled": false + }, + "public.supplier_order_reminders": { + "name": "supplier_order_reminders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "suppliers": { + "name": "suppliers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_order_reminders_uq": { + "name": "supplier_order_reminders_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_order_reminders_organization_id_organizations_id_fk": { + "name": "supplier_order_reminders_organization_id_organizations_id_fk", + "tableFrom": "supplier_order_reminders", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_order_reminders_establishment_id_establishments_id_fk": { + "name": "supplier_order_reminders_establishment_id_establishments_id_fk", + "tableFrom": "supplier_order_reminders", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.suppliers": { + "name": "suppliers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_number": { + "name": "vat_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_terms_days": { + "name": "payment_terms_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "default_category": { + "name": "default_category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'food'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "min_order_ht": { + "name": "min_order_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "order_cutoff": { + "name": "order_cutoff", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lead_time_days": { + "name": "lead_time_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "delivery_days": { + "name": "delivery_days", + "type": "integer[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::integer[]" + }, + "delivery_fee_mode": { + "name": "delivery_fee_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "delivery_fee_fixed": { + "name": "delivery_fee_fixed", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_percent": { + "name": "delivery_fee_percent", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_tiers": { + "name": "delivery_fee_tiers", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "suppliers_org_idx": { + "name": "suppliers_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "suppliers_org_name_uq": { + "name": "suppliers_org_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "suppliers_organization_id_organizations_id_fk": { + "name": "suppliers_organization_id_organizations_id_fk", + "tableFrom": "suppliers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "suppliers_created_by_users_id_fk": { + "name": "suppliers_created_by_users_id_fk", + "tableFrom": "suppliers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "suppliers_fee_mode_ck": { + "name": "suppliers_fee_mode_ck", + "value": "\"suppliers\".\"delivery_fee_mode\" IN ('none', 'fixed', 'tiers', 'percent')" + }, + "suppliers_delivery_days_ck": { + "name": "suppliers_delivery_days_ck", + "value": "\"suppliers\".\"delivery_days\" <@ ARRAY[1,2,3,4,5,6,7]" + }, + "suppliers_cutoff_ck": { + "name": "suppliers_cutoff_ck", + "value": "\"suppliers\".\"order_cutoff\" IS NULL OR \"suppliers\".\"order_cutoff\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "suppliers_siret_ck": { + "name": "suppliers_siret_ck", + "value": "\"suppliers\".\"siret\" IS NULL OR \"suppliers\".\"siret\" ~ '^[0-9]{14}$'" + }, + "suppliers_terms_ck": { + "name": "suppliers_terms_ck", + "value": "\"suppliers\".\"payment_terms_days\" IS NULL OR (\"suppliers\".\"payment_terms_days\" >= 0 AND \"suppliers\".\"payment_terms_days\" <= 365)" + } + }, + "isRLSEnabled": false + }, + "public.tablet_devices": { + "name": "tablet_devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo_on_punch": { + "name": "photo_on_punch", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pairing_code_hash": { + "name": "pairing_code_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pairing_expires_at": { + "name": "pairing_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paired_at": { + "name": "paired_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "operator_employee_id": { + "name": "operator_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "operator_token_hash": { + "name": "operator_token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "operator_until": { + "name": "operator_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tablet_devices_org_idx": { + "name": "tablet_devices_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tablet_devices_token_uq": { + "name": "tablet_devices_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tablet_devices_pairing_uq": { + "name": "tablet_devices_pairing_uq", + "columns": [ + { + "expression": "pairing_code_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tablet_devices_organization_id_organizations_id_fk": { + "name": "tablet_devices_organization_id_organizations_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tablet_devices_establishment_id_establishments_id_fk": { + "name": "tablet_devices_establishment_id_establishments_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tablet_devices_operator_employee_id_employees_id_fk": { + "name": "tablet_devices_operator_employee_id_employees_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "employees", + "columnsFrom": [ + "operator_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tablet_devices_created_by_users_id_fk": { + "name": "tablet_devices_created_by_users_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "tablet_devices_mode_ck": { + "name": "tablet_devices_mode_ck", + "value": "\"tablet_devices\".\"mode\" IN ('pointeuse', 'haccp')" + } + }, + "isRLSEnabled": false + }, + "public.task_completions": { + "name": "task_completions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "occurrence": { + "name": "occurrence", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "task_completions_est_idx": { + "name": "task_completions_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "task_completions_once_uq": { + "name": "task_completions_once_uq", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"task_completions\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_completions_organization_id_organizations_id_fk": { + "name": "task_completions_organization_id_organizations_id_fk", + "tableFrom": "task_completions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_completions_establishment_id_establishments_id_fk": { + "name": "task_completions_establishment_id_establishments_id_fk", + "tableFrom": "task_completions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_completions_task_id_task_definitions_id_fk": { + "name": "task_completions_task_id_task_definitions_id_fk", + "tableFrom": "task_completions", + "tableTo": "task_definitions", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_completions_done_by_users_id_fk": { + "name": "task_completions_done_by_users_id_fk", + "tableFrom": "task_completions", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "task_completions_cancelled_by_users_id_fk": { + "name": "task_completions_cancelled_by_users_id_fk", + "tableFrom": "task_completions", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_definitions": { + "name": "task_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "instructions": { + "name": "instructions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "month_day": { + "name": "month_day", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "once_date": { + "name": "once_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "due_time": { + "name": "due_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_required": { + "name": "photo_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "starts_on": { + "name": "starts_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "task_definitions_est_idx": { + "name": "task_definitions_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_definitions_organization_id_organizations_id_fk": { + "name": "task_definitions_organization_id_organizations_id_fk", + "tableFrom": "task_definitions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_definitions_establishment_id_establishments_id_fk": { + "name": "task_definitions_establishment_id_establishments_id_fk", + "tableFrom": "task_definitions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_definitions_assignee_user_id_users_id_fk": { + "name": "task_definitions_assignee_user_id_users_id_fk", + "tableFrom": "task_definitions", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "task_definitions_created_by_users_id_fk": { + "name": "task_definitions_created_by_users_id_fk", + "tableFrom": "task_definitions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "task_definitions_freq_ck": { + "name": "task_definitions_freq_ck", + "value": "\"task_definitions\".\"frequency\" IN ('once', 'daily', 'weekly', 'monthly')" + }, + "task_definitions_due_ck": { + "name": "task_definitions_due_ck", + "value": "\"task_definitions\".\"due_time\" IS NULL OR \"task_definitions\".\"due_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "task_definitions_month_ck": { + "name": "task_definitions_month_ck", + "value": "\"task_definitions\".\"month_day\" IS NULL OR \"task_definitions\".\"month_day\" BETWEEN 1 AND 31" + } + }, + "isRLSEnabled": false + }, + "public.temperature_readings": { + "name": "temperature_readings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": true + }, + "temp_min": { + "name": "temp_min", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sensor_id": { + "name": "sensor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "temperature_readings_est_idx": { + "name": "temperature_readings_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_readings_eq_idx": { + "name": "temperature_readings_eq_idx", + "columns": [ + { + "expression": "equipment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_readings_sensor_idx": { + "name": "temperature_readings_sensor_idx", + "columns": [ + { + "expression": "sensor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "temperature_readings_organization_id_organizations_id_fk": { + "name": "temperature_readings_organization_id_organizations_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "temperature_readings_establishment_id_establishments_id_fk": { + "name": "temperature_readings_establishment_id_establishments_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_equipment_id_equipment_id_fk": { + "name": "temperature_readings_equipment_id_equipment_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_recorded_by_users_id_fk": { + "name": "temperature_readings_recorded_by_users_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "temperature_readings_sensor_id_temperature_sensors_id_fk": { + "name": "temperature_readings_sensor_id_temperature_sensors_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "temperature_sensors", + "columnsFrom": [ + "sensor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_cancelled_by_users_id_fk": { + "name": "temperature_readings_cancelled_by_users_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "temperature_readings_action_ck": { + "name": "temperature_readings_action_ck", + "value": "\"temperature_readings\".\"conform\" OR \"temperature_readings\".\"corrective_action\" IS NOT NULL OR \"temperature_readings\".\"sensor_id\" IS NOT NULL" + }, + "temperature_readings_author_ck": { + "name": "temperature_readings_author_ck", + "value": "\"temperature_readings\".\"recorded_by\" IS NOT NULL OR \"temperature_readings\".\"sensor_id\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.temperature_sensors": { + "name": "temperature_sensors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hint": { + "name": "token_hint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keep_every_minutes": { + "name": "keep_every_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 15 + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_temperature": { + "name": "last_temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "temperature_sensors_token_uq": { + "name": "temperature_sensors_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_sensors_est_idx": { + "name": "temperature_sensors_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "temperature_sensors_organization_id_organizations_id_fk": { + "name": "temperature_sensors_organization_id_organizations_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "temperature_sensors_establishment_id_establishments_id_fk": { + "name": "temperature_sensors_establishment_id_establishments_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_sensors_equipment_id_equipment_id_fk": { + "name": "temperature_sensors_equipment_id_equipment_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_sensors_created_by_users_id_fk": { + "name": "temperature_sensors_created_by_users_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "temperature_sensors_keep_ck": { + "name": "temperature_sensors_keep_ck", + "value": "\"temperature_sensors\".\"keep_every_minutes\" BETWEEN 1 AND 240" + } + }, + "isRLSEnabled": false + }, + "public.trace_labels": { + "name": "trace_labels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "taken_at": { + "name": "taken_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_size": { + "name": "photo_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "usage": { + "name": "usage", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "production_name": { + "name": "production_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "trace_labels_est_idx": { + "name": "trace_labels_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "taken_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "trace_labels_organization_id_organizations_id_fk": { + "name": "trace_labels_organization_id_organizations_id_fk", + "tableFrom": "trace_labels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "trace_labels_establishment_id_establishments_id_fk": { + "name": "trace_labels_establishment_id_establishments_id_fk", + "tableFrom": "trace_labels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "trace_labels_item_id_purchase_items_id_fk": { + "name": "trace_labels_item_id_purchase_items_id_fk", + "tableFrom": "trace_labels", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "trace_labels_recorded_by_users_id_fk": { + "name": "trace_labels_recorded_by_users_id_fk", + "tableFrom": "trace_labels", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "trace_labels_cancelled_by_users_id_fk": { + "name": "trace_labels_cancelled_by_users_id_fk", + "tableFrom": "trace_labels", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "trace_labels_usage_ck": { + "name": "trace_labels_usage_ck", + "value": "\"trace_labels\".\"usage\" IN ('reception', 'ouverture', 'production')" + }, + "trace_labels_size_ck": { + "name": "trace_labels_size_ck", + "value": "\"trace_labels\".\"photo_size\" IS NULL OR \"trace_labels\".\"photo_size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.treasury_settings": { + "name": "treasury_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "vat_regime": { + "name": "vat_regime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_due_day": { + "name": "vat_due_day", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "alert_threshold": { + "name": "alert_threshold", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "treasury_settings_est_uq": { + "name": "treasury_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "treasury_settings_organization_id_organizations_id_fk": { + "name": "treasury_settings_organization_id_organizations_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "treasury_settings_establishment_id_establishments_id_fk": { + "name": "treasury_settings_establishment_id_establishments_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "treasury_settings_updated_by_users_id_fk": { + "name": "treasury_settings_updated_by_users_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "treasury_settings_vat_ck": { + "name": "treasury_settings_vat_ck", + "value": "(\"treasury_settings\".\"vat_regime\" IS NULL OR \"treasury_settings\".\"vat_regime\" IN ('monthly', 'quarterly')) AND (\"treasury_settings\".\"vat_due_day\" IS NULL OR \"treasury_settings\".\"vat_due_day\" BETWEEN 1 AND 31)" + } + }, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "totp_secret_enc": { + "name": "totp_secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "totp_enabled_at": { + "name": "totp_enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "totp_last_step": { + "name": "totp_last_step", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "password_changed_at": { + "name": "password_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "failed_login_count": { + "name": "failed_login_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "disabled_at": { + "name": "disabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "message_emails": { + "name": "message_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notification_phone": { + "name": "notification_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seen_release": { + "name": "seen_release", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_login_at": { + "name": "last_login_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "platform_admin": { + "name": "platform_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "email_verification_pending": { + "name": "email_verification_pending", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by_organization_id": { + "name": "created_by_organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_lower_uq": { + "name": "users_email_lower_uq", + "columns": [ + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_created_by_organization_id_organizations_id_fk": { + "name": "users_created_by_organization_id_organizations_id_fk", + "tableFrom": "users", + "tableTo": "organizations", + "columnsFrom": [ + "created_by_organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.waiter_closings": { + "name": "waiter_closings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "waiter_label": { + "name": "waiter_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "waiter_key": { + "name": "waiter_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "groupe": { + "name": "groupe", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "cb": { + "name": "cb", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "especes": { + "name": "especes", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "autre": { + "name": "autre", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recorded_at": { + "name": "recorded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "waiter_closings_est_idx": { + "name": "waiter_closings_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "waiter_closings_organization_id_organizations_id_fk": { + "name": "waiter_closings_organization_id_organizations_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "waiter_closings_establishment_id_establishments_id_fk": { + "name": "waiter_closings_establishment_id_establishments_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "waiter_closings_recorded_by_users_id_fk": { + "name": "waiter_closings_recorded_by_users_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "waiter_closings_cancelled_by_users_id_fk": { + "name": "waiter_closings_cancelled_by_users_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "waiter_closings_amounts_ck": { + "name": "waiter_closings_amounts_ck", + "value": "\"waiter_closings\".\"groupe\" >= 0 AND \"waiter_closings\".\"cb\" >= 0 AND \"waiter_closings\".\"especes\" >= 0 AND \"waiter_closings\".\"autre\" >= 0" + }, + "waiter_closings_key_ck": { + "name": "waiter_closings_key_ck", + "value": "length(\"waiter_closings\".\"waiter_key\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + } + }, + "enums": { + "public.connection_status": { + "name": "connection_status", + "schema": "public", + "values": [ + "not_configured", + "pending_verification", + "connected", + "error", + "disabled" + ] + }, + "public.data_status": { + "name": "data_status", + "schema": "public", + "values": [ + "real_validated", + "real_unvalidated", + "provisional", + "estimated", + "forecast", + "missing" + ] + }, + "public.import_status": { + "name": "import_status", + "schema": "public", + "values": [ + "completed", + "rejected", + "reverted" + ] + }, + "public.member_role": { + "name": "member_role", + "schema": "public", + "values": [ + "owner", + "admin", + "director", + "manager", + "accountant", + "chef", + "staff", + "cuisine", + "viewer", + "rh", + "controller", + "purchasing" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/0127_snapshot.json b/drizzle/meta/0127_snapshot.json new file mode 100644 index 00000000..bd7800eb --- /dev/null +++ b/drizzle/meta/0127_snapshot.json @@ -0,0 +1,41875 @@ +{ + "id": "987a083c-d69a-457f-a738-f160f9074881", + "prevId": "b45a7d33-fc36-4907-b9f2-308b5cc43c17", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.absence_requests": { + "name": "absence_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "part": { + "name": "part", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'journee'" + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "absence_requests_emp_idx": { + "name": "absence_requests_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "absence_requests_organization_id_organizations_id_fk": { + "name": "absence_requests_organization_id_organizations_id_fk", + "tableFrom": "absence_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "absence_requests_employee_id_employees_id_fk": { + "name": "absence_requests_employee_id_employees_id_fk", + "tableFrom": "absence_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "absence_requests_decided_by_users_id_fk": { + "name": "absence_requests_decided_by_users_id_fk", + "tableFrom": "absence_requests", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "absence_requests_created_by_users_id_fk": { + "name": "absence_requests_created_by_users_id_fk", + "tableFrom": "absence_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "absence_requests_status_ck": { + "name": "absence_requests_status_ck", + "value": "\"absence_requests\".\"status\" IN ('en_attente', 'acceptee', 'refusee', 'annulee')" + }, + "absence_requests_dates_ck": { + "name": "absence_requests_dates_ck", + "value": "\"absence_requests\".\"end_date\" >= \"absence_requests\".\"start_date\"" + } + }, + "isRLSEnabled": false + }, + "public.account_invites": { + "name": "account_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'invite'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "account_invites_token_uq": { + "name": "account_invites_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "account_invites_user_idx": { + "name": "account_invites_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_invites_organization_id_organizations_id_fk": { + "name": "account_invites_organization_id_organizations_id_fk", + "tableFrom": "account_invites", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_invites_user_id_users_id_fk": { + "name": "account_invites_user_id_users_id_fk", + "tableFrom": "account_invites", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "account_invites_created_by_users_id_fk": { + "name": "account_invites_created_by_users_id_fk", + "tableFrom": "account_invites", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "account_invites_purpose_ck": { + "name": "account_invites_purpose_ck", + "value": "\"account_invites\".\"purpose\" IN ('invite', 'reset', 'verify')" + } + }, + "isRLSEnabled": false + }, + "public.ai_actions": { + "name": "ai_actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "source_href": { + "name": "source_href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "discard_reason": { + "name": "discard_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_actions_org_idx": { + "name": "ai_actions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_actions_pending_uq": { + "name": "ai_actions_pending_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"ai_actions\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_actions_organization_id_organizations_id_fk": { + "name": "ai_actions_organization_id_organizations_id_fk", + "tableFrom": "ai_actions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_actions_created_by_users_id_fk": { + "name": "ai_actions_created_by_users_id_fk", + "tableFrom": "ai_actions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "ai_actions_decided_by_users_id_fk": { + "name": "ai_actions_decided_by_users_id_fk", + "tableFrom": "ai_actions", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_actions_kind_ck": { + "name": "ai_actions_kind_ck", + "value": "\"ai_actions\".\"kind\" IN ('negotiation_email', 'price_change')" + }, + "ai_actions_status_ck": { + "name": "ai_actions_status_ck", + "value": "\"ai_actions\".\"status\" IN ('pending', 'sent', 'applied', 'done_manual', 'discarded')" + }, + "ai_actions_decided_ck": { + "name": "ai_actions_decided_ck", + "value": "\"ai_actions\".\"status\" = 'pending' OR \"ai_actions\".\"decided_at\" IS NOT NULL" + }, + "ai_actions_discarded_ck": { + "name": "ai_actions_discarded_ck", + "value": "\"ai_actions\".\"status\" <> 'discarded' OR \"ai_actions\".\"discard_reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.ai_conversations": { + "name": "ai_conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_conversations_user_idx": { + "name": "ai_conversations_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_conversations_organization_id_organizations_id_fk": { + "name": "ai_conversations_organization_id_organizations_id_fk", + "tableFrom": "ai_conversations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_conversations_user_id_users_id_fk": { + "name": "ai_conversations_user_id_users_id_fk", + "tableFrom": "ai_conversations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ai_messages": { + "name": "ai_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tools": { + "name": "tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_messages_conv_idx": { + "name": "ai_messages_conv_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ai_messages_org_idx": { + "name": "ai_messages_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_messages_organization_id_organizations_id_fk": { + "name": "ai_messages_organization_id_organizations_id_fk", + "tableFrom": "ai_messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_messages_conversation_id_ai_conversations_id_fk": { + "name": "ai_messages_conversation_id_ai_conversations_id_fk", + "tableFrom": "ai_messages", + "tableTo": "ai_conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_messages_role_ck": { + "name": "ai_messages_role_ck", + "value": "\"ai_messages\".\"role\" IN ('user', 'assistant')" + } + }, + "isRLSEnabled": false + }, + "public.ai_reco_dismissals": { + "name": "ai_reco_dismissals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reco_id": { + "name": "reco_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "until": { + "name": "until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "dismissed_by": { + "name": "dismissed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ai_reco_dismissals_uq": { + "name": "ai_reco_dismissals_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reco_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ai_reco_dismissals_organization_id_organizations_id_fk": { + "name": "ai_reco_dismissals_organization_id_organizations_id_fk", + "tableFrom": "ai_reco_dismissals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ai_reco_dismissals_dismissed_by_users_id_fk": { + "name": "ai_reco_dismissals_dismissed_by_users_id_fk", + "tableFrom": "ai_reco_dismissals", + "tableTo": "users", + "columnsFrom": [ + "dismissed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ai_reco_dismissals_reason_ck": { + "name": "ai_reco_dismissals_reason_ck", + "value": "length(trim(\"ai_reco_dismissals\".\"reason\")) >= 3" + } + }, + "isRLSEnabled": false + }, + "public.allergen_pages": { + "name": "allergen_pages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "allergen_pages_token_uq": { + "name": "allergen_pages_token_uq", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "allergen_pages_est_uq": { + "name": "allergen_pages_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "allergen_pages_organization_id_organizations_id_fk": { + "name": "allergen_pages_organization_id_organizations_id_fk", + "tableFrom": "allergen_pages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "allergen_pages_establishment_id_establishments_id_fk": { + "name": "allergen_pages_establishment_id_establishments_id_fk", + "tableFrom": "allergen_pages", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "allergen_pages_created_by_users_id_fk": { + "name": "allergen_pages_created_by_users_id_fk", + "tableFrom": "allergen_pages", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "before": { + "name": "before", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "after": { + "name": "after", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_org_idx": { + "name": "audit_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_log_organization_id_organizations_id_fk": { + "name": "audit_log_organization_id_organizations_id_fk", + "tableFrom": "audit_log", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "audit_log_user_id_users_id_fk": { + "name": "audit_log_user_id_users_id_fk", + "tableFrom": "audit_log", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_throttle": { + "name": "auth_throttle", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_throttle_ip_idx": { + "name": "auth_throttle_ip_idx", + "columns": [ + { + "expression": "ip", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "approver_id": { + "name": "approver_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "delivered": { + "name": "delivered", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_approvals_once_uq": { + "name": "automation_approvals_once_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_approvals_org_idx": { + "name": "automation_approvals_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_approvals_organization_id_organizations_id_fk": { + "name": "automation_approvals_organization_id_organizations_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_approvals_rule_id_automation_rules_id_fk": { + "name": "automation_approvals_rule_id_automation_rules_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_approvals_approver_id_users_id_fk": { + "name": "automation_approvals_approver_id_users_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "users", + "columnsFrom": [ + "approver_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "automation_approvals_decided_by_users_id_fk": { + "name": "automation_approvals_decided_by_users_id_fk", + "tableFrom": "automation_approvals", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_approvals_status_ck": { + "name": "automation_approvals_status_ck", + "value": "\"automation_approvals\".\"status\" IN ('pending', 'approved', 'rejected')" + }, + "automation_approvals_reason_ck": { + "name": "automation_approvals_reason_ck", + "value": "\"automation_approvals\".\"status\" <> 'rejected' OR \"automation_approvals\".\"reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.automation_drafts": { + "name": "automation_drafts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rule_name": { + "name": "rule_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "source_href": { + "name": "source_href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prepared_for": { + "name": "prepared_for", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "discard_reason": { + "name": "discard_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_entity_type": { + "name": "result_entity_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_entity_id": { + "name": "result_entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_drafts_org_idx": { + "name": "automation_drafts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_drafts_est_idx": { + "name": "automation_drafts_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_drafts_organization_id_organizations_id_fk": { + "name": "automation_drafts_organization_id_organizations_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_drafts_establishment_id_establishments_id_fk": { + "name": "automation_drafts_establishment_id_establishments_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_drafts_rule_id_automation_rules_id_fk": { + "name": "automation_drafts_rule_id_automation_rules_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "automation_drafts_prepared_for_users_id_fk": { + "name": "automation_drafts_prepared_for_users_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "users", + "columnsFrom": [ + "prepared_for" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "automation_drafts_decided_by_users_id_fk": { + "name": "automation_drafts_decided_by_users_id_fk", + "tableFrom": "automation_drafts", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_drafts_kind_ck": { + "name": "automation_drafts_kind_ck", + "value": "\"automation_drafts\".\"kind\" IN ('purchase_order', 'credit_request', 'maintenance_request')" + }, + "automation_drafts_status_ck": { + "name": "automation_drafts_status_ck", + "value": "\"automation_drafts\".\"status\" IN ('pending', 'validated', 'discarded', 'expired')" + }, + "automation_drafts_validated_ck": { + "name": "automation_drafts_validated_ck", + "value": "\"automation_drafts\".\"status\" <> 'validated' OR (\"automation_drafts\".\"decided_by\" IS NOT NULL AND \"automation_drafts\".\"result_entity_type\" IS NOT NULL)" + }, + "automation_drafts_discarded_ck": { + "name": "automation_drafts_discarded_ck", + "value": "\"automation_drafts\".\"status\" <> 'discarded' OR \"automation_drafts\".\"discard_reason\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.automation_occurrences": { + "name": "automation_occurrences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "occurrence_key": { + "name": "occurrence_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "draft_id": { + "name": "draft_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_occurrences_uq": { + "name": "automation_occurrences_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_occurrences_org_key_idx": { + "name": "automation_occurrences_org_key_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_occurrences_organization_id_organizations_id_fk": { + "name": "automation_occurrences_organization_id_organizations_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_occurrences_rule_id_automation_rules_id_fk": { + "name": "automation_occurrences_rule_id_automation_rules_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_occurrences_draft_id_automation_drafts_id_fk": { + "name": "automation_occurrences_draft_id_automation_drafts_id_fk", + "tableFrom": "automation_occurrences", + "tableTo": "automation_drafts", + "columnsFrom": [ + "draft_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_pending": { + "name": "automation_pending", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_pending_org_idx": { + "name": "automation_pending_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_pending_organization_id_organizations_id_fk": { + "name": "automation_pending_organization_id_organizations_id_fk", + "tableFrom": "automation_pending", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_pending_rule_id_automation_rules_id_fk": { + "name": "automation_pending_rule_id_automation_rules_id_fk", + "tableFrom": "automation_pending", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_pending_user_id_users_id_fk": { + "name": "automation_pending_user_id_users_id_fk", + "tableFrom": "automation_pending", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "automation_pending_rule_id_user_id_item_key_pk": { + "name": "automation_pending_rule_id_user_id_item_key_pk", + "columns": [ + "rule_id", + "user_id", + "item_key" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_rules": { + "name": "automation_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "min_severity": { + "name": "min_severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'warning'" + }, + "recipient_ids": { + "name": "recipient_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "by_email": { + "name": "by_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'notify'" + }, + "params": { + "name": "params", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conditions": { + "name": "conditions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "delay_minutes": { + "name": "delay_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "approver_id": { + "name": "approver_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_triggered_at": { + "name": "last_triggered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_rules_org_idx": { + "name": "automation_rules_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_rules_organization_id_organizations_id_fk": { + "name": "automation_rules_organization_id_organizations_id_fk", + "tableFrom": "automation_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_rules_establishment_id_establishments_id_fk": { + "name": "automation_rules_establishment_id_establishments_id_fk", + "tableFrom": "automation_rules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_rules_approver_id_users_id_fk": { + "name": "automation_rules_approver_id_users_id_fk", + "tableFrom": "automation_rules", + "tableTo": "users", + "columnsFrom": [ + "approver_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "automation_rules_created_by_users_id_fk": { + "name": "automation_rules_created_by_users_id_fk", + "tableFrom": "automation_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "automation_rules_severity_ck": { + "name": "automation_rules_severity_ck", + "value": "\"automation_rules\".\"min_severity\" IN ('warning', 'danger')" + }, + "automation_rules_action_ck": { + "name": "automation_rules_action_ck", + "value": "\"automation_rules\".\"action\" IN ('notify', 'draft_purchase_order', 'draft_credit_request', 'draft_maintenance_request')" + }, + "automation_rules_delay_ck": { + "name": "automation_rules_delay_ck", + "value": "\"automation_rules\".\"delay_minutes\" >= 0 AND \"automation_rules\".\"delay_minutes\" <= 10080" + } + }, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rule_id": { + "name": "rule_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "item_key": { + "name": "item_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emailed": { + "name": "emailed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "automation_runs_once_uq": { + "name": "automation_runs_once_uq", + "columns": [ + { + "expression": "rule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automation_runs_org_idx": { + "name": "automation_runs_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "automation_runs_organization_id_organizations_id_fk": { + "name": "automation_runs_organization_id_organizations_id_fk", + "tableFrom": "automation_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_runs_rule_id_automation_rules_id_fk": { + "name": "automation_runs_rule_id_automation_rules_id_fk", + "tableFrom": "automation_runs", + "tableTo": "automation_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_runs_user_id_users_id_fk": { + "name": "automation_runs_user_id_users_id_fk", + "tableFrom": "automation_runs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_settings": { + "name": "automation_settings", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "paused": { + "name": "paused", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_by": { + "name": "paused_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "paused_at": { + "name": "paused_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "automation_settings_organization_id_organizations_id_fk": { + "name": "automation_settings_organization_id_organizations_id_fk", + "tableFrom": "automation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "automation_settings_paused_by_users_id_fk": { + "name": "automation_settings_paused_by_users_id_fk", + "tableFrom": "automation_settings", + "tableTo": "users", + "columnsFrom": [ + "paused_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bank_accounts": { + "name": "bank_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bank_name": { + "name": "bank_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban_last4": { + "name": "iban_last4", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "opening_balance": { + "name": "opening_balance", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "opening_date": { + "name": "opening_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "alert_threshold": { + "name": "alert_threshold", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_accounts_org_idx": { + "name": "bank_accounts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_accounts_organization_id_organizations_id_fk": { + "name": "bank_accounts_organization_id_organizations_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_accounts_establishment_id_establishments_id_fk": { + "name": "bank_accounts_establishment_id_establishments_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_accounts_created_by_users_id_fk": { + "name": "bank_accounts_created_by_users_id_fk", + "tableFrom": "bank_accounts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_accounts_iban_ck": { + "name": "bank_accounts_iban_ck", + "value": "\"bank_accounts\".\"iban_last4\" IS NULL OR \"bank_accounts\".\"iban_last4\" ~ '^[0-9A-Z]{4}$'" + } + }, + "isRLSEnabled": false + }, + "public.bank_imports": { + "name": "bank_imports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_sha256": { + "name": "file_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rows_total": { + "name": "rows_total", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "rows_inserted": { + "name": "rows_inserted", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "period_from": { + "name": "period_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "period_to": { + "name": "period_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_imports_account_idx": { + "name": "bank_imports_account_idx", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_imports_organization_id_organizations_id_fk": { + "name": "bank_imports_organization_id_organizations_id_fk", + "tableFrom": "bank_imports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_imports_account_id_bank_accounts_id_fk": { + "name": "bank_imports_account_id_bank_accounts_id_fk", + "tableFrom": "bank_imports", + "tableTo": "bank_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_imports_created_by_users_id_fk": { + "name": "bank_imports_created_by_users_id_fk", + "tableFrom": "bank_imports", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.bank_rules": { + "name": "bank_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'any'" + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_rules_uq": { + "name": "bank_rules_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"keyword\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "direction", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_rules_organization_id_organizations_id_fk": { + "name": "bank_rules_organization_id_organizations_id_fk", + "tableFrom": "bank_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_rules_created_by_users_id_fk": { + "name": "bank_rules_created_by_users_id_fk", + "tableFrom": "bank_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_rules_direction_ck": { + "name": "bank_rules_direction_ck", + "value": "\"bank_rules\".\"direction\" IN ('in', 'out', 'any')" + } + }, + "isRLSEnabled": false + }, + "public.bank_transactions": { + "name": "bank_transactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "import_id": { + "name": "import_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "booking_date": { + "name": "booking_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "value_date": { + "name": "value_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "balance_after": { + "name": "balance_after", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category_source": { + "name": "category_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "bank_tx_row_uq": { + "name": "bank_tx_row_uq", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "bank_tx_invoice_uq": { + "name": "bank_tx_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"bank_transactions\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "bank_tx_period_idx": { + "name": "bank_tx_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "booking_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "bank_transactions_organization_id_organizations_id_fk": { + "name": "bank_transactions_organization_id_organizations_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "bank_transactions_establishment_id_establishments_id_fk": { + "name": "bank_transactions_establishment_id_establishments_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_account_id_bank_accounts_id_fk": { + "name": "bank_transactions_account_id_bank_accounts_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "bank_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_import_id_bank_imports_id_fk": { + "name": "bank_transactions_import_id_bank_imports_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "bank_imports", + "columnsFrom": [ + "import_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "bank_transactions_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "bank_transactions_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "bank_transactions", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "bank_tx_amount_ck": { + "name": "bank_tx_amount_ck", + "value": "\"bank_transactions\".\"amount\" <> 0" + } + }, + "isRLSEnabled": false + }, + "public.booking_button_clicks": { + "name": "booking_button_clicks", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "placement": { + "name": "placement", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "clicks": { + "name": "clicks", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "booking_button_clicks_establishment_id_establishments_id_fk": { + "name": "booking_button_clicks_establishment_id_establishments_id_fk", + "tableFrom": "booking_button_clicks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_button_clicks_organization_id_organizations_id_fk": { + "name": "booking_button_clicks_organization_id_organizations_id_fk", + "tableFrom": "booking_button_clicks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "booking_button_clicks_establishment_id_day_placement_target_pk": { + "name": "booking_button_clicks_establishment_id_day_placement_target_pk", + "columns": [ + "establishment_id", + "day", + "placement", + "target" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "booking_button_clicks_placement_ck": { + "name": "booking_button_clicks_placement_ck", + "value": "\"booking_button_clicks\".\"placement\" IN ('instagram', 'google', 'site')" + }, + "booking_button_clicks_target_ck": { + "name": "booking_button_clicks_target_ck", + "value": "\"booking_button_clicks\".\"target\" IN ('altair', 'thefork', 'opentable', 'zenchef')" + } + }, + "isRLSEnabled": false + }, + "public.booking_channels": { + "name": "booking_channels", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "instagram_target": { + "name": "instagram_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "google_target": { + "name": "google_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "site_target": { + "name": "site_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'altair'" + }, + "thefork_url": { + "name": "thefork_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "opentable_url": { + "name": "opentable_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "zenchef_url": { + "name": "zenchef_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "booking_channels_establishment_id_establishments_id_fk": { + "name": "booking_channels_establishment_id_establishments_id_fk", + "tableFrom": "booking_channels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_channels_organization_id_organizations_id_fk": { + "name": "booking_channels_organization_id_organizations_id_fk", + "tableFrom": "booking_channels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "booking_channels_updated_by_users_id_fk": { + "name": "booking_channels_updated_by_users_id_fk", + "tableFrom": "booking_channels", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "booking_channels_targets_ck": { + "name": "booking_channels_targets_ck", + "value": "\"booking_channels\".\"instagram_target\" IN ('altair', 'thefork', 'opentable', 'zenchef') AND \"booking_channels\".\"google_target\" IN ('altair', 'thefork', 'opentable', 'zenchef') AND \"booking_channels\".\"site_target\" IN ('altair', 'thefork', 'opentable', 'zenchef')" + }, + "booking_channels_urls_ck": { + "name": "booking_channels_urls_ck", + "value": "(\"booking_channels\".\"thefork_url\" IS NULL OR \"booking_channels\".\"thefork_url\" LIKE 'https://%') AND (\"booking_channels\".\"opentable_url\" IS NULL OR \"booking_channels\".\"opentable_url\" LIKE 'https://%') AND (\"booking_channels\".\"zenchef_url\" IS NULL OR \"booking_channels\".\"zenchef_url\" LIKE 'https://%')" + } + }, + "isRLSEnabled": false + }, + "public.business_document_versions": { + "name": "business_document_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version_no": { + "name": "version_no", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "replaced_by": { + "name": "replaced_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "replaced_at": { + "name": "replaced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "business_document_versions_uq": { + "name": "business_document_versions_uq", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version_no", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_document_versions_sha_idx": { + "name": "business_document_versions_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "business_document_versions_organization_id_organizations_id_fk": { + "name": "business_document_versions_organization_id_organizations_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "business_document_versions_document_id_business_documents_id_fk": { + "name": "business_document_versions_document_id_business_documents_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "business_document_versions_replaced_by_users_id_fk": { + "name": "business_document_versions_replaced_by_users_id_fk", + "tableFrom": "business_document_versions", + "tableTo": "users", + "columnsFrom": [ + "replaced_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "business_document_versions_size_ck": { + "name": "business_document_versions_size_ck", + "value": "\"business_document_versions\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.business_documents": { + "name": "business_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "party": { + "name": "party", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference": { + "name": "reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "issued_on": { + "name": "issued_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "expires_on": { + "name": "expires_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reminder_days": { + "name": "reminder_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "annual_cost": { + "name": "annual_cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_version": { + "name": "file_version", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notice_on": { + "name": "notice_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "sensitivity": { + "name": "sensitivity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'normal'" + }, + "duplicate_of_id": { + "name": "duplicate_of_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "replaced_by_id": { + "name": "replaced_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "checklist_code": { + "name": "checklist_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "business_documents_org_idx": { + "name": "business_documents_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_documents_checklist_uq": { + "name": "business_documents_checklist_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checklist_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"business_documents\".\"checklist_code\" IS NOT NULL AND \"business_documents\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_documents_sha_idx": { + "name": "business_documents_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "business_documents_organization_id_organizations_id_fk": { + "name": "business_documents_organization_id_organizations_id_fk", + "tableFrom": "business_documents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "business_documents_establishment_id_establishments_id_fk": { + "name": "business_documents_establishment_id_establishments_id_fk", + "tableFrom": "business_documents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "business_documents_duplicate_of_id_business_documents_id_fk": { + "name": "business_documents_duplicate_of_id_business_documents_id_fk", + "tableFrom": "business_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "duplicate_of_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "business_documents_replaced_by_id_business_documents_id_fk": { + "name": "business_documents_replaced_by_id_business_documents_id_fk", + "tableFrom": "business_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "replaced_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "business_documents_created_by_users_id_fk": { + "name": "business_documents_created_by_users_id_fk", + "tableFrom": "business_documents", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "business_documents_size_ck": { + "name": "business_documents_size_ck", + "value": "\"business_documents\".\"size\" IS NULL OR \"business_documents\".\"size\" <= 5242880" + }, + "business_documents_reminder_ck": { + "name": "business_documents_reminder_ck", + "value": "\"business_documents\".\"reminder_days\" BETWEEN 0 AND 365" + }, + "business_documents_sensitivity_ck": { + "name": "business_documents_sensitivity_ck", + "value": "\"business_documents\".\"sensitivity\" IN ('normal', 'confidentiel', 'restreint')" + }, + "business_documents_notice_ck": { + "name": "business_documents_notice_ck", + "value": "\"business_documents\".\"notice_on\" IS NULL OR \"business_documents\".\"expires_on\" IS NULL OR \"business_documents\".\"notice_on\" <= \"business_documents\".\"expires_on\"" + } + }, + "isRLSEnabled": false + }, + "public.campaign_recipients": { + "name": "campaign_recipients", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "campaign_id": { + "name": "campaign_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unsubscribe_token_hash": { + "name": "unsubscribe_token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unsubscribed_at": { + "name": "unsubscribed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "campaign_recipients_token_uq": { + "name": "campaign_recipients_token_uq", + "columns": [ + { + "expression": "unsubscribe_token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "campaign_recipients_campaign_customer_uq": { + "name": "campaign_recipients_campaign_customer_uq", + "columns": [ + { + "expression": "campaign_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "campaign_recipients_customer_idx": { + "name": "campaign_recipients_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "campaign_recipients_organization_id_organizations_id_fk": { + "name": "campaign_recipients_organization_id_organizations_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "campaign_recipients_campaign_id_marketing_campaigns_id_fk": { + "name": "campaign_recipients_campaign_id_marketing_campaigns_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "marketing_campaigns", + "columnsFrom": [ + "campaign_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "campaign_recipients_customer_id_customers_id_fk": { + "name": "campaign_recipients_customer_id_customers_id_fk", + "tableFrom": "campaign_recipients", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.candidates": { + "name": "candidates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "job_opening_id": { + "name": "job_opening_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'nouveau'" + }, + "stage_changed_at": { + "name": "stage_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "interview_at": { + "name": "interview_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "rating": { + "name": "rating", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refusal_reason": { + "name": "refusal_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_contact_at": { + "name": "last_contact_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "candidates_org_idx": { + "name": "candidates_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stage", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "candidates_opening_idx": { + "name": "candidates_opening_idx", + "columns": [ + { + "expression": "job_opening_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "candidates_organization_id_organizations_id_fk": { + "name": "candidates_organization_id_organizations_id_fk", + "tableFrom": "candidates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidates_establishment_id_establishments_id_fk": { + "name": "candidates_establishment_id_establishments_id_fk", + "tableFrom": "candidates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "candidates_job_opening_id_job_openings_id_fk": { + "name": "candidates_job_opening_id_job_openings_id_fk", + "tableFrom": "candidates", + "tableTo": "job_openings", + "columnsFrom": [ + "job_opening_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidates_employee_id_employees_id_fk": { + "name": "candidates_employee_id_employees_id_fk", + "tableFrom": "candidates", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "candidates_created_by_users_id_fk": { + "name": "candidates_created_by_users_id_fk", + "tableFrom": "candidates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "candidates_stage_ck": { + "name": "candidates_stage_ck", + "value": "\"candidates\".\"stage\" IN ('nouveau', 'preselection', 'entretien', 'essai', 'offre', 'embauche', 'refuse', 'desiste')" + }, + "candidates_rating_ck": { + "name": "candidates_rating_ck", + "value": "\"candidates\".\"rating\" IS NULL OR \"candidates\".\"rating\" BETWEEN 1 AND 5" + } + }, + "isRLSEnabled": false + }, + "public.cash_counts": { + "name": "cash_counts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "denominations": { + "name": "denominations", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "counted_total": { + "name": "counted_total", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "counted_by": { + "name": "counted_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counted_at": { + "name": "counted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_counts_est_idx": { + "name": "cash_counts_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_counts_organization_id_organizations_id_fk": { + "name": "cash_counts_organization_id_organizations_id_fk", + "tableFrom": "cash_counts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_counts_establishment_id_establishments_id_fk": { + "name": "cash_counts_establishment_id_establishments_id_fk", + "tableFrom": "cash_counts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_counts_counted_by_users_id_fk": { + "name": "cash_counts_counted_by_users_id_fk", + "tableFrom": "cash_counts", + "tableTo": "users", + "columnsFrom": [ + "counted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cash_counts_cancelled_by_users_id_fk": { + "name": "cash_counts_cancelled_by_users_id_fk", + "tableFrom": "cash_counts", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_counts_kind_ck": { + "name": "cash_counts_kind_ck", + "value": "\"cash_counts\".\"kind\" IN ('fermeture', 'ouverture')" + }, + "cash_counts_amounts_ck": { + "name": "cash_counts_amounts_ck", + "value": "\"cash_counts\".\"counted_total\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.cash_plan_items": { + "name": "cash_plan_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "recurrence": { + "name": "recurrence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'once'" + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_plan_org_idx": { + "name": "cash_plan_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_plan_items_organization_id_organizations_id_fk": { + "name": "cash_plan_items_organization_id_organizations_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_plan_items_establishment_id_establishments_id_fk": { + "name": "cash_plan_items_establishment_id_establishments_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_plan_items_created_by_users_id_fk": { + "name": "cash_plan_items_created_by_users_id_fk", + "tableFrom": "cash_plan_items", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_plan_recurrence_ck": { + "name": "cash_plan_recurrence_ck", + "value": "\"cash_plan_items\".\"recurrence\" IN ('once', 'weekly', 'monthly', 'quarterly')" + }, + "cash_plan_amount_ck": { + "name": "cash_plan_amount_ck", + "value": "\"cash_plan_items\".\"amount\" <> 0" + }, + "cash_plan_end_ck": { + "name": "cash_plan_end_ck", + "value": "\"cash_plan_items\".\"end_date\" IS NULL OR \"cash_plan_items\".\"end_date\" >= \"cash_plan_items\".\"start_date\"" + } + }, + "isRLSEnabled": false + }, + "public.cash_withdrawals": { + "name": "cash_withdrawals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recorded_at": { + "name": "recorded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cash_withdrawals_est_idx": { + "name": "cash_withdrawals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cash_withdrawals_organization_id_organizations_id_fk": { + "name": "cash_withdrawals_organization_id_organizations_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cash_withdrawals_establishment_id_establishments_id_fk": { + "name": "cash_withdrawals_establishment_id_establishments_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cash_withdrawals_recorded_by_users_id_fk": { + "name": "cash_withdrawals_recorded_by_users_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cash_withdrawals_cancelled_by_users_id_fk": { + "name": "cash_withdrawals_cancelled_by_users_id_fk", + "tableFrom": "cash_withdrawals", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cash_withdrawals_kind_ck": { + "name": "cash_withdrawals_kind_ck", + "value": "\"cash_withdrawals\".\"kind\" IN ('fournisseur', 'banque', 'pourboires', 'avance', 'autre')" + }, + "cash_withdrawals_amount_ck": { + "name": "cash_withdrawals_amount_ck", + "value": "\"cash_withdrawals\".\"amount\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.catalog_price_changes": { + "name": "catalog_price_changes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "old_price_ht": { + "name": "old_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "new_price_ht": { + "name": "new_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "catalog_price_changes_org_idx": { + "name": "catalog_price_changes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "catalog_price_changes_organization_id_organizations_id_fk": { + "name": "catalog_price_changes_organization_id_organizations_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "catalog_price_changes_item_id_purchase_items_id_fk": { + "name": "catalog_price_changes_item_id_purchase_items_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "catalog_price_changes_supplier_id_suppliers_id_fk": { + "name": "catalog_price_changes_supplier_id_suppliers_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "catalog_price_changes_created_by_users_id_fk": { + "name": "catalog_price_changes_created_by_users_id_fk", + "tableFrom": "catalog_price_changes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "catalog_price_changes_source_ck": { + "name": "catalog_price_changes_source_ck", + "value": "\"catalog_price_changes\".\"source\" IN ('import', 'manual')" + }, + "catalog_price_changes_price_ck": { + "name": "catalog_price_changes_price_ck", + "value": "\"catalog_price_changes\".\"new_price_ht\" >= 0 AND (\"catalog_price_changes\".\"old_price_ht\" IS NULL OR \"catalog_price_changes\".\"old_price_ht\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.checklist_run_photos": { + "name": "checklist_run_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_index": { + "name": "item_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_run_photos_uq": { + "name": "checklist_run_photos_uq", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_run_photos_organization_id_organizations_id_fk": { + "name": "checklist_run_photos_organization_id_organizations_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_run_photos_establishment_id_establishments_id_fk": { + "name": "checklist_run_photos_establishment_id_establishments_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_run_photos_run_id_checklist_runs_id_fk": { + "name": "checklist_run_photos_run_id_checklist_runs_id_fk", + "tableFrom": "checklist_run_photos", + "tableTo": "checklist_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checklist_runs": { + "name": "checklist_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "answers": { + "name": "answers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "yes_count": { + "name": "yes_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "no_count": { + "name": "no_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "na_count": { + "name": "na_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moment": { + "name": "moment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_count": { + "name": "photo_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_runs_est_idx": { + "name": "checklist_runs_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_runs_organization_id_organizations_id_fk": { + "name": "checklist_runs_organization_id_organizations_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_runs_establishment_id_establishments_id_fk": { + "name": "checklist_runs_establishment_id_establishments_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_runs_template_id_checklist_templates_id_fk": { + "name": "checklist_runs_template_id_checklist_templates_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "checklist_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_runs_recorded_by_users_id_fk": { + "name": "checklist_runs_recorded_by_users_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "checklist_runs_cancelled_by_users_id_fk": { + "name": "checklist_runs_cancelled_by_users_id_fk", + "tableFrom": "checklist_runs", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.checklist_templates": { + "name": "checklist_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "items": { + "name": "items", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "due_by": { + "name": "due_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "moment": { + "name": "moment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_items": { + "name": "photo_items", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "checklist_templates_est_idx": { + "name": "checklist_templates_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "checklist_templates_organization_id_organizations_id_fk": { + "name": "checklist_templates_organization_id_organizations_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "checklist_templates_establishment_id_establishments_id_fk": { + "name": "checklist_templates_establishment_id_establishments_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "checklist_templates_created_by_users_id_fk": { + "name": "checklist_templates_created_by_users_id_fk", + "tableFrom": "checklist_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "checklist_templates_moment_ck": { + "name": "checklist_templates_moment_ck", + "value": "\"checklist_templates\".\"moment\" IS NULL OR \"checklist_templates\".\"moment\" IN ('ouverture', 'service', 'fermeture')" + } + }, + "isRLSEnabled": false + }, + "public.cleaning_records": { + "name": "cleaning_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_records_est_idx": { + "name": "cleaning_records_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cleaning_records_task_idx": { + "name": "cleaning_records_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "done_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_records_organization_id_organizations_id_fk": { + "name": "cleaning_records_organization_id_organizations_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_records_establishment_id_establishments_id_fk": { + "name": "cleaning_records_establishment_id_establishments_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cleaning_records_task_id_cleaning_tasks_id_fk": { + "name": "cleaning_records_task_id_cleaning_tasks_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "cleaning_tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "cleaning_records_recorded_by_users_id_fk": { + "name": "cleaning_records_recorded_by_users_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cleaning_records_cancelled_by_users_id_fk": { + "name": "cleaning_records_cancelled_by_users_id_fk", + "tableFrom": "cleaning_records", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cleaning_tasks": { + "name": "cleaning_tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "due_by": { + "name": "due_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_tasks_zone_idx": { + "name": "cleaning_tasks_zone_idx", + "columns": [ + { + "expression": "zone_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_tasks_organization_id_organizations_id_fk": { + "name": "cleaning_tasks_organization_id_organizations_id_fk", + "tableFrom": "cleaning_tasks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_tasks_zone_id_cleaning_zones_id_fk": { + "name": "cleaning_tasks_zone_id_cleaning_zones_id_fk", + "tableFrom": "cleaning_tasks", + "tableTo": "cleaning_zones", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "cleaning_tasks_freq_ck": { + "name": "cleaning_tasks_freq_ck", + "value": "\"cleaning_tasks\".\"frequency\" IN ('service', 'jour', 'semaine', 'mois')" + } + }, + "isRLSEnabled": false + }, + "public.cleaning_zones": { + "name": "cleaning_zones", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cleaning_zones_est_idx": { + "name": "cleaning_zones_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cleaning_zones_organization_id_organizations_id_fk": { + "name": "cleaning_zones_organization_id_organizations_id_fk", + "tableFrom": "cleaning_zones", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cleaning_zones_establishment_id_establishments_id_fk": { + "name": "cleaning_zones_establishment_id_establishments_id_fk", + "tableFrom": "cleaning_zones", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.clock_event_photos": { + "name": "clock_event_photos", + "schema": "", + "columns": { + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "clock_event_photos_org_idx": { + "name": "clock_event_photos_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "clock_event_photos_event_id_clock_events_id_fk": { + "name": "clock_event_photos_event_id_clock_events_id_fk", + "tableFrom": "clock_event_photos", + "tableTo": "clock_events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_event_photos_organization_id_organizations_id_fk": { + "name": "clock_event_photos_organization_id_organizations_id_fk", + "tableFrom": "clock_event_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "clock_event_photos_size_ck": { + "name": "clock_event_photos_size_ck", + "value": "octet_length(\"clock_event_photos\".\"data\") <= 307200" + } + }, + "isRLSEnabled": false + }, + "public.clock_events": { + "name": "clock_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ok'" + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "geo_distance_m": { + "name": "geo_distance_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "geo_accuracy_m": { + "name": "geo_accuracy_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "clock_events_est_day_idx": { + "name": "clock_events_est_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "clock_events_emp_day_idx": { + "name": "clock_events_emp_day_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "clock_events_organization_id_organizations_id_fk": { + "name": "clock_events_organization_id_organizations_id_fk", + "tableFrom": "clock_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_establishment_id_establishments_id_fk": { + "name": "clock_events_establishment_id_establishments_id_fk", + "tableFrom": "clock_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_employee_id_employees_id_fk": { + "name": "clock_events_employee_id_employees_id_fk", + "tableFrom": "clock_events", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_events_created_by_users_id_fk": { + "name": "clock_events_created_by_users_id_fk", + "tableFrom": "clock_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "clock_events_reviewed_by_users_id_fk": { + "name": "clock_events_reviewed_by_users_id_fk", + "tableFrom": "clock_events", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "clock_events_kind_ck": { + "name": "clock_events_kind_ck", + "value": "\"clock_events\".\"kind\" IN ('in', 'break_start', 'break_end', 'out')" + }, + "clock_events_source_ck": { + "name": "clock_events_source_ck", + "value": "\"clock_events\".\"source\" IN ('borne', 'manuel', 'hors_ligne', 'qr', 'telephone')" + }, + "clock_events_status_ck": { + "name": "clock_events_status_ck", + "value": "\"clock_events\".\"status\" IN ('ok', 'a_valider', 'annule')" + } + }, + "isRLSEnabled": false + }, + "public.clock_pins": { + "name": "clock_pins", + "schema": "", + "columns": { + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pin_hash": { + "name": "pin_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "failed_attempts": { + "name": "failed_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "clock_pins_employee_id_employees_id_fk": { + "name": "clock_pins_employee_id_employees_id_fk", + "tableFrom": "clock_pins", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_pins_organization_id_organizations_id_fk": { + "name": "clock_pins_organization_id_organizations_id_fk", + "tableFrom": "clock_pins", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_pins_updated_by_users_id_fk": { + "name": "clock_pins_updated_by_users_id_fk", + "tableFrom": "clock_pins", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.clock_qr_settings": { + "name": "clock_qr_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone_enabled": { + "name": "phone_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "geo_lat": { + "name": "geo_lat", + "type": "numeric(9, 6)", + "primaryKey": false, + "notNull": false + }, + "geo_lng": { + "name": "geo_lng", + "type": "numeric(9, 6)", + "primaryKey": false, + "notNull": false + }, + "geo_radius_m": { + "name": "geo_radius_m", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "auto_apply": { + "name": "auto_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_apply_by": { + "name": "auto_apply_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "auto_applied_day": { + "name": "auto_applied_day", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "pin_by_employee": { + "name": "pin_by_employee", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "clock_qr_settings_establishment_id_establishments_id_fk": { + "name": "clock_qr_settings_establishment_id_establishments_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_qr_settings_organization_id_organizations_id_fk": { + "name": "clock_qr_settings_organization_id_organizations_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "clock_qr_settings_auto_apply_by_users_id_fk": { + "name": "clock_qr_settings_auto_apply_by_users_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "users", + "columnsFrom": [ + "auto_apply_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "clock_qr_settings_updated_by_users_id_fk": { + "name": "clock_qr_settings_updated_by_users_id_fk", + "tableFrom": "clock_qr_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.companies": { + "name": "companies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "legal_name": { + "name": "legal_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "legal_form": { + "name": "legal_form", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siren": { + "name": "siren", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_number": { + "name": "vat_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_holding": { + "name": "is_holding", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hr_settings": { + "name": "hr_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "calendar_settings": { + "name": "calendar_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "tax_settings": { + "name": "tax_settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "companies_org_idx": { + "name": "companies_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "companies_organization_id_organizations_id_fk": { + "name": "companies_organization_id_organizations_id_fk", + "tableFrom": "companies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "companies_siren_ck": { + "name": "companies_siren_ck", + "value": "\"companies\".\"siren\" IS NULL OR \"companies\".\"siren\" ~ '^[0-9]{9}$'" + } + }, + "isRLSEnabled": false + }, + "public.company_holdings": { + "name": "company_holdings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "parent_company_id": { + "name": "parent_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "child_company_id": { + "name": "child_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "ownership_pct": { + "name": "ownership_pct", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": true + }, + "since": { + "name": "since", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "holdings_pair_uq": { + "name": "holdings_pair_uq", + "columns": [ + { + "expression": "parent_company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "child_company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "company_holdings_organization_id_organizations_id_fk": { + "name": "company_holdings_organization_id_organizations_id_fk", + "tableFrom": "company_holdings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "company_holdings_parent_company_id_companies_id_fk": { + "name": "company_holdings_parent_company_id_companies_id_fk", + "tableFrom": "company_holdings", + "tableTo": "companies", + "columnsFrom": [ + "parent_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "company_holdings_child_company_id_companies_id_fk": { + "name": "company_holdings_child_company_id_companies_id_fk", + "tableFrom": "company_holdings", + "tableTo": "companies", + "columnsFrom": [ + "child_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "holdings_pct_ck": { + "name": "holdings_pct_ck", + "value": "\"company_holdings\".\"ownership_pct\" > 0 AND \"company_holdings\".\"ownership_pct\" <= 100" + }, + "holdings_self_ck": { + "name": "holdings_self_ck", + "value": "\"company_holdings\".\"parent_company_id\" <> \"company_holdings\".\"child_company_id\"" + } + }, + "isRLSEnabled": false + }, + "public.compliance_items": { + "name": "compliance_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "obligation_id": { + "name": "obligation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "verified_by": { + "name": "verified_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "compliance_items_uq": { + "name": "compliance_items_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "obligation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "compliance_items_document_idx": { + "name": "compliance_items_document_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "compliance_items_organization_id_organizations_id_fk": { + "name": "compliance_items_organization_id_organizations_id_fk", + "tableFrom": "compliance_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "compliance_items_establishment_id_establishments_id_fk": { + "name": "compliance_items_establishment_id_establishments_id_fk", + "tableFrom": "compliance_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "compliance_items_obligation_id_regulatory_obligations_id_fk": { + "name": "compliance_items_obligation_id_regulatory_obligations_id_fk", + "tableFrom": "compliance_items", + "tableTo": "regulatory_obligations", + "columnsFrom": [ + "obligation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "compliance_items_document_id_business_documents_id_fk": { + "name": "compliance_items_document_id_business_documents_id_fk", + "tableFrom": "compliance_items", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "compliance_items_verified_by_users_id_fk": { + "name": "compliance_items_verified_by_users_id_fk", + "tableFrom": "compliance_items", + "tableTo": "users", + "columnsFrom": [ + "verified_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "compliance_items_status_ck": { + "name": "compliance_items_status_ck", + "value": "\"compliance_items\".\"status\" IN ('verifie', 'non_applicable_declare', 'en_cours')" + }, + "compliance_items_in_progress_ck": { + "name": "compliance_items_in_progress_ck", + "value": "\"compliance_items\".\"status\" <> 'en_cours' OR \"compliance_items\".\"note\" IS NOT NULL" + }, + "compliance_items_proof_ck": { + "name": "compliance_items_proof_ck", + "value": "(\"compliance_items\".\"status\" <> 'verifie' OR \"compliance_items\".\"document_id\" IS NOT NULL) AND (\"compliance_items\".\"status\" <> 'non_applicable_declare' OR \"compliance_items\".\"reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.context_observations": { + "name": "context_observations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "series": { + "name": "series", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "numeric(12, 3)", + "primaryKey": false, + "notNull": false + }, + "extra": { + "name": "extra", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "context_observations_uq": { + "name": "context_observations_uq", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "series", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "context_observations_source_ck": { + "name": "context_observations_source_ck", + "value": "\"context_observations\".\"source\" IN ('meteo_france', 'insee')" + } + }, + "isRLSEnabled": false + }, + "public.context_sources": { + "name": "context_sources", + "schema": "", + "columns": { + "source": { + "name": "source", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "last_attempt_at": { + "name": "last_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rows": { + "name": "rows", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_members": { + "name": "conversation_members", + "schema": "", + "columns": { + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_read_at": { + "name": "last_read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "notified_at": { + "name": "notified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversation_members_user_idx": { + "name": "conversation_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversation_members_conversation_id_conversations_id_fk": { + "name": "conversation_members_conversation_id_conversations_id_fk", + "tableFrom": "conversation_members", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversation_members_user_id_users_id_fk": { + "name": "conversation_members_user_id_users_id_fk", + "tableFrom": "conversation_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversation_members_conversation_id_user_id_pk": { + "name": "conversation_members_conversation_id_user_id_pk", + "columns": [ + "conversation_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_group": { + "name": "is_group", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversations_org_idx": { + "name": "conversations_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversations_organization_id_organizations_id_fk": { + "name": "conversations_organization_id_organizations_id_fk", + "tableFrom": "conversations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversations_created_by_users_id_fk": { + "name": "conversations_created_by_users_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credit_request_lines": { + "name": "credit_request_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_request_lines_req_idx": { + "name": "credit_request_lines_req_idx", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_request_lines_organization_id_organizations_id_fk": { + "name": "credit_request_lines_organization_id_organizations_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_lines_request_id_credit_requests_id_fk": { + "name": "credit_request_lines_request_id_credit_requests_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "credit_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_lines_item_id_purchase_items_id_fk": { + "name": "credit_request_lines_item_id_purchase_items_id_fk", + "tableFrom": "credit_request_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_request_lines_amount_ck": { + "name": "credit_request_lines_amount_ck", + "value": "\"credit_request_lines\".\"quantity\" > 0 AND \"credit_request_lines\".\"unit_price_ht\" > 0 AND \"credit_request_lines\".\"amount_ht\" > 0" + }, + "credit_request_lines_reason_ck": { + "name": "credit_request_lines_reason_ck", + "value": "\"credit_request_lines\".\"reason\" IN ('manquant', 'abime', 'non_conforme', 'erreur_prix', 'erreur_quantite', 'dlc_courte', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.credit_request_photos": { + "name": "credit_request_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_request_photos_req_idx": { + "name": "credit_request_photos_req_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_request_photos_organization_id_organizations_id_fk": { + "name": "credit_request_photos_organization_id_organizations_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_photos_request_id_credit_requests_id_fk": { + "name": "credit_request_photos_request_id_credit_requests_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "credit_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_request_photos_created_by_users_id_fk": { + "name": "credit_request_photos_created_by_users_id_fk", + "tableFrom": "credit_request_photos", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_request_photos_size_ck": { + "name": "credit_request_photos_size_ck", + "value": "\"credit_request_photos\".\"size\" <= 5242880" + }, + "credit_request_photos_mime_ck": { + "name": "credit_request_photos_mime_ck", + "value": "\"credit_request_photos\".\"mime\" IN ('image/jpeg', 'image/png', 'image/webp')" + } + }, + "isRLSEnabled": false + }, + "public.credit_requests": { + "name": "credit_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "request_date": { + "name": "request_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "credited_ht": { + "name": "credited_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "close_reason": { + "name": "close_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credit_requests_est_idx": { + "name": "credit_requests_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credit_requests_number_uq": { + "name": "credit_requests_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credit_requests_organization_id_organizations_id_fk": { + "name": "credit_requests_organization_id_organizations_id_fk", + "tableFrom": "credit_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credit_requests_establishment_id_establishments_id_fk": { + "name": "credit_requests_establishment_id_establishments_id_fk", + "tableFrom": "credit_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_supplier_id_suppliers_id_fk": { + "name": "credit_requests_supplier_id_suppliers_id_fk", + "tableFrom": "credit_requests", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_purchase_order_id_purchase_orders_id_fk": { + "name": "credit_requests_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "credit_requests", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_invoice_id_purchase_invoices_id_fk": { + "name": "credit_requests_invoice_id_purchase_invoices_id_fk", + "tableFrom": "credit_requests", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "credit_requests_closed_by_users_id_fk": { + "name": "credit_requests_closed_by_users_id_fk", + "tableFrom": "credit_requests", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "credit_requests_created_by_users_id_fk": { + "name": "credit_requests_created_by_users_id_fk", + "tableFrom": "credit_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credit_requests_status_ck": { + "name": "credit_requests_status_ck", + "value": "\"credit_requests\".\"status\" IN ('open', 'sent', 'accepted', 'refused', 'cancelled')" + }, + "credit_requests_total_ck": { + "name": "credit_requests_total_ck", + "value": "\"credit_requests\".\"total_ht\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.customers": { + "name": "customers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergies": { + "name": "allergies", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preferences": { + "name": "preferences", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birthday": { + "name": "birthday", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "vip": { + "name": "vip", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "consent_email": { + "name": "consent_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "consent_sms": { + "name": "consent_sms", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "consent_at": { + "name": "consent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consent_source": { + "name": "consent_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "anonymized_at": { + "name": "anonymized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "customers_org_idx": { + "name": "customers_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "customers_phone_idx": { + "name": "customers_phone_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "phone", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "customers_email_idx": { + "name": "customers_email_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "customers_organization_id_organizations_id_fk": { + "name": "customers_organization_id_organizations_id_fk", + "tableFrom": "customers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.dashboard_layouts": { + "name": "dashboard_layouts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blocks": { + "name": "blocks", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "dashboard_layouts_user_id_users_id_fk": { + "name": "dashboard_layouts_user_id_users_id_fk", + "tableFrom": "dashboard_layouts", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dashboard_layouts_organization_id_organizations_id_fk": { + "name": "dashboard_layouts_organization_id_organizations_id_fk", + "tableFrom": "dashboard_layouts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "dashboard_layouts_user_id_organization_id_pk": { + "name": "dashboard_layouts_user_id_organization_id_pk", + "columns": [ + "user_id", + "organization_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.delivery_note_scans": { + "name": "delivery_note_scans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "delivery_note_scans_order_idx": { + "name": "delivery_note_scans_order_idx", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "delivery_note_scans_org_idx": { + "name": "delivery_note_scans_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "delivery_note_scans_organization_id_organizations_id_fk": { + "name": "delivery_note_scans_organization_id_organizations_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_establishment_id_establishments_id_fk": { + "name": "delivery_note_scans_establishment_id_establishments_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_order_id_purchase_orders_id_fk": { + "name": "delivery_note_scans_order_id_purchase_orders_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "purchase_orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "delivery_note_scans_created_by_users_id_fk": { + "name": "delivery_note_scans_created_by_users_id_fk", + "tableFrom": "delivery_note_scans", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "delivery_note_scans_status_ck": { + "name": "delivery_note_scans_status_ck", + "value": "\"delivery_note_scans\".\"status\" IN ('lu', 'echec')" + }, + "delivery_note_scans_size_ck": { + "name": "delivery_note_scans_size_ck", + "value": "\"delivery_note_scans\".\"size\" > 0 AND \"delivery_note_scans\".\"size\" <= 10485760" + } + }, + "isRLSEnabled": false + }, + "public.dish_quality_checks": { + "name": "dish_quality_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "checked_by": { + "name": "checked_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "weight_g": { + "name": "weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "target_weight_g": { + "name": "target_weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tolerance_pct": { + "name": "tolerance_pct", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "plating_ok": { + "name": "plating_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "temperature_ok": { + "name": "temperature_ok", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "dish_quality_checks_est_idx": { + "name": "dish_quality_checks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "dish_quality_checks_recipe_idx": { + "name": "dish_quality_checks_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "dish_quality_checks_organization_id_organizations_id_fk": { + "name": "dish_quality_checks_organization_id_organizations_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_establishment_id_establishments_id_fk": { + "name": "dish_quality_checks_establishment_id_establishments_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_recipe_id_recipes_id_fk": { + "name": "dish_quality_checks_recipe_id_recipes_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "dish_quality_checks_checked_by_users_id_fk": { + "name": "dish_quality_checks_checked_by_users_id_fk", + "tableFrom": "dish_quality_checks", + "tableTo": "users", + "columnsFrom": [ + "checked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "dish_quality_checks_weight_ck": { + "name": "dish_quality_checks_weight_ck", + "value": "(\"dish_quality_checks\".\"weight_g\" IS NULL OR \"dish_quality_checks\".\"weight_g\" BETWEEN 1 AND 20000) AND (\"dish_quality_checks\".\"target_weight_g\" IS NULL OR \"dish_quality_checks\".\"target_weight_g\" BETWEEN 1 AND 20000)" + } + }, + "isRLSEnabled": false + }, + "public.duerp_risks": { + "name": "duerp_risks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "unit_id": { + "name": "unit_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "hazard": { + "name": "hazard", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "situation": { + "name": "situation", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "existing_measures": { + "name": "existing_measures", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gravity": { + "name": "gravity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "probability": { + "name": "probability", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "planned_action": { + "name": "planned_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action_owner": { + "name": "action_owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action_due": { + "name": "action_due", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "action_status": { + "name": "action_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_template": { + "name": "from_template", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_risks_unit_idx": { + "name": "duerp_risks_unit_idx", + "columns": [ + { + "expression": "unit_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_risks_est_idx": { + "name": "duerp_risks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_risks_organization_id_organizations_id_fk": { + "name": "duerp_risks_organization_id_organizations_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_risks_establishment_id_establishments_id_fk": { + "name": "duerp_risks_establishment_id_establishments_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_risks_unit_id_duerp_units_id_fk": { + "name": "duerp_risks_unit_id_duerp_units_id_fk", + "tableFrom": "duerp_risks", + "tableTo": "duerp_units", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "duerp_risks_scale_ck": { + "name": "duerp_risks_scale_ck", + "value": "(\"duerp_risks\".\"gravity\" IS NULL OR \"duerp_risks\".\"gravity\" BETWEEN 1 AND 4) AND (\"duerp_risks\".\"probability\" IS NULL OR \"duerp_risks\".\"probability\" BETWEEN 1 AND 4)" + }, + "duerp_risks_action_ck": { + "name": "duerp_risks_action_ck", + "value": "\"duerp_risks\".\"action_status\" IS NULL OR (\"duerp_risks\".\"action_status\" IN ('a_faire', 'en_cours', 'faite') AND \"duerp_risks\".\"planned_action\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.duerp_units": { + "name": "duerp_units", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headcount": { + "name": "headcount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_units_est_idx": { + "name": "duerp_units_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_units_name_uq": { + "name": "duerp_units_name_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"duerp_units\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_units_organization_id_organizations_id_fk": { + "name": "duerp_units_organization_id_organizations_id_fk", + "tableFrom": "duerp_units", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_units_establishment_id_establishments_id_fk": { + "name": "duerp_units_establishment_id_establishments_id_fk", + "tableFrom": "duerp_units", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "duerp_units_headcount_ck": { + "name": "duerp_units_headcount_ck", + "value": "\"duerp_units\".\"headcount\" IS NULL OR \"duerp_units\".\"headcount\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.duerp_versions": { + "name": "duerp_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version_no": { + "name": "version_no", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "snapshot": { + "name": "snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "published_by_name": { + "name": "published_by_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "duerp_versions_no_uq": { + "name": "duerp_versions_no_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version_no", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "duerp_versions_org_idx": { + "name": "duerp_versions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "duerp_versions_organization_id_organizations_id_fk": { + "name": "duerp_versions_organization_id_organizations_id_fk", + "tableFrom": "duerp_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "duerp_versions_establishment_id_establishments_id_fk": { + "name": "duerp_versions_establishment_id_establishments_id_fk", + "tableFrom": "duerp_versions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_attachments": { + "name": "email_attachments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'application/pdf'" + }, + "content": { + "name": "content", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_attachments_org_idx": { + "name": "email_attachments_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_attachments_organization_id_organizations_id_fk": { + "name": "email_attachments_organization_id_organizations_id_fk", + "tableFrom": "email_attachments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "email_attachments_mime_ck": { + "name": "email_attachments_mime_ck", + "value": "\"email_attachments\".\"mime\" = 'application/pdf'" + }, + "email_attachments_size_ck": { + "name": "email_attachments_size_ck", + "value": "\"email_attachments\".\"size\" >= 0 AND \"email_attachments\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.email_outbox": { + "name": "email_outbox", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "signature_request_id": { + "name": "signature_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "attachment_id": { + "name": "attachment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "list_unsubscribe": { + "name": "list_unsubscribe", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_outbox_pending_idx": { + "name": "email_outbox_pending_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_outbox_organization_id_organizations_id_fk": { + "name": "email_outbox_organization_id_organizations_id_fk", + "tableFrom": "email_outbox", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "email_outbox_attachment_id_email_attachments_id_fk": { + "name": "email_outbox_attachment_id_email_attachments_id_fk", + "tableFrom": "email_outbox", + "tableTo": "email_attachments", + "columnsFrom": [ + "attachment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "email_outbox_status_ck": { + "name": "email_outbox_status_ck", + "value": "\"email_outbox\".\"status\" IN ('en_attente', 'envoye', 'echec')" + } + }, + "isRLSEnabled": false + }, + "public.employee_contracts": { + "name": "employee_contracts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "amends_id": { + "name": "amends_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_date": { + "name": "start_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "end_date": { + "name": "end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "trial_end_date": { + "name": "trial_end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "step": { + "name": "step", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'employe'" + }, + "weekly_hours": { + "name": "weekly_hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "hourly_rate_gross": { + "name": "hourly_rate_gross", + "type": "numeric(12, 4)", + "primaryKey": false, + "notNull": false + }, + "monthly_gross": { + "name": "monthly_gross", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "cdd_reason": { + "name": "cdd_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "replaced_person": { + "name": "replaced_person", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "meal_benefit": { + "name": "meal_benefit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "end_reason": { + "name": "end_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hire_time": { + "name": "hire_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_status": { + "name": "dpae_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_declared_on": { + "name": "dpae_declared_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "dpae_reference": { + "name": "dpae_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dpae_note": { + "name": "dpae_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_contracts_emp_idx": { + "name": "employee_contracts_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "start_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_contracts_organization_id_organizations_id_fk": { + "name": "employee_contracts_organization_id_organizations_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_contracts_employee_id_employees_id_fk": { + "name": "employee_contracts_employee_id_employees_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_contracts_amends_id_employee_contracts_id_fk": { + "name": "employee_contracts_amends_id_employee_contracts_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "employee_contracts", + "columnsFrom": [ + "amends_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "employee_contracts_created_by_users_id_fk": { + "name": "employee_contracts_created_by_users_id_fk", + "tableFrom": "employee_contracts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_contracts_dpae_ck": { + "name": "employee_contracts_dpae_ck", + "value": "(\"employee_contracts\".\"dpae_status\" IS NULL OR \"employee_contracts\".\"dpae_status\" IN ('enregistree', 'non_concernee_declaree')) AND (\"employee_contracts\".\"dpae_status\" IS DISTINCT FROM 'enregistree' OR \"employee_contracts\".\"dpae_declared_on\" IS NOT NULL) AND (\"employee_contracts\".\"dpae_status\" IS DISTINCT FROM 'non_concernee_declaree' OR \"employee_contracts\".\"dpae_note\" IS NOT NULL)" + }, + "employee_contracts_kind_ck": { + "name": "employee_contracts_kind_ck", + "value": "\"employee_contracts\".\"kind\" IN ('cdi', 'cdd', 'extra', 'saisonnier', 'apprentissage', 'professionnalisation', 'stage', 'dirigeant')" + }, + "employee_contracts_dates_ck": { + "name": "employee_contracts_dates_ck", + "value": "\"employee_contracts\".\"end_date\" IS NULL OR \"employee_contracts\".\"end_date\" >= \"employee_contracts\".\"start_date\"" + }, + "employee_contracts_category_ck": { + "name": "employee_contracts_category_ck", + "value": "\"employee_contracts\".\"category\" IN ('employe', 'agent_maitrise', 'cadre')" + }, + "employee_contracts_hours_ck": { + "name": "employee_contracts_hours_ck", + "value": "\"employee_contracts\".\"weekly_hours\" IS NULL OR (\"employee_contracts\".\"weekly_hours\" > 0 AND \"employee_contracts\".\"weekly_hours\" <= 48)" + }, + "employee_contracts_rate_ck": { + "name": "employee_contracts_rate_ck", + "value": "(\"employee_contracts\".\"hourly_rate_gross\" IS NULL OR \"employee_contracts\".\"hourly_rate_gross\" >= 0) AND (\"employee_contracts\".\"monthly_gross\" IS NULL OR \"employee_contracts\".\"monthly_gross\" >= 0)" + }, + "employee_contracts_hire_time_ck": { + "name": "employee_contracts_hire_time_ck", + "value": "\"employee_contracts\".\"hire_time\" IS NULL OR \"employee_contracts\".\"hire_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "employee_contracts_meal_ck": { + "name": "employee_contracts_meal_ck", + "value": "\"employee_contracts\".\"meal_benefit\" IS NULL OR \"employee_contracts\".\"meal_benefit\" IN ('nature', 'indemnite', 'aucun')" + } + }, + "isRLSEnabled": false + }, + "public.employee_files": { + "name": "employee_files", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "duplicate_of_id": { + "name": "duplicate_of_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "visible_to_employee": { + "name": "visible_to_employee", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_files_emp_idx": { + "name": "employee_files_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "employee_files_sha_idx": { + "name": "employee_files_sha_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_files_organization_id_organizations_id_fk": { + "name": "employee_files_organization_id_organizations_id_fk", + "tableFrom": "employee_files", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_files_employee_id_employees_id_fk": { + "name": "employee_files_employee_id_employees_id_fk", + "tableFrom": "employee_files", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_files_duplicate_of_id_employee_files_id_fk": { + "name": "employee_files_duplicate_of_id_employee_files_id_fk", + "tableFrom": "employee_files", + "tableTo": "employee_files", + "columnsFrom": [ + "duplicate_of_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_files_uploaded_by_users_id_fk": { + "name": "employee_files_uploaded_by_users_id_fk", + "tableFrom": "employee_files", + "tableTo": "users", + "columnsFrom": [ + "uploaded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_files_size_ck": { + "name": "employee_files_size_ck", + "value": "\"employee_files\".\"size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.employee_reviews": { + "name": "employee_reviews", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'prevu'" + }, + "scheduled_on": { + "name": "scheduled_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "done_on": { + "name": "done_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reviewer_id": { + "name": "reviewer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "objectives": { + "name": "objectives", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "training_wishes": { + "name": "training_wishes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_comment": { + "name": "employee_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_reviews_emp_idx": { + "name": "employee_reviews_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_reviews_organization_id_organizations_id_fk": { + "name": "employee_reviews_organization_id_organizations_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_reviews_employee_id_employees_id_fk": { + "name": "employee_reviews_employee_id_employees_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_reviews_reviewer_id_users_id_fk": { + "name": "employee_reviews_reviewer_id_users_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "users", + "columnsFrom": [ + "reviewer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_reviews_file_id_employee_files_id_fk": { + "name": "employee_reviews_file_id_employee_files_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_reviews_created_by_users_id_fk": { + "name": "employee_reviews_created_by_users_id_fk", + "tableFrom": "employee_reviews", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_reviews_kind_ck": { + "name": "employee_reviews_kind_ck", + "value": "\"employee_reviews\".\"kind\" IN ('annuel', 'professionnel', 'etat_des_lieux', 'fin_essai')" + }, + "employee_reviews_status_ck": { + "name": "employee_reviews_status_ck", + "value": "\"employee_reviews\".\"status\" IN ('prevu', 'realise', 'annule')" + }, + "employee_reviews_done_ck": { + "name": "employee_reviews_done_ck", + "value": "\"employee_reviews\".\"status\" <> 'realise' OR \"employee_reviews\".\"done_on\" IS NOT NULL" + }, + "employee_reviews_planned_ck": { + "name": "employee_reviews_planned_ck", + "value": "\"employee_reviews\".\"status\" <> 'prevu' OR \"employee_reviews\".\"scheduled_on\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.employee_skills": { + "name": "employee_skills", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "skill_id": { + "name": "skill_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "assessed_on": { + "name": "assessed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "assessed_by": { + "name": "assessed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "employee_skills_organization_id_organizations_id_fk": { + "name": "employee_skills_organization_id_organizations_id_fk", + "tableFrom": "employee_skills", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_employee_id_employees_id_fk": { + "name": "employee_skills_employee_id_employees_id_fk", + "tableFrom": "employee_skills", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_skill_id_skills_id_fk": { + "name": "employee_skills_skill_id_skills_id_fk", + "tableFrom": "employee_skills", + "tableTo": "skills", + "columnsFrom": [ + "skill_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_skills_assessed_by_users_id_fk": { + "name": "employee_skills_assessed_by_users_id_fk", + "tableFrom": "employee_skills", + "tableTo": "users", + "columnsFrom": [ + "assessed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "employee_skills_employee_id_skill_id_pk": { + "name": "employee_skills_employee_id_skill_id_pk", + "columns": [ + "employee_id", + "skill_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_skills_level_ck": { + "name": "employee_skills_level_ck", + "value": "\"employee_skills\".\"level\" BETWEEN 0 AND 4" + } + }, + "isRLSEnabled": false + }, + "public.employee_trainings": { + "name": "employee_trainings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'realisee'" + }, + "planned_on": { + "name": "planned_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "done_on": { + "name": "done_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "hours": { + "name": "hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "funded_by": { + "name": "funded_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employee_trainings_emp_idx": { + "name": "employee_trainings_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employee_trainings_organization_id_organizations_id_fk": { + "name": "employee_trainings_organization_id_organizations_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_trainings_employee_id_employees_id_fk": { + "name": "employee_trainings_employee_id_employees_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employee_trainings_file_id_employee_files_id_fk": { + "name": "employee_trainings_file_id_employee_files_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "employee_trainings_created_by_users_id_fk": { + "name": "employee_trainings_created_by_users_id_fk", + "tableFrom": "employee_trainings", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employee_trainings_status_ck": { + "name": "employee_trainings_status_ck", + "value": "\"employee_trainings\".\"status\" IN ('prevue', 'realisee', 'annulee')" + }, + "employee_trainings_done_ck": { + "name": "employee_trainings_done_ck", + "value": "\"employee_trainings\".\"status\" <> 'realisee' OR \"employee_trainings\".\"done_on\" IS NOT NULL" + }, + "employee_trainings_valid_ck": { + "name": "employee_trainings_valid_ck", + "value": "\"employee_trainings\".\"valid_until\" IS NULL OR \"employee_trainings\".\"done_on\" IS NULL OR \"employee_trainings\".\"valid_until\" >= \"employee_trainings\".\"done_on\"" + }, + "employee_trainings_amounts_ck": { + "name": "employee_trainings_amounts_ck", + "value": "(\"employee_trainings\".\"hours\" IS NULL OR \"employee_trainings\".\"hours\" > 0) AND (\"employee_trainings\".\"cost\" IS NULL OR \"employee_trainings\".\"cost\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.employees": { + "name": "employees", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "registry_number": { + "name": "registry_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "birth_name": { + "name": "birth_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "birth_date": { + "name": "birth_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "birth_place": { + "name": "birth_place", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "nationality": { + "name": "nationality", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birth_country": { + "name": "birth_country", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "birth_department": { + "name": "birth_department", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family_situation": { + "name": "family_situation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_type": { + "name": "work_permit_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_number": { + "name": "work_permit_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "work_permit_expiry": { + "name": "work_permit_expiry", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "social_security_enc": { + "name": "social_security_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban_enc": { + "name": "iban_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bic": { + "name": "bic", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "account_holder": { + "name": "account_holder", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emergency_contact": { + "name": "emergency_contact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emergency_phone": { + "name": "emergency_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disability": { + "name": "disability", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "medical_visit_date": { + "name": "medical_visit_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "medical_visit_next_due": { + "name": "medical_visit_next_due", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "reinforced_medical": { + "name": "reinforced_medical", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "planning_hidden": { + "name": "planning_hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employees_org_idx": { + "name": "employees_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "employees_registry_uq": { + "name": "employees_registry_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "registry_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employees_organization_id_organizations_id_fk": { + "name": "employees_organization_id_organizations_id_fk", + "tableFrom": "employees", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employees_establishment_id_establishments_id_fk": { + "name": "employees_establishment_id_establishments_id_fk", + "tableFrom": "employees", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "employees_user_id_users_id_fk": { + "name": "employees_user_id_users_id_fk", + "tableFrom": "employees", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employees_gender_ck": { + "name": "employees_gender_ck", + "value": "\"employees\".\"gender\" IS NULL OR \"employees\".\"gender\" IN ('F', 'M', 'X')" + }, + "employees_birth_department_ck": { + "name": "employees_birth_department_ck", + "value": "\"employees\".\"birth_department\" IS NULL OR \"employees\".\"birth_department\" ~ '^([0-9]{2}|2[AB]|9[78][0-9])$'" + } + }, + "isRLSEnabled": false + }, + "public.employer_signatures": { + "name": "employer_signatures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "png": { + "name": "png", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "signer_name": { + "name": "signer_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "employer_signatures_company_uq": { + "name": "employer_signatures_company_uq", + "columns": [ + { + "expression": "company_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "employer_signatures_organization_id_organizations_id_fk": { + "name": "employer_signatures_organization_id_organizations_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employer_signatures_company_id_companies_id_fk": { + "name": "employer_signatures_company_id_companies_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "employer_signatures_updated_by_users_id_fk": { + "name": "employer_signatures_updated_by_users_id_fk", + "tableFrom": "employer_signatures", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "employer_signatures_size_ck": { + "name": "employer_signatures_size_ck", + "value": "octet_length(\"employer_signatures\".\"png\") <= 102400" + } + }, + "isRLSEnabled": false + }, + "public.equipment": { + "name": "equipment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "temp_tracked": { + "name": "temp_tracked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "temp_min": { + "name": "temp_min", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "readings_per_day": { + "name": "readings_per_day", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "serial_number": { + "name": "serial_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installed_on": { + "name": "installed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "warranty_until": { + "name": "warranty_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "service_partner": { + "name": "service_partner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_phone": { + "name": "service_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_every_months": { + "name": "service_every_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "purchase_price_ht": { + "name": "purchase_price_ht", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "equipment_est_idx": { + "name": "equipment_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "equipment_organization_id_organizations_id_fk": { + "name": "equipment_organization_id_organizations_id_fk", + "tableFrom": "equipment", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "equipment_establishment_id_establishments_id_fk": { + "name": "equipment_establishment_id_establishments_id_fk", + "tableFrom": "equipment", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "equipment_created_by_users_id_fk": { + "name": "equipment_created_by_users_id_fk", + "tableFrom": "equipment", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "equipment_range_ck": { + "name": "equipment_range_ck", + "value": "\"equipment\".\"temp_min\" IS NULL OR \"equipment\".\"temp_max\" IS NULL OR \"equipment\".\"temp_min\" <= \"equipment\".\"temp_max\"" + }, + "equipment_rpd_ck": { + "name": "equipment_rpd_ck", + "value": "\"equipment\".\"readings_per_day\" BETWEEN 1 AND 4" + }, + "equipment_price_ck": { + "name": "equipment_price_ck", + "value": "\"equipment\".\"purchase_price_ht\" IS NULL OR \"equipment\".\"purchase_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.establishment_fee_rules": { + "name": "establishment_fee_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rate_pct": { + "name": "rate_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "basis": { + "name": "basis", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ttc'" + }, + "match_channel": { + "name": "match_channel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "match_payment": { + "name": "match_payment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fixed_monthly_ht": { + "name": "fixed_monthly_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "valid_from": { + "name": "valid_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "valid_to": { + "name": "valid_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishment_fee_rules_est_idx": { + "name": "establishment_fee_rules_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishment_fee_rules_organization_id_organizations_id_fk": { + "name": "establishment_fee_rules_organization_id_organizations_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_fee_rules_establishment_id_establishments_id_fk": { + "name": "establishment_fee_rules_establishment_id_establishments_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_fee_rules_created_by_users_id_fk": { + "name": "establishment_fee_rules_created_by_users_id_fk", + "tableFrom": "establishment_fee_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "establishment_fee_rules_kind_ck": { + "name": "establishment_fee_rules_kind_ck", + "value": "\"establishment_fee_rules\".\"kind\" IN ('plateforme', 'franchise')" + }, + "establishment_fee_rules_basis_ck": { + "name": "establishment_fee_rules_basis_ck", + "value": "\"establishment_fee_rules\".\"basis\" IN ('ttc', 'ht')" + }, + "establishment_fee_rules_rate_ck": { + "name": "establishment_fee_rules_rate_ck", + "value": "\"establishment_fee_rules\".\"rate_pct\" >= 0 AND \"establishment_fee_rules\".\"rate_pct\" < 100" + }, + "establishment_fee_rules_fixed_ck": { + "name": "establishment_fee_rules_fixed_ck", + "value": "\"establishment_fee_rules\".\"fixed_monthly_ht\" IS NULL OR \"establishment_fee_rules\".\"fixed_monthly_ht\" >= 0" + }, + "establishment_fee_rules_channel_ck": { + "name": "establishment_fee_rules_channel_ck", + "value": "\"establishment_fee_rules\".\"match_channel\" IS NULL OR \"establishment_fee_rules\".\"match_channel\" IN ('sur_place', 'emporter', 'livraison', 'click_collect', 'autre')" + }, + "establishment_fee_rules_dates_ck": { + "name": "establishment_fee_rules_dates_ck", + "value": "\"establishment_fee_rules\".\"valid_to\" IS NULL OR \"establishment_fee_rules\".\"valid_to\" >= \"establishment_fee_rules\".\"valid_from\"" + }, + "establishment_fee_rules_label_ck": { + "name": "establishment_fee_rules_label_ck", + "value": "char_length(\"establishment_fee_rules\".\"label\") BETWEEN 1 AND 80" + } + }, + "isRLSEnabled": false + }, + "public.establishment_regulatory_profiles": { + "name": "establishment_regulatory_profiles", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "on_site": { + "name": "on_site", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "takeaway": { + "name": "takeaway", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "delivery": { + "name": "delivery", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "seating_capacity": { + "name": "seating_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "erp_category": { + "name": "erp_category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "erp_type": { + "name": "erp_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headcount_declared": { + "name": "headcount_declared", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "alcohol_licence": { + "name": "alcohol_licence", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "terrace": { + "name": "terrace", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "music": { + "name": "music", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "cameras": { + "name": "cameras", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "fryer": { + "name": "fryer", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "minors_employed": { + "name": "minors_employed", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "foreign_workers": { + "name": "foreign_workers", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "franchise": { + "name": "franchise", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishment_regulatory_profiles_org_idx": { + "name": "establishment_regulatory_profiles_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishment_regulatory_profiles_establishment_id_establishments_id_fk": { + "name": "establishment_regulatory_profiles_establishment_id_establishments_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_regulatory_profiles_organization_id_organizations_id_fk": { + "name": "establishment_regulatory_profiles_organization_id_organizations_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishment_regulatory_profiles_updated_by_users_id_fk": { + "name": "establishment_regulatory_profiles_updated_by_users_id_fk", + "tableFrom": "establishment_regulatory_profiles", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "establishment_regulatory_profiles_erp_ck": { + "name": "establishment_regulatory_profiles_erp_ck", + "value": "\"establishment_regulatory_profiles\".\"erp_category\" IS NULL OR \"establishment_regulatory_profiles\".\"erp_category\" IN ('1', '2', '3', '4', '5')" + }, + "establishment_regulatory_profiles_licence_ck": { + "name": "establishment_regulatory_profiles_licence_ck", + "value": "\"establishment_regulatory_profiles\".\"alcohol_licence\" IS NULL OR \"establishment_regulatory_profiles\".\"alcohol_licence\" IN ('aucune', 'petite_licence_restaurant', 'licence_restaurant', 'licence_3', 'licence_4', 'petite_licence_emporter', 'licence_emporter', 'inconnue')" + }, + "establishment_regulatory_profiles_counts_ck": { + "name": "establishment_regulatory_profiles_counts_ck", + "value": "(\"establishment_regulatory_profiles\".\"seating_capacity\" IS NULL OR \"establishment_regulatory_profiles\".\"seating_capacity\" >= 0) AND (\"establishment_regulatory_profiles\".\"headcount_declared\" IS NULL OR \"establishment_regulatory_profiles\".\"headcount_declared\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.establishments": { + "name": "establishments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'restaurant'" + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ape_code": { + "name": "ape_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idcc": { + "name": "idcc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "country": { + "name": "country", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'FR'" + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Europe/Paris'" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'EUR'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "establishments_org_idx": { + "name": "establishments_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "establishments_organization_id_organizations_id_fk": { + "name": "establishments_organization_id_organizations_id_fk", + "tableFrom": "establishments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "establishments_company_id_companies_id_fk": { + "name": "establishments_company_id_companies_id_fk", + "tableFrom": "establishments", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.expense_entries": { + "name": "expense_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier": { + "name": "supplier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "period_start": { + "name": "period_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_end": { + "name": "period_end", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "recurrence": { + "name": "recurrence", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "recurrence_until": { + "name": "recurrence_until", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deleted_by": { + "name": "deleted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "deletion_reason": { + "name": "deletion_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "double_count_decision": { + "name": "double_count_decision", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "double_count_decided_by": { + "name": "double_count_decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "double_count_decided_at": { + "name": "double_count_decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "expenses_period_idx": { + "name": "expenses_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_start", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "period_end", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "expense_entries_organization_id_organizations_id_fk": { + "name": "expense_entries_organization_id_organizations_id_fk", + "tableFrom": "expense_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "expense_entries_establishment_id_establishments_id_fk": { + "name": "expense_entries_establishment_id_establishments_id_fk", + "tableFrom": "expense_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "expense_entries_created_by_users_id_fk": { + "name": "expense_entries_created_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "expense_entries_deleted_by_users_id_fk": { + "name": "expense_entries_deleted_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "deleted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "expense_entries_double_count_decided_by_users_id_fk": { + "name": "expense_entries_double_count_decided_by_users_id_fk", + "tableFrom": "expense_entries", + "tableTo": "users", + "columnsFrom": [ + "double_count_decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "expenses_period_ck": { + "name": "expenses_period_ck", + "value": "\"expense_entries\".\"period_start\" <= \"expense_entries\".\"period_end\"" + }, + "expenses_recurrence_ck": { + "name": "expenses_recurrence_ck", + "value": "\"expense_entries\".\"recurrence\" IN ('none', 'monthly', 'quarterly', 'yearly')" + }, + "expenses_recurrence_until_ck": { + "name": "expenses_recurrence_until_ck", + "value": "\"expense_entries\".\"recurrence_until\" IS NULL OR (\"expense_entries\".\"recurrence\" <> 'none' AND \"expense_entries\".\"recurrence_until\" >= \"expense_entries\".\"period_start\")" + }, + "expenses_ttc_consistency_ck": { + "name": "expenses_ttc_consistency_ck", + "value": "\"expense_entries\".\"amount_ttc\" = \"expense_entries\".\"amount_ht\" + \"expense_entries\".\"vat_amount\"" + }, + "expense_double_count_ck": { + "name": "expense_double_count_ck", + "value": "\"expense_entries\".\"double_count_decision\" IS NULL OR \"expense_entries\".\"double_count_decision\" IN ('keep', 'exclude')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_ambassadors": { + "name": "feedback_ambassadors", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "appointed_by": { + "name": "appointed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_ambassadors_organization_id_organizations_id_fk": { + "name": "feedback_ambassadors_organization_id_organizations_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_ambassadors_user_id_users_id_fk": { + "name": "feedback_ambassadors_user_id_users_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_ambassadors_appointed_by_users_id_fk": { + "name": "feedback_ambassadors_appointed_by_users_id_fk", + "tableFrom": "feedback_ambassadors", + "tableTo": "users", + "columnsFrom": [ + "appointed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_ambassadors_organization_id_user_id_pk": { + "name": "feedback_ambassadors_organization_id_user_id_pk", + "columns": [ + "organization_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback_comments": { + "name": "feedback_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'commentaire'" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_status": { + "name": "from_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "to_status": { + "name": "to_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_comments_item_idx": { + "name": "feedback_comments_item_idx", + "columns": [ + { + "expression": "feedback_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_comments_organization_id_organizations_id_fk": { + "name": "feedback_comments_organization_id_organizations_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_comments_feedback_id_feedback_items_id_fk": { + "name": "feedback_comments_feedback_id_feedback_items_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "feedback_items", + "columnsFrom": [ + "feedback_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_comments_user_id_users_id_fk": { + "name": "feedback_comments_user_id_users_id_fk", + "tableFrom": "feedback_comments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_comments_kind_ck": { + "name": "feedback_comments_kind_ck", + "value": "\"feedback_comments\".\"kind\" IN ('commentaire', 'reponse', 'statut', 'fusion')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_items": { + "name": "feedback_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "page_path": { + "name": "page_path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_role": { + "name": "author_role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "screenshot": { + "name": "screenshot", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "screenshot_mime": { + "name": "screenshot_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'recue'" + }, + "status_note": { + "name": "status_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "release_version": { + "name": "release_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "merged_into_id": { + "name": "merged_into_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "first_response_at": { + "name": "first_response_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status_changed_at": { + "name": "status_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delivered_at": { + "name": "delivered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_items_number_uq": { + "name": "feedback_items_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "feedback_items_org_idx": { + "name": "feedback_items_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_items_organization_id_organizations_id_fk": { + "name": "feedback_items_organization_id_organizations_id_fk", + "tableFrom": "feedback_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_items_merged_into_id_feedback_items_id_fk": { + "name": "feedback_items_merged_into_id_feedback_items_id_fk", + "tableFrom": "feedback_items", + "tableTo": "feedback_items", + "columnsFrom": [ + "merged_into_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "feedback_items_author_id_users_id_fk": { + "name": "feedback_items_author_id_users_id_fk", + "tableFrom": "feedback_items", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_items_kind_ck": { + "name": "feedback_items_kind_ck", + "value": "\"feedback_items\".\"kind\" IN ('idee', 'probleme', 'question')" + }, + "feedback_items_status_ck": { + "name": "feedback_items_status_ck", + "value": "\"feedback_items\".\"status\" IN ('recue', 'etude', 'prevue', 'en_cours', 'livree', 'pas_maintenant')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_pulses": { + "name": "feedback_pulses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "app_version": { + "name": "app_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "feedback_pulses_once_uq": { + "name": "feedback_pulses_once_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "app_version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "feedback_pulses_org_idx": { + "name": "feedback_pulses_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "module", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feedback_pulses_organization_id_organizations_id_fk": { + "name": "feedback_pulses_organization_id_organizations_id_fk", + "tableFrom": "feedback_pulses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_pulses_user_id_users_id_fk": { + "name": "feedback_pulses_user_id_users_id_fk", + "tableFrom": "feedback_pulses", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "feedback_pulses_answer_ck": { + "name": "feedback_pulses_answer_ck", + "value": "\"feedback_pulses\".\"answer\" IN ('oui', 'non')" + } + }, + "isRLSEnabled": false + }, + "public.feedback_testers": { + "name": "feedback_testers", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_testers_organization_id_organizations_id_fk": { + "name": "feedback_testers_organization_id_organizations_id_fk", + "tableFrom": "feedback_testers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_testers_user_id_users_id_fk": { + "name": "feedback_testers_user_id_users_id_fk", + "tableFrom": "feedback_testers", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_testers_organization_id_user_id_pk": { + "name": "feedback_testers_organization_id_user_id_pk", + "columns": [ + "organization_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback_votes": { + "name": "feedback_votes", + "schema": "", + "columns": { + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "feedback_votes_feedback_id_feedback_items_id_fk": { + "name": "feedback_votes_feedback_id_feedback_items_id_fk", + "tableFrom": "feedback_votes", + "tableTo": "feedback_items", + "columnsFrom": [ + "feedback_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_votes_user_id_users_id_fk": { + "name": "feedback_votes_user_id_users_id_fk", + "tableFrom": "feedback_votes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "feedback_votes_feedback_id_user_id_pk": { + "name": "feedback_votes_feedback_id_user_id_pk", + "columns": [ + "feedback_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.file_downloads": { + "name": "file_downloads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sensitivity": { + "name": "sensitivity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disposition": { + "name": "disposition", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "file_downloads_entity_idx": { + "name": "file_downloads_entity_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "file_downloads_organization_id_organizations_id_fk": { + "name": "file_downloads_organization_id_organizations_id_fk", + "tableFrom": "file_downloads", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "file_downloads_user_id_users_id_fk": { + "name": "file_downloads_user_id_users_id_fk", + "tableFrom": "file_downloads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "file_downloads_source_ck": { + "name": "file_downloads_source_ck", + "value": "\"file_downloads\".\"source\" IN ('business_document', 'business_document_version', 'employee_file', 'vault_zip', 'privacy_export', 'signature_request', 'sos_zip', 'generated_report', 'generated_hr_document', 'data_export')" + }, + "file_downloads_disposition_ck": { + "name": "file_downloads_disposition_ck", + "value": "\"file_downloads\".\"disposition\" IN ('inline', 'attachment', 'zip')" + } + }, + "isRLSEnabled": false + }, + "public.fixed_assets": { + "name": "fixed_assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "financing": { + "name": "financing", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "acquired_on": { + "name": "acquired_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "useful_life_months": { + "name": "useful_life_months", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lease_monthly_ht": { + "name": "lease_monthly_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "lease_end_on": { + "name": "lease_end_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "lease_residual_ht": { + "name": "lease_residual_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "disposed_on": { + "name": "disposed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "disposal_reason": { + "name": "disposal_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "fixed_assets_est_idx": { + "name": "fixed_assets_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fixed_assets_invoice_uq": { + "name": "fixed_assets_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"fixed_assets\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "fixed_assets_pennylane_uq": { + "name": "fixed_assets_pennylane_uq", + "columns": [ + { + "expression": "pennylane_record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"fixed_assets\".\"pennylane_record_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "fixed_assets_organization_id_organizations_id_fk": { + "name": "fixed_assets_organization_id_organizations_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fixed_assets_establishment_id_establishments_id_fk": { + "name": "fixed_assets_establishment_id_establishments_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "fixed_assets_supplier_id_suppliers_id_fk": { + "name": "fixed_assets_supplier_id_suppliers_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "fixed_assets_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_pennylane_record_id_pennylane_records_id_fk": { + "name": "fixed_assets_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_document_id_business_documents_id_fk": { + "name": "fixed_assets_document_id_business_documents_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "fixed_assets_created_by_users_id_fk": { + "name": "fixed_assets_created_by_users_id_fk", + "tableFrom": "fixed_assets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "fixed_assets_category_ck": { + "name": "fixed_assets_category_ck", + "value": "\"fixed_assets\".\"category\" IN ('materiel_cuisine', 'mobilier', 'informatique', 'agencement', 'vehicule', 'autre')" + }, + "fixed_assets_financing_ck": { + "name": "fixed_assets_financing_ck", + "value": "\"fixed_assets\".\"financing\" IN ('achat', 'credit_bail', 'location_financiere')" + }, + "fixed_assets_purchase_ck": { + "name": "fixed_assets_purchase_ck", + "value": "\"fixed_assets\".\"financing\" <> 'achat' OR (\"fixed_assets\".\"amount_ht\" IS NOT NULL AND \"fixed_assets\".\"amount_ht\" > 0 AND \"fixed_assets\".\"useful_life_months\" IS NOT NULL)" + }, + "fixed_assets_lease_ck": { + "name": "fixed_assets_lease_ck", + "value": "\"fixed_assets\".\"financing\" = 'achat' OR (\"fixed_assets\".\"lease_monthly_ht\" IS NOT NULL AND \"fixed_assets\".\"lease_monthly_ht\" > 0 AND \"fixed_assets\".\"lease_end_on\" IS NOT NULL AND \"fixed_assets\".\"lease_end_on\" > \"fixed_assets\".\"acquired_on\")" + }, + "fixed_assets_life_ck": { + "name": "fixed_assets_life_ck", + "value": "\"fixed_assets\".\"useful_life_months\" IS NULL OR \"fixed_assets\".\"useful_life_months\" BETWEEN 1 AND 600" + }, + "fixed_assets_amounts_ck": { + "name": "fixed_assets_amounts_ck", + "value": "(\"fixed_assets\".\"amount_ht\" IS NULL OR \"fixed_assets\".\"amount_ht\" >= 0) AND (\"fixed_assets\".\"lease_residual_ht\" IS NULL OR \"fixed_assets\".\"lease_residual_ht\" >= 0)" + }, + "fixed_assets_disposal_ck": { + "name": "fixed_assets_disposal_ck", + "value": "\"fixed_assets\".\"disposed_on\" IS NULL OR (\"fixed_assets\".\"disposed_on\" >= \"fixed_assets\".\"acquired_on\" AND \"fixed_assets\".\"disposal_reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.floor_items": { + "name": "floor_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "shape": { + "name": "shape", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "w": { + "name": "w", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "h": { + "name": "h", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "rotation": { + "name": "rotation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "floor_items_room_idx": { + "name": "floor_items_room_idx", + "columns": [ + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "floor_items_table_label_uq": { + "name": "floor_items_table_label_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"label\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"floor_items\".\"kind\" = 'table' AND \"floor_items\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "floor_items_organization_id_organizations_id_fk": { + "name": "floor_items_organization_id_organizations_id_fk", + "tableFrom": "floor_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "floor_items_establishment_id_establishments_id_fk": { + "name": "floor_items_establishment_id_establishments_id_fk", + "tableFrom": "floor_items", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "floor_items_room_id_floor_rooms_id_fk": { + "name": "floor_items_room_id_floor_rooms_id_fk", + "tableFrom": "floor_items", + "tableTo": "floor_rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "floor_items_kind_ck": { + "name": "floor_items_kind_ck", + "value": "\"floor_items\".\"kind\" IN ('table', 'wall', 'bar', 'door', 'window', 'pillar', 'plant', 'zone', 'text')" + }, + "floor_items_table_ck": { + "name": "floor_items_table_ck", + "value": "\"floor_items\".\"kind\" <> 'table' OR (\"floor_items\".\"shape\" IN ('round', 'square', 'rect') AND \"floor_items\".\"label\" IS NOT NULL AND \"floor_items\".\"seats\" BETWEEN 1 AND 40)" + }, + "floor_items_size_ck": { + "name": "floor_items_size_ck", + "value": "\"floor_items\".\"w\" BETWEEN 5 AND 10000 AND \"floor_items\".\"h\" BETWEEN 5 AND 10000 AND \"floor_items\".\"rotation\" BETWEEN 0 AND 359" + } + }, + "isRLSEnabled": false + }, + "public.floor_rooms": { + "name": "floor_rooms", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width_cm": { + "name": "width_cm", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1200 + }, + "height_cm": { + "name": "height_cm", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 800 + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "floor_rooms_est_idx": { + "name": "floor_rooms_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "floor_rooms_organization_id_organizations_id_fk": { + "name": "floor_rooms_organization_id_organizations_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "floor_rooms_establishment_id_establishments_id_fk": { + "name": "floor_rooms_establishment_id_establishments_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "floor_rooms_created_by_users_id_fk": { + "name": "floor_rooms_created_by_users_id_fk", + "tableFrom": "floor_rooms", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "floor_rooms_size_ck": { + "name": "floor_rooms_size_ck", + "value": "\"floor_rooms\".\"width_cm\" BETWEEN 200 AND 10000 AND \"floor_rooms\".\"height_cm\" BETWEEN 200 AND 10000" + } + }, + "isRLSEnabled": false + }, + "public.forecast_events": { + "name": "forecast_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_day": { + "name": "from_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "to_day": { + "name": "to_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "impact_pct": { + "name": "impact_pct", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forecast_events_org_idx": { + "name": "forecast_events_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forecast_events_organization_id_organizations_id_fk": { + "name": "forecast_events_organization_id_organizations_id_fk", + "tableFrom": "forecast_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forecast_events_establishment_id_establishments_id_fk": { + "name": "forecast_events_establishment_id_establishments_id_fk", + "tableFrom": "forecast_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forecast_events_created_by_users_id_fk": { + "name": "forecast_events_created_by_users_id_fk", + "tableFrom": "forecast_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "forecast_events_range_ck": { + "name": "forecast_events_range_ck", + "value": "\"forecast_events\".\"to_day\" >= \"forecast_events\".\"from_day\" AND \"forecast_events\".\"to_day\" - \"forecast_events\".\"from_day\" <= 92" + }, + "forecast_events_impact_ck": { + "name": "forecast_events_impact_ck", + "value": "\"forecast_events\".\"impact_pct\" IS NULL OR (\"forecast_events\".\"impact_pct\" >= -100 AND \"forecast_events\".\"impact_pct\" <= 500)" + } + }, + "isRLSEnabled": false + }, + "public.forum_replies": { + "name": "forum_replies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "topic_id": { + "name": "topic_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forum_replies_topic_idx": { + "name": "forum_replies_topic_idx", + "columns": [ + { + "expression": "topic_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forum_replies_organization_id_organizations_id_fk": { + "name": "forum_replies_organization_id_organizations_id_fk", + "tableFrom": "forum_replies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_replies_topic_id_forum_topics_id_fk": { + "name": "forum_replies_topic_id_forum_topics_id_fk", + "tableFrom": "forum_replies", + "tableTo": "forum_topics", + "columnsFrom": [ + "topic_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_replies_author_id_users_id_fk": { + "name": "forum_replies_author_id_users_id_fk", + "tableFrom": "forum_replies", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.forum_topics": { + "name": "forum_topics", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'question'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pinned": { + "name": "pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "solution_reply_id": { + "name": "solution_reply_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "idea_id": { + "name": "idea_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "forum_topics_number_uq": { + "name": "forum_topics_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "forum_topics_org_idx": { + "name": "forum_topics_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "pinned", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_activity_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "forum_topics_organization_id_organizations_id_fk": { + "name": "forum_topics_organization_id_organizations_id_fk", + "tableFrom": "forum_topics", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "forum_topics_author_id_users_id_fk": { + "name": "forum_topics_author_id_users_id_fk", + "tableFrom": "forum_topics", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "forum_topics_idea_id_feedback_items_id_fk": { + "name": "forum_topics_idea_id_feedback_items_id_fk", + "tableFrom": "forum_topics", + "tableTo": "feedback_items", + "columnsFrom": [ + "idea_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "forum_topics_category_ck": { + "name": "forum_topics_category_ck", + "value": "\"forum_topics\".\"category\" IN ('question', 'astuce', 'discussion')" + } + }, + "isRLSEnabled": false + }, + "public.google_post_settings": { + "name": "google_post_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "schedule_mode": { + "name": "schedule_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'per_week'" + }, + "weekdays": { + "name": "weekdays", + "type": "integer[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[2,5]::integer[]" + }, + "per_week": { + "name": "per_week", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "post_time": { + "name": "post_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'10:00'" + }, + "lead_hours": { + "name": "lead_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 48 + }, + "src_menu": { + "name": "src_menu", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_events": { + "name": "src_events", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_hours": { + "name": "src_hours", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_best_sellers": { + "name": "src_best_sellers", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_seasonal": { + "name": "src_seasonal", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "src_reviews": { + "name": "src_reviews", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "review_min_rating": { + "name": "review_min_rating", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "default_cta_type": { + "name": "default_cta_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "default_cta_url": { + "name": "default_cta_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'fr'" + }, + "autopublish": { + "name": "autopublish", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "enabled_by": { + "name": "enabled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "enabled_at": { + "name": "enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmation": { + "name": "confirmation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_generated_at": { + "name": "last_generated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "google_post_settings_org_idx": { + "name": "google_post_settings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "google_post_settings_establishment_id_establishments_id_fk": { + "name": "google_post_settings_establishment_id_establishments_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_post_settings_organization_id_organizations_id_fk": { + "name": "google_post_settings_organization_id_organizations_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_post_settings_enabled_by_users_id_fk": { + "name": "google_post_settings_enabled_by_users_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "users", + "columnsFrom": [ + "enabled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_post_settings_updated_by_users_id_fk": { + "name": "google_post_settings_updated_by_users_id_fk", + "tableFrom": "google_post_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "google_post_settings_mode_ck": { + "name": "google_post_settings_mode_ck", + "value": "\"google_post_settings\".\"schedule_mode\" IN ('weekdays', 'per_week')" + }, + "google_post_settings_weekdays_ck": { + "name": "google_post_settings_weekdays_ck", + "value": "cardinality(\"google_post_settings\".\"weekdays\") BETWEEN 1 AND 7 AND \"google_post_settings\".\"weekdays\" <@ ARRAY[1,2,3,4,5,6,7]::integer[]" + }, + "google_post_settings_per_week_ck": { + "name": "google_post_settings_per_week_ck", + "value": "\"google_post_settings\".\"per_week\" BETWEEN 1 AND 7" + }, + "google_post_settings_time_ck": { + "name": "google_post_settings_time_ck", + "value": "\"google_post_settings\".\"post_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "google_post_settings_lead_ck": { + "name": "google_post_settings_lead_ck", + "value": "\"google_post_settings\".\"lead_hours\" BETWEEN 12 AND 168" + }, + "google_post_settings_rating_ck": { + "name": "google_post_settings_rating_ck", + "value": "\"google_post_settings\".\"review_min_rating\" BETWEEN 4 AND 5" + }, + "google_post_settings_cta_ck": { + "name": "google_post_settings_cta_ck", + "value": "\"google_post_settings\".\"default_cta_type\" IS NULL OR \"google_post_settings\".\"default_cta_type\" IN ('BOOK', 'ORDER', 'SHOP', 'LEARN_MORE', 'SIGN_UP', 'CALL')" + }, + "google_post_settings_autopublish_ck": { + "name": "google_post_settings_autopublish_ck", + "value": "NOT \"google_post_settings\".\"autopublish\" OR \"google_post_settings\".\"confirmation\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.google_posts": { + "name": "google_posts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "generator": { + "name": "generator", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "facts": { + "name": "facts", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "topic_type": { + "name": "topic_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'STANDARD'" + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cta_type": { + "name": "cta_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cta_url": { + "name": "cta_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_title": { + "name": "event_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_start_date": { + "name": "event_start_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_start_time": { + "name": "event_start_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_end_date": { + "name": "event_end_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_end_time": { + "name": "event_end_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_coupon": { + "name": "offer_coupon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_url": { + "name": "offer_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "offer_terms": { + "name": "offer_terms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "visual_id": { + "name": "visual_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "image_mime": { + "name": "image_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blocked_words": { + "name": "blocked_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "google_name": { + "name": "google_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_state": { + "name": "google_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "search_url": { + "name": "search_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "ai_cost_usd": { + "name": "ai_cost_usd", + "type": "numeric(12, 6)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "google_posts_due_idx": { + "name": "google_posts_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_cal_idx": { + "name": "google_posts_cal_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_for", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_source_uq": { + "name": "google_posts_source_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"google_posts\".\"source_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "google_posts_token_uq": { + "name": "google_posts_token_uq", + "columns": [ + { + "expression": "public_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "google_posts_organization_id_organizations_id_fk": { + "name": "google_posts_organization_id_organizations_id_fk", + "tableFrom": "google_posts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_posts_establishment_id_establishments_id_fk": { + "name": "google_posts_establishment_id_establishments_id_fk", + "tableFrom": "google_posts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "google_posts_visual_id_studio_visuals_id_fk": { + "name": "google_posts_visual_id_studio_visuals_id_fk", + "tableFrom": "google_posts", + "tableTo": "studio_visuals", + "columnsFrom": [ + "visual_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_posts_approved_by_users_id_fk": { + "name": "google_posts_approved_by_users_id_fk", + "tableFrom": "google_posts", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "google_posts_created_by_users_id_fk": { + "name": "google_posts_created_by_users_id_fk", + "tableFrom": "google_posts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "google_posts_source_ck": { + "name": "google_posts_source_ck", + "value": "\"google_posts\".\"source\" IN ('manuel', 'menu_du_jour', 'evenement', 'horaires', 'meilleures_ventes', 'saison', 'avis')" + }, + "google_posts_generator_ck": { + "name": "google_posts_generator_ck", + "value": "\"google_posts\".\"generator\" IN ('ia', 'modele', 'humain')" + }, + "google_posts_topic_ck": { + "name": "google_posts_topic_ck", + "value": "\"google_posts\".\"topic_type\" IN ('STANDARD', 'EVENT', 'OFFER')" + }, + "google_posts_status_ck": { + "name": "google_posts_status_ck", + "value": "\"google_posts\".\"status\" IN ('brouillon', 'planifie', 'publishing', 'publie', 'echec', 'bloque', 'annule', 'expire', 'retire')" + }, + "google_posts_summary_ck": { + "name": "google_posts_summary_ck", + "value": "char_length(\"google_posts\".\"summary\") BETWEEN 1 AND 1500" + }, + "google_posts_cta_ck": { + "name": "google_posts_cta_ck", + "value": "\"google_posts\".\"cta_type\" IS NULL OR \"google_posts\".\"cta_type\" IN ('BOOK', 'ORDER', 'SHOP', 'LEARN_MORE', 'SIGN_UP', 'CALL')" + }, + "google_posts_image_ck": { + "name": "google_posts_image_ck", + "value": "(\"google_posts\".\"image\" IS NULL) = (\"google_posts\".\"image_mime\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.haccp_corrective_actions": { + "name": "haccp_corrective_actions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_id": { + "name": "source_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dedup_key": { + "name": "dedup_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "detected_at": { + "name": "detected_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "action_taken": { + "name": "action_taken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "haccp_corrective_actions_dedup_uq": { + "name": "haccp_corrective_actions_dedup_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedup_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "haccp_corrective_actions_open_idx": { + "name": "haccp_corrective_actions_open_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "detected_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"haccp_corrective_actions\".\"closed_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "haccp_corrective_actions_organization_id_organizations_id_fk": { + "name": "haccp_corrective_actions_organization_id_organizations_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_corrective_actions_establishment_id_establishments_id_fk": { + "name": "haccp_corrective_actions_establishment_id_establishments_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_corrective_actions_closed_by_users_id_fk": { + "name": "haccp_corrective_actions_closed_by_users_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "haccp_corrective_actions_created_by_users_id_fk": { + "name": "haccp_corrective_actions_created_by_users_id_fk", + "tableFrom": "haccp_corrective_actions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "haccp_corrective_actions_source_ck": { + "name": "haccp_corrective_actions_source_ck", + "value": "\"haccp_corrective_actions\".\"source\" IN ('sonde_hors_plage', 'sonde_muette', 'releves_manquants', 'nettoyage_manquant', 'date_limite', 'manuel', 'rappel_produit', 'nuisibles')" + }, + "haccp_corrective_actions_close_ck": { + "name": "haccp_corrective_actions_close_ck", + "value": "(\"haccp_corrective_actions\".\"closed_at\" IS NULL) = (\"haccp_corrective_actions\".\"action_taken\" IS NULL) AND (\"haccp_corrective_actions\".\"closed_at\" IS NULL) = (\"haccp_corrective_actions\".\"closed_by\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.haccp_sealed_exports": { + "name": "haccp_sealed_exports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'dossier'" + }, + "period_from": { + "name": "period_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_to": { + "name": "period_to", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "verify_token": { + "name": "verify_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bytes": { + "name": "bytes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "haccp_sealed_exports_token_uq": { + "name": "haccp_sealed_exports_token_uq", + "columns": [ + { + "expression": "verify_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "haccp_sealed_exports_est_idx": { + "name": "haccp_sealed_exports_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "haccp_sealed_exports_organization_id_organizations_id_fk": { + "name": "haccp_sealed_exports_organization_id_organizations_id_fk", + "tableFrom": "haccp_sealed_exports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_sealed_exports_establishment_id_establishments_id_fk": { + "name": "haccp_sealed_exports_establishment_id_establishments_id_fk", + "tableFrom": "haccp_sealed_exports", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "haccp_sealed_exports_created_by_users_id_fk": { + "name": "haccp_sealed_exports_created_by_users_id_fk", + "tableFrom": "haccp_sealed_exports", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "haccp_sealed_exports_kind_ck": { + "name": "haccp_sealed_exports_kind_ck", + "value": "\"haccp_sealed_exports\".\"kind\" IN ('dossier')" + } + }, + "isRLSEnabled": false + }, + "public.incidents": { + "name": "incidents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actions_taken": { + "name": "actions_taken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "reported_by": { + "name": "reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reported_at": { + "name": "reported_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "incidents_est_idx": { + "name": "incidents_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurred_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "incidents_organization_id_organizations_id_fk": { + "name": "incidents_organization_id_organizations_id_fk", + "tableFrom": "incidents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "incidents_establishment_id_establishments_id_fk": { + "name": "incidents_establishment_id_establishments_id_fk", + "tableFrom": "incidents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "incidents_reported_by_users_id_fk": { + "name": "incidents_reported_by_users_id_fk", + "tableFrom": "incidents", + "tableTo": "users", + "columnsFrom": [ + "reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "incidents_closed_by_users_id_fk": { + "name": "incidents_closed_by_users_id_fk", + "tableFrom": "incidents", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "incidents_kind_ck": { + "name": "incidents_kind_ck", + "value": "\"incidents\".\"kind\" IN ('client', 'accident', 'casse', 'vol', 'securite', 'hygiene', 'livraison', 'autre')" + }, + "incidents_severity_ck": { + "name": "incidents_severity_ck", + "value": "\"incidents\".\"severity\" IN ('mineur', 'important', 'grave')" + }, + "incidents_status_ck": { + "name": "incidents_status_ck", + "value": "\"incidents\".\"status\" IN ('ouvert', 'clos')" + }, + "incidents_closed_ck": { + "name": "incidents_closed_ck", + "value": "\"incidents\".\"status\" = 'ouvert' OR (\"incidents\".\"closed_at\" IS NOT NULL AND \"incidents\".\"follow_up\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.inspection_shares": { + "name": "inspection_shares", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inspector_code": { + "name": "inspector_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_name": { + "name": "created_by_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "access_count": { + "name": "access_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_access_at": { + "name": "last_access_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inspection_shares_token_uq": { + "name": "inspection_shares_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inspection_shares_est_idx": { + "name": "inspection_shares_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inspection_shares_organization_id_organizations_id_fk": { + "name": "inspection_shares_organization_id_organizations_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inspection_shares_establishment_id_establishments_id_fk": { + "name": "inspection_shares_establishment_id_establishments_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inspection_shares_created_by_users_id_fk": { + "name": "inspection_shares_created_by_users_id_fk", + "tableFrom": "inspection_shares", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_connections": { + "name": "integration_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "connection_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'not_configured'" + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_config": { + "name": "public_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auto_sync": { + "name": "auto_sync", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sync_interval_hours": { + "name": "sync_interval_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 24 + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integration_conn_uq": { + "name": "integration_conn_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_connections_organization_id_organizations_id_fk": { + "name": "integration_connections_organization_id_organizations_id_fk", + "tableFrom": "integration_connections", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_connections_establishment_id_establishments_id_fk": { + "name": "integration_connections_establishment_id_establishments_id_fk", + "tableFrom": "integration_connections", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "integration_conn_interval_ck": { + "name": "integration_conn_interval_ck", + "value": "\"integration_connections\".\"sync_interval_hours\" BETWEEN 1 AND 168" + }, + "integration_conn_failures_ck": { + "name": "integration_conn_failures_ck", + "value": "\"integration_connections\".\"consecutive_failures\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.integration_sync_runs": { + "name": "integration_sync_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "counts": { + "name": "counts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "errors": { + "name": "errors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "integration_sync_runs_idx": { + "name": "integration_sync_runs_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_sync_runs_organization_id_organizations_id_fk": { + "name": "integration_sync_runs_organization_id_organizations_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_sync_runs_establishment_id_establishments_id_fk": { + "name": "integration_sync_runs_establishment_id_establishments_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "integration_sync_runs_user_id_users_id_fk": { + "name": "integration_sync_runs_user_id_users_id_fk", + "tableFrom": "integration_sync_runs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "integration_sync_runs_trigger_ck": { + "name": "integration_sync_runs_trigger_ck", + "value": "\"integration_sync_runs\".\"trigger\" IN ('manual', 'auto')" + }, + "integration_sync_runs_outcome_ck": { + "name": "integration_sync_runs_outcome_ck", + "value": "\"integration_sync_runs\".\"outcome\" IN ('success', 'partial', 'error')" + } + }, + "isRLSEnabled": false + }, + "public.intercompany_flows": { + "name": "intercompany_flows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payer_company_id": { + "name": "payer_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "payee_company_id": { + "name": "payee_company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "flow_date": { + "name": "flow_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "agreement_ref": { + "name": "agreement_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'saisie'" + }, + "purchase_invoice_id": { + "name": "purchase_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "bank_transaction_id": { + "name": "bank_transaction_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "intercompany_flows_org_idx": { + "name": "intercompany_flows_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "flow_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "intercompany_flows_invoice_uq": { + "name": "intercompany_flows_invoice_uq", + "columns": [ + { + "expression": "purchase_invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"intercompany_flows\".\"purchase_invoice_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "intercompany_flows_bank_uq": { + "name": "intercompany_flows_bank_uq", + "columns": [ + { + "expression": "bank_transaction_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"intercompany_flows\".\"bank_transaction_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "intercompany_flows_organization_id_organizations_id_fk": { + "name": "intercompany_flows_organization_id_organizations_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_payer_company_id_companies_id_fk": { + "name": "intercompany_flows_payer_company_id_companies_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "companies", + "columnsFrom": [ + "payer_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_payee_company_id_companies_id_fk": { + "name": "intercompany_flows_payee_company_id_companies_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "companies", + "columnsFrom": [ + "payee_company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "intercompany_flows_purchase_invoice_id_purchase_invoices_id_fk": { + "name": "intercompany_flows_purchase_invoice_id_purchase_invoices_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "purchase_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "intercompany_flows_bank_transaction_id_bank_transactions_id_fk": { + "name": "intercompany_flows_bank_transaction_id_bank_transactions_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "bank_transactions", + "columnsFrom": [ + "bank_transaction_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "intercompany_flows_created_by_users_id_fk": { + "name": "intercompany_flows_created_by_users_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "intercompany_flows_cancelled_by_users_id_fk": { + "name": "intercompany_flows_cancelled_by_users_id_fk", + "tableFrom": "intercompany_flows", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "intercompany_flows_pair_ck": { + "name": "intercompany_flows_pair_ck", + "value": "\"intercompany_flows\".\"payer_company_id\" <> \"intercompany_flows\".\"payee_company_id\"" + }, + "intercompany_flows_amount_ck": { + "name": "intercompany_flows_amount_ck", + "value": "\"intercompany_flows\".\"amount_ht\" > 0 AND (\"intercompany_flows\".\"vat_amount\" IS NULL OR \"intercompany_flows\".\"vat_amount\" >= 0)" + }, + "intercompany_flows_source_ck": { + "name": "intercompany_flows_source_ck", + "value": "\"intercompany_flows\".\"source\" IN ('saisie', 'facture', 'banque')" + }, + "intercompany_flows_kind_ck": { + "name": "intercompany_flows_kind_ck", + "value": "\"intercompany_flows\".\"kind\" IN ('refacturation', 'management_fees', 'loyer', 'vente', 'interets', 'dividendes', 'pret', 'remboursement_pret', 'apport_compte_courant', 'remboursement_compte_courant', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.inventories": { + "name": "inventories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "count_date": { + "name": "count_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "total_value": { + "name": "total_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inventories_est_idx": { + "name": "inventories_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "count_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inventories_validated_day_uq": { + "name": "inventories_validated_day_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "count_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"inventories\".\"status\" = 'validated'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inventories_organization_id_organizations_id_fk": { + "name": "inventories_organization_id_organizations_id_fk", + "tableFrom": "inventories", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventories_establishment_id_establishments_id_fk": { + "name": "inventories_establishment_id_establishments_id_fk", + "tableFrom": "inventories", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "inventories_created_by_users_id_fk": { + "name": "inventories_created_by_users_id_fk", + "tableFrom": "inventories", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "inventories_validated_by_users_id_fk": { + "name": "inventories_validated_by_users_id_fk", + "tableFrom": "inventories", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "inventories_status_ck": { + "name": "inventories_status_ck", + "value": "\"inventories\".\"status\" IN ('draft', 'validated')" + } + }, + "isRLSEnabled": false + }, + "public.inventory_lines": { + "name": "inventory_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inventory_id": { + "name": "inventory_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inventory_lines_item_uq": { + "name": "inventory_lines_item_uq", + "columns": [ + { + "expression": "inventory_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "inventory_lines_organization_id_organizations_id_fk": { + "name": "inventory_lines_organization_id_organizations_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventory_lines_inventory_id_inventories_id_fk": { + "name": "inventory_lines_inventory_id_inventories_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "inventories", + "columnsFrom": [ + "inventory_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "inventory_lines_item_id_purchase_items_id_fk": { + "name": "inventory_lines_item_id_purchase_items_id_fk", + "tableFrom": "inventory_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "inventory_lines_qty_ck": { + "name": "inventory_lines_qty_ck", + "value": "\"inventory_lines\".\"quantity\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.investment_scenarios": { + "name": "investment_scenarios", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'etude'" + }, + "price": { + "name": "price", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "fees": { + "name": "fees", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "works": { + "name": "works", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "working_capital": { + "name": "working_capital", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "equity": { + "name": "equity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "loan_rate_pct": { + "name": "loan_rate_pct", + "type": "numeric(6, 3)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "loan_years": { + "name": "loan_years", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 7 + }, + "revenue_ht": { + "name": "revenue_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "ebe": { + "name": "ebe", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "adjustments": { + "name": "adjustments", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "owner_pay": { + "name": "owner_pay", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "maintenance_capex": { + "name": "maintenance_capex", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "investment_scenarios_org_idx": { + "name": "investment_scenarios_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "investment_scenarios_organization_id_organizations_id_fk": { + "name": "investment_scenarios_organization_id_organizations_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "investment_scenarios_establishment_id_establishments_id_fk": { + "name": "investment_scenarios_establishment_id_establishments_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "investment_scenarios_created_by_users_id_fk": { + "name": "investment_scenarios_created_by_users_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "investment_scenarios_updated_by_users_id_fk": { + "name": "investment_scenarios_updated_by_users_id_fk", + "tableFrom": "investment_scenarios", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "investment_scenarios_kind_ck": { + "name": "investment_scenarios_kind_ck", + "value": "\"investment_scenarios\".\"kind\" IN ('rachat_fonds', 'rachat_parts', 'travaux', 'equipement', 'ouverture', 'autre')" + }, + "investment_scenarios_status_ck": { + "name": "investment_scenarios_status_ck", + "value": "\"investment_scenarios\".\"status\" IN ('etude', 'retenu', 'abandonne', 'realise')" + }, + "investment_scenarios_years_ck": { + "name": "investment_scenarios_years_ck", + "value": "\"investment_scenarios\".\"loan_years\" BETWEEN 1 AND 30" + }, + "investment_scenarios_rate_ck": { + "name": "investment_scenarios_rate_ck", + "value": "\"investment_scenarios\".\"loan_rate_pct\" >= 0 AND \"investment_scenarios\".\"loan_rate_pct\" <= 20" + }, + "investment_scenarios_amounts_ck": { + "name": "investment_scenarios_amounts_ck", + "value": "\"investment_scenarios\".\"price\" >= 0 AND \"investment_scenarios\".\"fees\" >= 0 AND \"investment_scenarios\".\"works\" >= 0 AND \"investment_scenarios\".\"working_capital\" >= 0 AND \"investment_scenarios\".\"equity\" >= 0 AND \"investment_scenarios\".\"owner_pay\" >= 0 AND \"investment_scenarios\".\"maintenance_capex\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.invoice_label_links": { + "name": "invoice_label_links", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "link_key": { + "name": "link_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invoice_label_links_key_uq": { + "name": "invoice_label_links_key_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "link_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invoice_label_links_organization_id_organizations_id_fk": { + "name": "invoice_label_links_organization_id_organizations_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoice_label_links_item_id_purchase_items_id_fk": { + "name": "invoice_label_links_item_id_purchase_items_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invoice_label_links_created_by_users_id_fk": { + "name": "invoice_label_links_created_by_users_id_fk", + "tableFrom": "invoice_label_links", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.item_stock_settings": { + "name": "item_stock_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "min_stock": { + "name": "min_stock", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "target_stock": { + "name": "target_stock", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "overstock_days": { + "name": "overstock_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "item_stock_settings_uq": { + "name": "item_stock_settings_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "item_stock_settings_organization_id_organizations_id_fk": { + "name": "item_stock_settings_organization_id_organizations_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "item_stock_settings_establishment_id_establishments_id_fk": { + "name": "item_stock_settings_establishment_id_establishments_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "item_stock_settings_item_id_purchase_items_id_fk": { + "name": "item_stock_settings_item_id_purchase_items_id_fk", + "tableFrom": "item_stock_settings", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "item_stock_settings_ck": { + "name": "item_stock_settings_ck", + "value": "(\"item_stock_settings\".\"min_stock\" IS NULL OR \"item_stock_settings\".\"min_stock\" >= 0) AND (\"item_stock_settings\".\"target_stock\" IS NULL OR \"item_stock_settings\".\"target_stock\" >= 0) AND (\"item_stock_settings\".\"overstock_days\" IS NULL OR \"item_stock_settings\".\"overstock_days\" BETWEEN 1 AND 365)" + } + }, + "isRLSEnabled": false + }, + "public.job_openings": { + "name": "job_openings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_kind": { + "name": "contract_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'cdi'" + }, + "weekly_hours": { + "name": "weekly_hours", + "type": "numeric(6, 2)", + "primaryKey": false, + "notNull": false + }, + "start_wanted": { + "name": "start_wanted", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_openings_org_idx": { + "name": "job_openings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_openings_organization_id_organizations_id_fk": { + "name": "job_openings_organization_id_organizations_id_fk", + "tableFrom": "job_openings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_openings_establishment_id_establishments_id_fk": { + "name": "job_openings_establishment_id_establishments_id_fk", + "tableFrom": "job_openings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "job_openings_created_by_users_id_fk": { + "name": "job_openings_created_by_users_id_fk", + "tableFrom": "job_openings", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "job_openings_status_ck": { + "name": "job_openings_status_ck", + "value": "\"job_openings\".\"status\" IN ('ouvert', 'pourvu', 'ferme')" + }, + "job_openings_hours_ck": { + "name": "job_openings_hours_ck", + "value": "\"job_openings\".\"weekly_hours\" IS NULL OR (\"job_openings\".\"weekly_hours\" > 0 AND \"job_openings\".\"weekly_hours\" <= 48)" + } + }, + "isRLSEnabled": false + }, + "public.kitchen_labels": { + "name": "kitchen_labels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "supplier_lot": { + "name": "supplier_lot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "produced_at": { + "name": "produced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "original_dlc": { + "name": "original_dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "shelf_life_days": { + "name": "shelf_life_days", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "ingredients": { + "name": "ingredients", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "storage_note": { + "name": "storage_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "copies": { + "name": "copies", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "trace_label_id": { + "name": "trace_label_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "printed_by": { + "name": "printed_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "kitchen_labels_est_idx": { + "name": "kitchen_labels_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "produced_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kitchen_labels_lot_uq": { + "name": "kitchen_labels_lot_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lot_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "kitchen_labels_organization_id_organizations_id_fk": { + "name": "kitchen_labels_organization_id_organizations_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "kitchen_labels_establishment_id_establishments_id_fk": { + "name": "kitchen_labels_establishment_id_establishments_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "kitchen_labels_recipe_id_recipes_id_fk": { + "name": "kitchen_labels_recipe_id_recipes_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "kitchen_labels_item_id_purchase_items_id_fk": { + "name": "kitchen_labels_item_id_purchase_items_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "kitchen_labels_trace_label_id_trace_labels_id_fk": { + "name": "kitchen_labels_trace_label_id_trace_labels_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "trace_labels", + "columnsFrom": [ + "trace_label_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "kitchen_labels_printed_by_users_id_fk": { + "name": "kitchen_labels_printed_by_users_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "users", + "columnsFrom": [ + "printed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "kitchen_labels_cancelled_by_users_id_fk": { + "name": "kitchen_labels_cancelled_by_users_id_fk", + "tableFrom": "kitchen_labels", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "kitchen_labels_kind_ck": { + "name": "kitchen_labels_kind_ck", + "value": "\"kitchen_labels\".\"kind\" IN ('production', 'ouverture', 'temoin')" + }, + "kitchen_labels_format_ck": { + "name": "kitchen_labels_format_ck", + "value": "\"kitchen_labels\".\"format\" IN ('62x29', '62x100', '102x152')" + }, + "kitchen_labels_copies_ck": { + "name": "kitchen_labels_copies_ck", + "value": "\"kitchen_labels\".\"copies\" BETWEEN 1 AND 50 AND \"kitchen_labels\".\"shelf_life_days\" BETWEEN 0 AND 90" + }, + "kitchen_labels_service_ck": { + "name": "kitchen_labels_service_ck", + "value": "\"kitchen_labels\".\"service\" IS NULL OR \"kitchen_labels\".\"service\" IN ('midi', 'soir')" + } + }, + "isRLSEnabled": false + }, + "public.known_devices": { + "name": "known_devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_ip": { + "name": "last_ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "alerted_at": { + "name": "alerted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "known_devices_uq": { + "name": "known_devices_uq", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "known_devices_user_idx": { + "name": "known_devices_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_seen_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "known_devices_user_id_users_id_fk": { + "name": "known_devices_user_id_users_id_fk", + "tableFrom": "known_devices", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lead_activities": { + "name": "lead_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "lead_id": { + "name": "lead_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "lead_activities_lead_idx": { + "name": "lead_activities_lead_idx", + "columns": [ + { + "expression": "lead_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "lead_activities_organization_id_organizations_id_fk": { + "name": "lead_activities_organization_id_organizations_id_fk", + "tableFrom": "lead_activities", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lead_activities_lead_id_leads_id_fk": { + "name": "lead_activities_lead_id_leads_id_fk", + "tableFrom": "lead_activities", + "tableTo": "leads", + "columnsFrom": [ + "lead_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "lead_activities_created_by_users_id_fk": { + "name": "lead_activities_created_by_users_id_fk", + "tableFrom": "lead_activities", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.leads": { + "name": "leads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_kind": { + "name": "event_kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "guests": { + "name": "guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "budget_ttc": { + "name": "budget_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "company": { + "name": "company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'nouveau'" + }, + "lost_reason": { + "name": "lost_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_action_on": { + "name": "next_action_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "next_action": { + "name": "next_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_user_id": { + "name": "owner_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "set_menu_id": { + "name": "set_menu_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "leads_org_stage_idx": { + "name": "leads_org_stage_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stage", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_action_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "leads_est_idx": { + "name": "leads_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "leads_organization_id_organizations_id_fk": { + "name": "leads_organization_id_organizations_id_fk", + "tableFrom": "leads", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leads_establishment_id_establishments_id_fk": { + "name": "leads_establishment_id_establishments_id_fk", + "tableFrom": "leads", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "leads_customer_id_customers_id_fk": { + "name": "leads_customer_id_customers_id_fk", + "tableFrom": "leads", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_owner_user_id_users_id_fk": { + "name": "leads_owner_user_id_users_id_fk", + "tableFrom": "leads", + "tableTo": "users", + "columnsFrom": [ + "owner_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_set_menu_id_set_menus_id_fk": { + "name": "leads_set_menu_id_set_menus_id_fk", + "tableFrom": "leads", + "tableTo": "set_menus", + "columnsFrom": [ + "set_menu_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "leads_created_by_users_id_fk": { + "name": "leads_created_by_users_id_fk", + "tableFrom": "leads", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leads_stage_ck": { + "name": "leads_stage_ck", + "value": "\"leads\".\"stage\" IN ('nouveau', 'contacte', 'devis', 'negociation', 'gagne', 'perdu')" + }, + "leads_guests_ck": { + "name": "leads_guests_ck", + "value": "\"leads\".\"guests\" IS NULL OR (\"leads\".\"guests\" > 0 AND \"leads\".\"guests\" <= 5000)" + }, + "leads_budget_ck": { + "name": "leads_budget_ck", + "value": "\"leads\".\"budget_ttc\" IS NULL OR \"leads\".\"budget_ttc\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.leave_adjustments": { + "name": "leave_adjustments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counter": { + "name": "counter", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "leave_adjustments_emp_idx": { + "name": "leave_adjustments_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "leave_adjustments_organization_id_organizations_id_fk": { + "name": "leave_adjustments_organization_id_organizations_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_adjustments_employee_id_employees_id_fk": { + "name": "leave_adjustments_employee_id_employees_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_adjustments_created_by_users_id_fk": { + "name": "leave_adjustments_created_by_users_id_fk", + "tableFrom": "leave_adjustments", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leave_adjustments_counter_ck": { + "name": "leave_adjustments_counter_ck", + "value": "\"leave_adjustments\".\"counter\" IN ('cp_n1', 'cp_n', 'rc')" + }, + "leave_adjustments_amount_ck": { + "name": "leave_adjustments_amount_ck", + "value": "\"leave_adjustments\".\"amount\" <> 0 AND abs(\"leave_adjustments\".\"amount\") <= 500" + } + }, + "isRLSEnabled": false + }, + "public.leave_settings": { + "name": "leave_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cp_unit": { + "name": "cp_unit", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvrables'" + }, + "overtime_as_rest": { + "name": "overtime_as_rest", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "leave_settings_establishment_id_establishments_id_fk": { + "name": "leave_settings_establishment_id_establishments_id_fk", + "tableFrom": "leave_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_settings_organization_id_organizations_id_fk": { + "name": "leave_settings_organization_id_organizations_id_fk", + "tableFrom": "leave_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "leave_settings_updated_by_users_id_fk": { + "name": "leave_settings_updated_by_users_id_fk", + "tableFrom": "leave_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "leave_settings_unit_ck": { + "name": "leave_settings_unit_ck", + "value": "\"leave_settings\".\"cp_unit\" IN ('ouvrables', 'ouvres')" + } + }, + "isRLSEnabled": false + }, + "public.logbook_entries": { + "name": "logbook_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "important": { + "name": "important", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "done_note": { + "name": "done_note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "logbook_entries_est_idx": { + "name": "logbook_entries_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "logbook_entries_organization_id_organizations_id_fk": { + "name": "logbook_entries_organization_id_organizations_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "logbook_entries_establishment_id_establishments_id_fk": { + "name": "logbook_entries_establishment_id_establishments_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "logbook_entries_author_id_users_id_fk": { + "name": "logbook_entries_author_id_users_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "logbook_entries_done_by_users_id_fk": { + "name": "logbook_entries_done_by_users_id_fk", + "tableFrom": "logbook_entries", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "logbook_entries_category_ck": { + "name": "logbook_entries_category_ck", + "value": "\"logbook_entries\".\"category\" IN ('info', 'a_traiter', 'client', 'livraison', 'equipe')" + } + }, + "isRLSEnabled": false + }, + "public.logbook_reads": { + "name": "logbook_reads", + "schema": "", + "columns": { + "entry_id": { + "name": "entry_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "logbook_reads_entry_id_logbook_entries_id_fk": { + "name": "logbook_reads_entry_id_logbook_entries_id_fk", + "tableFrom": "logbook_reads", + "tableTo": "logbook_entries", + "columnsFrom": [ + "entry_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "logbook_reads_user_id_users_id_fk": { + "name": "logbook_reads_user_id_users_id_fk", + "tableFrom": "logbook_reads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "logbook_reads_entry_id_user_id_pk": { + "name": "logbook_reads_entry_id_user_id_pk", + "columns": [ + "entry_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.loyalty_events": { + "name": "loyalty_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visits": { + "name": "visits", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "loyalty_events_customer_idx": { + "name": "loyalty_events_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "loyalty_events_est_idx": { + "name": "loyalty_events_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "loyalty_events_organization_id_organizations_id_fk": { + "name": "loyalty_events_organization_id_organizations_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_establishment_id_establishments_id_fk": { + "name": "loyalty_events_establishment_id_establishments_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_customer_id_customers_id_fk": { + "name": "loyalty_events_customer_id_customers_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_events_created_by_users_id_fk": { + "name": "loyalty_events_created_by_users_id_fk", + "tableFrom": "loyalty_events", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "loyalty_events_kind_ck": { + "name": "loyalty_events_kind_ck", + "value": "\"loyalty_events\".\"kind\" IN ('ajustement', 'recompense')" + }, + "loyalty_events_visits_ck": { + "name": "loyalty_events_visits_ck", + "value": "\"loyalty_events\".\"visits\" <> 0 AND (\"loyalty_events\".\"kind\" <> 'recompense' OR \"loyalty_events\".\"visits\" < 0)" + } + }, + "isRLSEnabled": false + }, + "public.loyalty_programs": { + "name": "loyalty_programs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "visits_per_reward": { + "name": "visits_per_reward", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reward_label": { + "name": "reward_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starts_on": { + "name": "starts_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "loyalty_programs_est_uq": { + "name": "loyalty_programs_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "loyalty_programs_org_idx": { + "name": "loyalty_programs_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "loyalty_programs_organization_id_organizations_id_fk": { + "name": "loyalty_programs_organization_id_organizations_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_programs_establishment_id_establishments_id_fk": { + "name": "loyalty_programs_establishment_id_establishments_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "loyalty_programs_updated_by_users_id_fk": { + "name": "loyalty_programs_updated_by_users_id_fk", + "tableFrom": "loyalty_programs", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "loyalty_programs_visits_ck": { + "name": "loyalty_programs_visits_ck", + "value": "\"loyalty_programs\".\"visits_per_reward\" BETWEEN 2 AND 50" + } + }, + "isRLSEnabled": false + }, + "public.mail_accounts": { + "name": "mail_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gmail'" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'connected'" + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "cursor_ms": { + "name": "cursor_ms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_by": { + "name": "connected_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_accounts_email_uq": { + "name": "mail_accounts_email_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_accounts_organization_id_organizations_id_fk": { + "name": "mail_accounts_organization_id_organizations_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_accounts_establishment_id_establishments_id_fk": { + "name": "mail_accounts_establishment_id_establishments_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_accounts_connected_by_users_id_fk": { + "name": "mail_accounts_connected_by_users_id_fk", + "tableFrom": "mail_accounts", + "tableTo": "users", + "columnsFrom": [ + "connected_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_accounts_provider_ck": { + "name": "mail_accounts_provider_ck", + "value": "\"mail_accounts\".\"provider\" IN ('gmail', 'outlook')" + }, + "mail_accounts_status_ck": { + "name": "mail_accounts_status_ck", + "value": "\"mail_accounts\".\"status\" IN ('connected', 'error', 'disabled')" + }, + "mail_accounts_failures_ck": { + "name": "mail_accounts_failures_ck", + "value": "\"mail_accounts\".\"consecutive_failures\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.mail_documents": { + "name": "mail_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "part_id": { + "name": "part_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_verifier'" + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "suggested_issue_id": { + "name": "suggested_issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "match_reason": { + "name": "match_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "business_document_id": { + "name": "business_document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "maintenance_invoice_id": { + "name": "maintenance_invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_documents_part_uq": { + "name": "mail_documents_part_uq", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "part_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_documents_org_idx": { + "name": "mail_documents_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_documents_organization_id_organizations_id_fk": { + "name": "mail_documents_organization_id_organizations_id_fk", + "tableFrom": "mail_documents", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_documents_message_id_mail_messages_id_fk": { + "name": "mail_documents_message_id_mail_messages_id_fk", + "tableFrom": "mail_documents", + "tableTo": "mail_messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_documents_establishment_id_establishments_id_fk": { + "name": "mail_documents_establishment_id_establishments_id_fk", + "tableFrom": "mail_documents", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_supplier_id_suppliers_id_fk": { + "name": "mail_documents_supplier_id_suppliers_id_fk", + "tableFrom": "mail_documents", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_pennylane_record_id_pennylane_records_id_fk": { + "name": "mail_documents_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "mail_documents", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_suggested_issue_id_maintenance_issues_id_fk": { + "name": "mail_documents_suggested_issue_id_maintenance_issues_id_fk", + "tableFrom": "mail_documents", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "suggested_issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_business_document_id_business_documents_id_fk": { + "name": "mail_documents_business_document_id_business_documents_id_fk", + "tableFrom": "mail_documents", + "tableTo": "business_documents", + "columnsFrom": [ + "business_document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_maintenance_invoice_id_maintenance_invoices_id_fk": { + "name": "mail_documents_maintenance_invoice_id_maintenance_invoices_id_fk", + "tableFrom": "mail_documents", + "tableTo": "maintenance_invoices", + "columnsFrom": [ + "maintenance_invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_documents_decided_by_users_id_fk": { + "name": "mail_documents_decided_by_users_id_fk", + "tableFrom": "mail_documents", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_documents_kind_ck": { + "name": "mail_documents_kind_ck", + "value": "\"mail_documents\".\"kind\" IN ('facture', 'devis', 'attestation', 'autre')" + }, + "mail_documents_status_ck": { + "name": "mail_documents_status_ck", + "value": "\"mail_documents\".\"status\" IN ('a_verifier', 'verifiee', 'classee', 'ignoree')" + }, + "mail_documents_size_ck": { + "name": "mail_documents_size_ck", + "value": "\"mail_documents\".\"size\" <= 4718592" + } + }, + "isRLSEnabled": false + }, + "public.mail_messages": { + "name": "mail_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_id": { + "name": "thread_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_email": { + "name": "from_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "to_text": { + "name": "to_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "attachment_count": { + "name": "attachment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_messages_ext_uq": { + "name": "mail_messages_ext_uq", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_messages_org_idx": { + "name": "mail_messages_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_messages_organization_id_organizations_id_fk": { + "name": "mail_messages_organization_id_organizations_id_fk", + "tableFrom": "mail_messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_messages_account_id_mail_accounts_id_fk": { + "name": "mail_messages_account_id_mail_accounts_id_fk", + "tableFrom": "mail_messages", + "tableTo": "mail_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_messages_category_ck": { + "name": "mail_messages_category_ck", + "value": "\"mail_messages\".\"category\" IN ('facture', 'devis', 'attestation', 'reservation', 'commande', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.mail_reply_drafts": { + "name": "mail_reply_drafts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "to_email": { + "name": "to_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_valider'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "outbox_id": { + "name": "outbox_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mail_reply_drafts_message_uq": { + "name": "mail_reply_drafts_message_uq", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mail_reply_drafts_org_idx": { + "name": "mail_reply_drafts_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_reply_drafts_organization_id_organizations_id_fk": { + "name": "mail_reply_drafts_organization_id_organizations_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_account_id_mail_accounts_id_fk": { + "name": "mail_reply_drafts_account_id_mail_accounts_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_accounts", + "columnsFrom": [ + "account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_message_id_mail_messages_id_fk": { + "name": "mail_reply_drafts_message_id_mail_messages_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_drafts_template_id_mail_reply_templates_id_fk": { + "name": "mail_reply_drafts_template_id_mail_reply_templates_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "mail_reply_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mail_reply_drafts_decided_by_users_id_fk": { + "name": "mail_reply_drafts_decided_by_users_id_fk", + "tableFrom": "mail_reply_drafts", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_reply_drafts_status_ck": { + "name": "mail_reply_drafts_status_ck", + "value": "\"mail_reply_drafts\".\"status\" IN ('a_valider', 'envoye', 'ecarte')" + } + }, + "isRLSEnabled": false + }, + "public.mail_reply_templates": { + "name": "mail_reply_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "mail_reply_templates_org_idx": { + "name": "mail_reply_templates_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mail_reply_templates_organization_id_organizations_id_fk": { + "name": "mail_reply_templates_organization_id_organizations_id_fk", + "tableFrom": "mail_reply_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mail_reply_templates_created_by_users_id_fk": { + "name": "mail_reply_templates_created_by_users_id_fk", + "tableFrom": "mail_reply_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "mail_reply_templates_category_ck": { + "name": "mail_reply_templates_category_ck", + "value": "\"mail_reply_templates\".\"category\" IN ('facture', 'devis', 'attestation', 'reservation', 'commande', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_interventions": { + "name": "maintenance_interventions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "performed_on": { + "name": "performed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cost_ht": { + "name": "cost_ht", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": false + }, + "invoice_ref": { + "name": "invoice_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_due_on": { + "name": "next_due_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_interventions_eq_idx": { + "name": "maintenance_interventions_eq_idx", + "columns": [ + { + "expression": "equipment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "performed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_interventions_organization_id_organizations_id_fk": { + "name": "maintenance_interventions_organization_id_organizations_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_interventions_establishment_id_establishments_id_fk": { + "name": "maintenance_interventions_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_equipment_id_equipment_id_fk": { + "name": "maintenance_interventions_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_interventions_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_interventions_recorded_by_users_id_fk": { + "name": "maintenance_interventions_recorded_by_users_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_interventions_cancelled_by_users_id_fk": { + "name": "maintenance_interventions_cancelled_by_users_id_fk", + "tableFrom": "maintenance_interventions", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_interventions_kind_ck": { + "name": "maintenance_interventions_kind_ck", + "value": "\"maintenance_interventions\".\"kind\" IN ('preventive', 'curative', 'reglementaire')" + }, + "maintenance_interventions_cost_ck": { + "name": "maintenance_interventions_cost_ck", + "value": "\"maintenance_interventions\".\"cost_ht\" IS NULL OR \"maintenance_interventions\".\"cost_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_invoices": { + "name": "maintenance_invoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quote_id": { + "name": "quote_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pennylane_record_id": { + "name": "pennylane_record_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'reparation'" + }, + "repairer": { + "name": "repairer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "document_mime": { + "name": "document_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_name": { + "name": "document_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "match_reason": { + "name": "match_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "linked_by": { + "name": "linked_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_invoices_est_idx": { + "name": "maintenance_invoices_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_invoices_issue_idx": { + "name": "maintenance_invoices_issue_idx", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_invoices_pennylane_uq": { + "name": "maintenance_invoices_pennylane_uq", + "columns": [ + { + "expression": "pennylane_record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"maintenance_invoices\".\"pennylane_record_id\" IS NOT NULL AND \"maintenance_invoices\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_invoices_organization_id_organizations_id_fk": { + "name": "maintenance_invoices_organization_id_organizations_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_invoices_establishment_id_establishments_id_fk": { + "name": "maintenance_invoices_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_equipment_id_equipment_id_fk": { + "name": "maintenance_invoices_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_invoices_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_quote_id_maintenance_quotes_id_fk": { + "name": "maintenance_invoices_quote_id_maintenance_quotes_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "maintenance_quotes", + "columnsFrom": [ + "quote_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_invoices_pennylane_record_id_pennylane_records_id_fk": { + "name": "maintenance_invoices_pennylane_record_id_pennylane_records_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "pennylane_records", + "columnsFrom": [ + "pennylane_record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_invoices_linked_by_users_id_fk": { + "name": "maintenance_invoices_linked_by_users_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "users", + "columnsFrom": [ + "linked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_invoices_cancelled_by_users_id_fk": { + "name": "maintenance_invoices_cancelled_by_users_id_fk", + "tableFrom": "maintenance_invoices", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_invoices_source_ck": { + "name": "maintenance_invoices_source_ck", + "value": "\"maintenance_invoices\".\"source\" IN ('pennylane', 'document', 'saisie')" + }, + "maintenance_invoices_kind_ck": { + "name": "maintenance_invoices_kind_ck", + "value": "\"maintenance_invoices\".\"kind\" IN ('entretien', 'reparation', 'controle')" + }, + "maintenance_invoices_amount_ck": { + "name": "maintenance_invoices_amount_ck", + "value": "(\"maintenance_invoices\".\"amount_ht\" IS NOT NULL OR \"maintenance_invoices\".\"amount_ttc\" IS NOT NULL) AND (\"maintenance_invoices\".\"amount_ht\" IS NULL OR \"maintenance_invoices\".\"amount_ht\" >= 0) AND (\"maintenance_invoices\".\"amount_ttc\" IS NULL OR \"maintenance_invoices\".\"amount_ttc\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_issues": { + "name": "maintenance_issues", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ouvert'" + }, + "reported_by": { + "name": "reported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reported_at": { + "name": "reported_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "resolved_at": { + "name": "resolved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "resolution": { + "name": "resolution", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_issues_est_idx": { + "name": "maintenance_issues_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_issues_organization_id_organizations_id_fk": { + "name": "maintenance_issues_organization_id_organizations_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_issues_establishment_id_establishments_id_fk": { + "name": "maintenance_issues_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_issues_equipment_id_equipment_id_fk": { + "name": "maintenance_issues_equipment_id_equipment_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_issues_reported_by_users_id_fk": { + "name": "maintenance_issues_reported_by_users_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "users", + "columnsFrom": [ + "reported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_issues_resolved_by_users_id_fk": { + "name": "maintenance_issues_resolved_by_users_id_fk", + "tableFrom": "maintenance_issues", + "tableTo": "users", + "columnsFrom": [ + "resolved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_issues_severity_ck": { + "name": "maintenance_issues_severity_ck", + "value": "\"maintenance_issues\".\"severity\" IN ('bloquant', 'genant', 'mineur')" + }, + "maintenance_issues_status_ck": { + "name": "maintenance_issues_status_ck", + "value": "\"maintenance_issues\".\"status\" IN ('ouvert', 'en_cours', 'resolu')" + } + }, + "isRLSEnabled": false + }, + "public.maintenance_quotes": { + "name": "maintenance_quotes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "repairer": { + "name": "repairer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quote_ref": { + "name": "quote_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document": { + "name": "document", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "document_mime": { + "name": "document_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_name": { + "name": "document_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "extracted": { + "name": "extracted", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'a_valider'" + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "maintenance_quotes_issue_idx": { + "name": "maintenance_quotes_issue_idx", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_quotes_est_idx": { + "name": "maintenance_quotes_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "maintenance_quotes_one_valid_uq": { + "name": "maintenance_quotes_one_valid_uq", + "columns": [ + { + "expression": "issue_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"maintenance_quotes\".\"status\" = 'valide'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "maintenance_quotes_organization_id_organizations_id_fk": { + "name": "maintenance_quotes_organization_id_organizations_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "maintenance_quotes_establishment_id_establishments_id_fk": { + "name": "maintenance_quotes_establishment_id_establishments_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_quotes_issue_id_maintenance_issues_id_fk": { + "name": "maintenance_quotes_issue_id_maintenance_issues_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "maintenance_issues", + "columnsFrom": [ + "issue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "maintenance_quotes_decided_by_users_id_fk": { + "name": "maintenance_quotes_decided_by_users_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "maintenance_quotes_created_by_users_id_fk": { + "name": "maintenance_quotes_created_by_users_id_fk", + "tableFrom": "maintenance_quotes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "maintenance_quotes_status_ck": { + "name": "maintenance_quotes_status_ck", + "value": "\"maintenance_quotes\".\"status\" IN ('a_valider', 'valide', 'refuse')" + }, + "maintenance_quotes_amount_ck": { + "name": "maintenance_quotes_amount_ck", + "value": "(\"maintenance_quotes\".\"amount_ht\" IS NOT NULL OR \"maintenance_quotes\".\"amount_ttc\" IS NOT NULL) AND (\"maintenance_quotes\".\"amount_ht\" IS NULL OR \"maintenance_quotes\".\"amount_ht\" >= 0) AND (\"maintenance_quotes\".\"amount_ttc\" IS NULL OR \"maintenance_quotes\".\"amount_ttc\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.marketing_campaigns": { + "name": "marketing_campaigns", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "segment": { + "name": "segment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sms_text": { + "name": "sms_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "recipients_count": { + "name": "recipients_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "marketing_campaigns_org_idx": { + "name": "marketing_campaigns_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "marketing_campaigns_organization_id_organizations_id_fk": { + "name": "marketing_campaigns_organization_id_organizations_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "marketing_campaigns_establishment_id_establishments_id_fk": { + "name": "marketing_campaigns_establishment_id_establishments_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "marketing_campaigns_created_by_users_id_fk": { + "name": "marketing_campaigns_created_by_users_id_fk", + "tableFrom": "marketing_campaigns", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "marketing_campaigns_status_ck": { + "name": "marketing_campaigns_status_ck", + "value": "\"marketing_campaigns\".\"status\" IN ('brouillon', 'envoyee')" + } + }, + "isRLSEnabled": false + }, + "public.media_assets": { + "name": "media_assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'upload'" + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_count": { + "name": "used_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "media_assets_org_idx": { + "name": "media_assets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_assets_recipe_idx": { + "name": "media_assets_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "media_assets_hash_uq": { + "name": "media_assets_hash_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "media_assets_organization_id_organizations_id_fk": { + "name": "media_assets_organization_id_organizations_id_fk", + "tableFrom": "media_assets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "media_assets_establishment_id_establishments_id_fk": { + "name": "media_assets_establishment_id_establishments_id_fk", + "tableFrom": "media_assets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "media_assets_recipe_id_recipes_id_fk": { + "name": "media_assets_recipe_id_recipes_id_fk", + "tableFrom": "media_assets", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "media_assets_created_by_users_id_fk": { + "name": "media_assets_created_by_users_id_fk", + "tableFrom": "media_assets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "media_assets_source_ck": { + "name": "media_assets_source_ck", + "value": "\"media_assets\".\"source\" IN ('upload', 'fiche', 'studio')" + }, + "media_assets_mime_ck": { + "name": "media_assets_mime_ck", + "value": "\"media_assets\".\"mime\" IN ('image/jpeg', 'image/png', 'image/webp')" + }, + "media_assets_size_ck": { + "name": "media_assets_size_ck", + "value": "\"media_assets\".\"size\" BETWEEN 1 AND 5242880" + }, + "media_assets_title_ck": { + "name": "media_assets_title_ck", + "value": "char_length(\"media_assets\".\"title\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + }, + "public.membership_establishments": { + "name": "membership_establishments", + "schema": "", + "columns": { + "membership_id": { + "name": "membership_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "membership_establishments_membership_id_memberships_id_fk": { + "name": "membership_establishments_membership_id_memberships_id_fk", + "tableFrom": "membership_establishments", + "tableTo": "memberships", + "columnsFrom": [ + "membership_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "membership_establishments_establishment_id_establishments_id_fk": { + "name": "membership_establishments_establishment_id_establishments_id_fk", + "tableFrom": "membership_establishments", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "membership_establishments_membership_id_establishment_id_pk": { + "name": "membership_establishments_membership_id_establishment_id_pk", + "columns": [ + "membership_id", + "establishment_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memberships": { + "name": "memberships", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "all_establishments": { + "name": "all_establishments", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "permissions_added": { + "name": "permissions_added", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "permissions_removed": { + "name": "permissions_removed", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "memberships_user_org_uq": { + "name": "memberships_user_org_uq", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memberships_user_id_users_id_fk": { + "name": "memberships_user_id_users_id_fk", + "tableFrom": "memberships", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "memberships_organization_id_organizations_id_fk": { + "name": "memberships_organization_id_organizations_id_fk", + "tableFrom": "memberships", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "messages_conv_idx": { + "name": "messages_conv_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "messages_organization_id_organizations_id_fk": { + "name": "messages_organization_id_organizations_id_fk", + "tableFrom": "messages", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_conversation_id_conversations_id_fk": { + "name": "messages_conversation_id_conversations_id_fk", + "tableFrom": "messages", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_user_id_users_id_fk": { + "name": "messages_user_id_users_id_fk", + "tableFrom": "messages", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mfa_challenges": { + "name": "mfa_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mfa_challenges_user_idx": { + "name": "mfa_challenges_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mfa_challenges_user_id_users_id_fk": { + "name": "mfa_challenges_user_id_users_id_fk", + "tableFrom": "mfa_challenges", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.monthly_budgets": { + "name": "monthly_budgets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "month": { + "name": "month", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "revenue_ht": { + "name": "revenue_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "charges_ht": { + "name": "charges_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "food_cost_pct": { + "name": "food_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "beverage_cost_pct": { + "name": "beverage_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "labor_cost_pct": { + "name": "labor_cost_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "monthly_budgets_est_month_uq": { + "name": "monthly_budgets_est_month_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "monthly_budgets_org_idx": { + "name": "monthly_budgets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "monthly_budgets_organization_id_organizations_id_fk": { + "name": "monthly_budgets_organization_id_organizations_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "monthly_budgets_establishment_id_establishments_id_fk": { + "name": "monthly_budgets_establishment_id_establishments_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "monthly_budgets_updated_by_users_id_fk": { + "name": "monthly_budgets_updated_by_users_id_fk", + "tableFrom": "monthly_budgets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "monthly_budgets_month_ck": { + "name": "monthly_budgets_month_ck", + "value": "extract(day from \"monthly_budgets\".\"month\") = 1" + }, + "monthly_budgets_values_ck": { + "name": "monthly_budgets_values_ck", + "value": "(\"monthly_budgets\".\"revenue_ht\" IS NULL OR \"monthly_budgets\".\"revenue_ht\" >= 0) AND (\"monthly_budgets\".\"charges_ht\" IS NULL OR \"monthly_budgets\".\"charges_ht\" >= 0) AND (\"monthly_budgets\".\"covers\" IS NULL OR \"monthly_budgets\".\"covers\" >= 0)\n AND (\"monthly_budgets\".\"food_cost_pct\" IS NULL OR \"monthly_budgets\".\"food_cost_pct\" BETWEEN 0 AND 100) AND (\"monthly_budgets\".\"beverage_cost_pct\" IS NULL OR \"monthly_budgets\".\"beverage_cost_pct\" BETWEEN 0 AND 100) AND (\"monthly_budgets\".\"labor_cost_pct\" IS NULL OR \"monthly_budgets\".\"labor_cost_pct\" BETWEEN 0 AND 100)" + } + }, + "isRLSEnabled": false + }, + "public.notification_deliveries": { + "name": "notification_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "notification_id": { + "name": "notification_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_outbox_id": { + "name": "email_outbox_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "push_subscription_id": { + "name": "push_subscription_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notification_deliveries_org_idx": { + "name": "notification_deliveries_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_deliveries_user_idx": { + "name": "notification_deliveries_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notification_deliveries_pending_idx": { + "name": "notification_deliveries_pending_idx", + "columns": [ + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notification_deliveries_organization_id_organizations_id_fk": { + "name": "notification_deliveries_organization_id_organizations_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_deliveries_user_id_users_id_fk": { + "name": "notification_deliveries_user_id_users_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_deliveries_notification_id_notifications_id_fk": { + "name": "notification_deliveries_notification_id_notifications_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "notifications", + "columnsFrom": [ + "notification_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "notification_deliveries_email_outbox_id_email_outbox_id_fk": { + "name": "notification_deliveries_email_outbox_id_email_outbox_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "email_outbox", + "columnsFrom": [ + "email_outbox_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "notification_deliveries_push_subscription_id_push_subscriptions_id_fk": { + "name": "notification_deliveries_push_subscription_id_push_subscriptions_id_fk", + "tableFrom": "notification_deliveries", + "tableTo": "push_subscriptions", + "columnsFrom": [ + "push_subscription_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_deliveries_channel_ck": { + "name": "notification_deliveries_channel_ck", + "value": "\"notification_deliveries\".\"channel\" IN ('in_app', 'email', 'push', 'sms')" + }, + "notification_deliveries_status_ck": { + "name": "notification_deliveries_status_ck", + "value": "\"notification_deliveries\".\"status\" IN ('envoye', 'en_attente', 'echec', 'simule', 'desactive', 'indisponible')" + } + }, + "isRLSEnabled": false + }, + "public.notification_preferences": { + "name": "notification_preferences", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notification_preferences_organization_id_organizations_id_fk": { + "name": "notification_preferences_organization_id_organizations_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_preferences_user_id_users_id_fk": { + "name": "notification_preferences_user_id_users_id_fk", + "tableFrom": "notification_preferences", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "notification_preferences_organization_id_user_id_category_channel_pk": { + "name": "notification_preferences_organization_id_user_id_category_channel_pk", + "columns": [ + "organization_id", + "user_id", + "category", + "channel" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_preferences_channel_ck": { + "name": "notification_preferences_channel_ck", + "value": "\"notification_preferences\".\"channel\" IN ('in_app', 'email', 'push', 'sms')" + } + }, + "isRLSEnabled": false + }, + "public.notification_templates": { + "name": "notification_templates", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notification_templates_organization_id_organizations_id_fk": { + "name": "notification_templates_organization_id_organizations_id_fk", + "tableFrom": "notification_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_templates_updated_by_users_id_fk": { + "name": "notification_templates_updated_by_users_id_fk", + "tableFrom": "notification_templates", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "notification_templates_organization_id_category_channel_pk": { + "name": "notification_templates_organization_id_category_channel_pk", + "columns": [ + "organization_id", + "category", + "channel" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "notification_templates_channel_ck": { + "name": "notification_templates_channel_ck", + "value": "\"notification_templates\".\"channel\" IN ('email', 'push', 'sms')" + } + }, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_user_idx": { + "name": "notifications_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_organization_id_organizations_id_fk": { + "name": "notifications_organization_id_organizations_id_fk", + "tableFrom": "notifications", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oil_checks": { + "name": "oil_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "polar_pct": { + "name": "polar_pct", + "type": "numeric(4, 1)", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "oil_checks_est_idx": { + "name": "oil_checks_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "checked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "oil_checks_organization_id_organizations_id_fk": { + "name": "oil_checks_organization_id_organizations_id_fk", + "tableFrom": "oil_checks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oil_checks_establishment_id_establishments_id_fk": { + "name": "oil_checks_establishment_id_establishments_id_fk", + "tableFrom": "oil_checks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "oil_checks_equipment_id_equipment_id_fk": { + "name": "oil_checks_equipment_id_equipment_id_fk", + "tableFrom": "oil_checks", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "oil_checks_recorded_by_users_id_fk": { + "name": "oil_checks_recorded_by_users_id_fk", + "tableFrom": "oil_checks", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "oil_checks_cancelled_by_users_id_fk": { + "name": "oil_checks_cancelled_by_users_id_fk", + "tableFrom": "oil_checks", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "oil_checks_kind_ck": { + "name": "oil_checks_kind_ck", + "value": "\"oil_checks\".\"kind\" IN ('controle', 'filtrage', 'changement')" + }, + "oil_checks_action_ck": { + "name": "oil_checks_action_ck", + "value": "\"oil_checks\".\"conform\" OR \"oil_checks\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.onboarding_items": { + "name": "onboarding_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "step_id": { + "name": "step_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "due_on": { + "name": "due_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "auto_check": { + "name": "auto_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "done_how": { + "name": "done_how", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_items_emp_idx": { + "name": "onboarding_items_emp_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "onboarding_items_step_uq": { + "name": "onboarding_items_step_uq", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "step_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"onboarding_items\".\"step_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_items_organization_id_organizations_id_fk": { + "name": "onboarding_items_organization_id_organizations_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_items_employee_id_employees_id_fk": { + "name": "onboarding_items_employee_id_employees_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "onboarding_items_step_id_onboarding_steps_id_fk": { + "name": "onboarding_items_step_id_onboarding_steps_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "onboarding_steps", + "columnsFrom": [ + "step_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "onboarding_items_done_by_users_id_fk": { + "name": "onboarding_items_done_by_users_id_fk", + "tableFrom": "onboarding_items", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "onboarding_items_how_ck": { + "name": "onboarding_items_how_ck", + "value": "\"onboarding_items\".\"done_how\" IS NULL OR \"onboarding_items\".\"done_how\" IN ('manuel', 'auto')" + } + }, + "isRLSEnabled": false + }, + "public.onboarding_steps": { + "name": "onboarding_steps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "day_offset": { + "name": "day_offset", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "auto_check": { + "name": "auto_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "onboarding_steps_org_idx": { + "name": "onboarding_steps_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "onboarding_steps_organization_id_organizations_id_fk": { + "name": "onboarding_steps_organization_id_organizations_id_fk", + "tableFrom": "onboarding_steps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "onboarding_steps_offset_ck": { + "name": "onboarding_steps_offset_ck", + "value": "\"onboarding_steps\".\"day_offset\" BETWEEN -60 AND 365" + } + }, + "isRLSEnabled": false + }, + "public.organizations": { + "name": "organizations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_demo": { + "name": "is_demo", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "stock_valuation": { + "name": "stock_valuation", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'dernier_prix'" + }, + "require_mfa": { + "name": "require_mfa", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_via": { + "name": "created_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "onboarding_dismissed_at": { + "name": "onboarding_dismissed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "onboarding_skipped": { + "name": "onboarding_skipped", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "is_test": { + "name": "is_test", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "suspended_at": { + "name": "suspended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organizations_slug_unique": { + "name": "organizations_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": { + "organizations_stock_valuation_ck": { + "name": "organizations_stock_valuation_ck", + "value": "\"organizations\".\"stock_valuation\" IN ('dernier_prix', 'cump', 'fifo')" + }, + "organizations_demo_or_test_ck": { + "name": "organizations_demo_or_test_ck", + "value": "NOT (\"organizations\".\"is_demo\" AND \"organizations\".\"is_test\")" + } + }, + "isRLSEnabled": false + }, + "public.partner_booking_imports": { + "name": "partner_booking_imports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "partner": { + "name": "partner", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created": { + "name": "created", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated": { + "name": "updated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cancelled": { + "name": "cancelled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "unchanged": { + "name": "unchanged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skipped": { + "name": "skipped", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "notes": { + "name": "notes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "partner_booking_imports_est_idx": { + "name": "partner_booking_imports_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "partner_booking_imports_organization_id_organizations_id_fk": { + "name": "partner_booking_imports_organization_id_organizations_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "partner_booking_imports_establishment_id_establishments_id_fk": { + "name": "partner_booking_imports_establishment_id_establishments_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "partner_booking_imports_created_by_users_id_fk": { + "name": "partner_booking_imports_created_by_users_id_fk", + "tableFrom": "partner_booking_imports", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "partner_booking_imports_partner_ck": { + "name": "partner_booking_imports_partner_ck", + "value": "\"partner_booking_imports\".\"partner\" IN ('thefork', 'opentable', 'google')" + }, + "partner_booking_imports_origin_ck": { + "name": "partner_booking_imports_origin_ck", + "value": "\"partner_booking_imports\".\"origin\" IN ('api', 'fichier', 'demo')" + } + }, + "isRLSEnabled": false + }, + "public.payroll_bonuses": { + "name": "payroll_bonuses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount_gross": { + "name": "amount_gross", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payroll_bonuses_est_date_idx": { + "name": "payroll_bonuses_est_date_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payroll_bonuses_org_idx": { + "name": "payroll_bonuses_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payroll_bonuses_organization_id_organizations_id_fk": { + "name": "payroll_bonuses_organization_id_organizations_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_establishment_id_establishments_id_fk": { + "name": "payroll_bonuses_establishment_id_establishments_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_employee_id_employees_id_fk": { + "name": "payroll_bonuses_employee_id_employees_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_bonuses_created_by_users_id_fk": { + "name": "payroll_bonuses_created_by_users_id_fk", + "tableFrom": "payroll_bonuses", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "payroll_bonuses_amount_ck": { + "name": "payroll_bonuses_amount_ck", + "value": "\"payroll_bonuses\".\"amount_gross\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.payroll_parameters": { + "name": "payroll_parameters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "effective_from": { + "name": "effective_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "employer_charge_pct": { + "name": "employer_charge_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "labor_alert_pct": { + "name": "labor_alert_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "source_note": { + "name": "source_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "min_productivity_ht": { + "name": "min_productivity_ht", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "meal_value": { + "name": "meal_value", + "type": "numeric(8, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "payroll_parameters_est_from_uq": { + "name": "payroll_parameters_est_from_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "payroll_parameters_org_idx": { + "name": "payroll_parameters_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "payroll_parameters_organization_id_organizations_id_fk": { + "name": "payroll_parameters_organization_id_organizations_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_parameters_establishment_id_establishments_id_fk": { + "name": "payroll_parameters_establishment_id_establishments_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "payroll_parameters_created_by_users_id_fk": { + "name": "payroll_parameters_created_by_users_id_fk", + "tableFrom": "payroll_parameters", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "payroll_parameters_pct_ck": { + "name": "payroll_parameters_pct_ck", + "value": "(\"payroll_parameters\".\"employer_charge_pct\" IS NULL OR \"payroll_parameters\".\"employer_charge_pct\" BETWEEN 0 AND 100) AND (\"payroll_parameters\".\"labor_alert_pct\" IS NULL OR \"payroll_parameters\".\"labor_alert_pct\" BETWEEN 0 AND 100)" + }, + "payroll_parameters_prod_ck": { + "name": "payroll_parameters_prod_ck", + "value": "\"payroll_parameters\".\"min_productivity_ht\" IS NULL OR \"payroll_parameters\".\"min_productivity_ht\" > 0" + }, + "payroll_parameters_meal_ck": { + "name": "payroll_parameters_meal_ck", + "value": "\"payroll_parameters\".\"meal_value\" IS NULL OR \"payroll_parameters\".\"meal_value\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.pennylane_category_mappings": { + "name": "pennylane_category_mappings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category_key": { + "name": "category_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_category_mappings_uq": { + "name": "pennylane_category_mappings_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "category_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_category_mappings_organization_id_organizations_id_fk": { + "name": "pennylane_category_mappings_organization_id_organizations_id_fk", + "tableFrom": "pennylane_category_mappings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_category_mappings_updated_by_users_id_fk": { + "name": "pennylane_category_mappings_updated_by_users_id_fk", + "tableFrom": "pennylane_category_mappings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.pennylane_item_prices": { + "name": "pennylane_item_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "record_id": { + "name": "record_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "line_index": { + "name": "line_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_item_prices_line_uq": { + "name": "pennylane_item_prices_line_uq", + "columns": [ + { + "expression": "record_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "line_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pennylane_item_prices_item_idx": { + "name": "pennylane_item_prices_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_item_prices_organization_id_organizations_id_fk": { + "name": "pennylane_item_prices_organization_id_organizations_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_establishment_id_establishments_id_fk": { + "name": "pennylane_item_prices_establishment_id_establishments_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_record_id_pennylane_records_id_fk": { + "name": "pennylane_item_prices_record_id_pennylane_records_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "pennylane_records", + "columnsFrom": [ + "record_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_item_prices_item_id_purchase_items_id_fk": { + "name": "pennylane_item_prices_item_id_purchase_items_id_fk", + "tableFrom": "pennylane_item_prices", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pennylane_item_prices_method_ck": { + "name": "pennylane_item_prices_method_ck", + "value": "\"pennylane_item_prices\".\"method\" IN ('confirme', 'reference', 'libelle')" + }, + "pennylane_item_prices_values_ck": { + "name": "pennylane_item_prices_values_ck", + "value": "\"pennylane_item_prices\".\"quantity\" > 0 AND \"pennylane_item_prices\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.pennylane_records": { + "name": "pennylane_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "third_party": { + "name": "third_party", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "remaining": { + "name": "remaining", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "payment_status": { + "name": "payment_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unknown'" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tax": { + "name": "tax", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "bank_account_ref": { + "name": "bank_account_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "raw": { + "name": "raw", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "synced_at": { + "name": "synced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pennylane_records_uq": { + "name": "pennylane_records_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pennylane_records_date_idx": { + "name": "pennylane_records_date_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pennylane_records_organization_id_organizations_id_fk": { + "name": "pennylane_records_organization_id_organizations_id_fk", + "tableFrom": "pennylane_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pennylane_records_establishment_id_establishments_id_fk": { + "name": "pennylane_records_establishment_id_establishments_id_fk", + "tableFrom": "pennylane_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pennylane_records_kind_ck": { + "name": "pennylane_records_kind_ck", + "value": "\"pennylane_records\".\"kind\" IN ('supplier_invoice', 'customer_invoice', 'transaction', 'bank_account')" + } + }, + "isRLSEnabled": false + }, + "public.pest_control_contracts": { + "name": "pest_control_contracts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "provider_name": { + "name": "provider_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "certibiocide_number": { + "name": "certibiocide_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact_phone": { + "name": "contact_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact_email": { + "name": "contact_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "starts_on": { + "name": "starts_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "ends_on": { + "name": "ends_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "visits_per_year": { + "name": "visits_per_year", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "trap_plan": { + "name": "trap_plan", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "trap_plan_mime": { + "name": "trap_plan_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "trap_plan_size": { + "name": "trap_plan_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pest_control_contracts_est_idx": { + "name": "pest_control_contracts_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pest_control_contracts_organization_id_organizations_id_fk": { + "name": "pest_control_contracts_organization_id_organizations_id_fk", + "tableFrom": "pest_control_contracts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pest_control_contracts_establishment_id_establishments_id_fk": { + "name": "pest_control_contracts_establishment_id_establishments_id_fk", + "tableFrom": "pest_control_contracts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pest_control_contracts_created_by_users_id_fk": { + "name": "pest_control_contracts_created_by_users_id_fk", + "tableFrom": "pest_control_contracts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pest_control_contracts_visits_ck": { + "name": "pest_control_contracts_visits_ck", + "value": "\"pest_control_contracts\".\"visits_per_year\" IS NULL OR (\"pest_control_contracts\".\"visits_per_year\" BETWEEN 1 AND 52)" + }, + "pest_control_contracts_plan_ck": { + "name": "pest_control_contracts_plan_ck", + "value": "\"pest_control_contracts\".\"trap_plan_size\" IS NULL OR \"pest_control_contracts\".\"trap_plan_size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.pest_control_visits": { + "name": "pest_control_visits", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "contract_id": { + "name": "contract_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "visit_on": { + "name": "visit_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'contrat'" + }, + "technician_name": { + "name": "technician_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "activity": { + "name": "activity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pests": { + "name": "pests", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "findings": { + "name": "findings", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actions": { + "name": "actions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recommendations": { + "name": "recommendations", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "products": { + "name": "products", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sign_token_hash": { + "name": "sign_token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sign_token_expires_at": { + "name": "sign_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "signed_at": { + "name": "signed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "signer_name": { + "name": "signer_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signature": { + "name": "signature", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "corrective_action_id": { + "name": "corrective_action_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pest_control_visits_est_idx": { + "name": "pest_control_visits_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "visit_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pest_control_visits_token_uq": { + "name": "pest_control_visits_token_uq", + "columns": [ + { + "expression": "sign_token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"pest_control_visits\".\"sign_token_hash\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pest_control_visits_organization_id_organizations_id_fk": { + "name": "pest_control_visits_organization_id_organizations_id_fk", + "tableFrom": "pest_control_visits", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pest_control_visits_establishment_id_establishments_id_fk": { + "name": "pest_control_visits_establishment_id_establishments_id_fk", + "tableFrom": "pest_control_visits", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pest_control_visits_contract_id_pest_control_contracts_id_fk": { + "name": "pest_control_visits_contract_id_pest_control_contracts_id_fk", + "tableFrom": "pest_control_visits", + "tableTo": "pest_control_contracts", + "columnsFrom": [ + "contract_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "pest_control_visits_corrective_action_id_haccp_corrective_actions_id_fk": { + "name": "pest_control_visits_corrective_action_id_haccp_corrective_actions_id_fk", + "tableFrom": "pest_control_visits", + "tableTo": "haccp_corrective_actions", + "columnsFrom": [ + "corrective_action_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "pest_control_visits_recorded_by_users_id_fk": { + "name": "pest_control_visits_recorded_by_users_id_fk", + "tableFrom": "pest_control_visits", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "pest_control_visits_cancelled_by_users_id_fk": { + "name": "pest_control_visits_cancelled_by_users_id_fk", + "tableFrom": "pest_control_visits", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "pest_control_visits_kind_ck": { + "name": "pest_control_visits_kind_ck", + "value": "\"pest_control_visits\".\"kind\" IN ('contrat', 'curatif')" + }, + "pest_control_visits_activity_ck": { + "name": "pest_control_visits_activity_ck", + "value": "\"pest_control_visits\".\"activity\" IS NULL OR \"pest_control_visits\".\"activity\" IN ('aucune', 'faible', 'forte')" + }, + "pest_control_visits_signed_ck": { + "name": "pest_control_visits_signed_ck", + "value": "(\"pest_control_visits\".\"signed_at\" IS NULL) = (\"pest_control_visits\".\"signature\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.planning_absences": { + "name": "planning_absences", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "part": { + "name": "part", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'journee'" + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_absences_uq": { + "name": "planning_absences_uq", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "part", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_absences_organization_id_organizations_id_fk": { + "name": "planning_absences_organization_id_organizations_id_fk", + "tableFrom": "planning_absences", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_absences_employee_id_employees_id_fk": { + "name": "planning_absences_employee_id_employees_id_fk", + "tableFrom": "planning_absences", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_absences_created_by_users_id_fk": { + "name": "planning_absences_created_by_users_id_fk", + "tableFrom": "planning_absences", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_absences_part_ck": { + "name": "planning_absences_part_ck", + "value": "\"planning_absences\".\"part\" IN ('journee', 'matin', 'apres_midi')" + } + }, + "isRLSEnabled": false + }, + "public.planning_day_budgets": { + "name": "planning_day_budgets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "sales_ht": { + "name": "sales_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_day_budgets_uq": { + "name": "planning_day_budgets_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "planning_day_budgets_org_idx": { + "name": "planning_day_budgets_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_day_budgets_organization_id_organizations_id_fk": { + "name": "planning_day_budgets_organization_id_organizations_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_budgets_establishment_id_establishments_id_fk": { + "name": "planning_day_budgets_establishment_id_establishments_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_budgets_updated_by_users_id_fk": { + "name": "planning_day_budgets_updated_by_users_id_fk", + "tableFrom": "planning_day_budgets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_day_budgets_ck": { + "name": "planning_day_budgets_ck", + "value": "\"planning_day_budgets\".\"sales_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.planning_day_notes": { + "name": "planning_day_notes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_day_notes_uq": { + "name": "planning_day_notes_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_day_notes_organization_id_organizations_id_fk": { + "name": "planning_day_notes_organization_id_organizations_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_notes_establishment_id_establishments_id_fk": { + "name": "planning_day_notes_establishment_id_establishments_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_day_notes_updated_by_users_id_fk": { + "name": "planning_day_notes_updated_by_users_id_fk", + "tableFrom": "planning_day_notes", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "planning_day_notes_len_ck": { + "name": "planning_day_notes_len_ck", + "value": "char_length(\"planning_day_notes\".\"text\") BETWEEN 1 AND 500" + } + }, + "isRLSEnabled": false + }, + "public.planning_weeks": { + "name": "planning_weeks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "week_start": { + "name": "week_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_by": { + "name": "published_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "changed_at": { + "name": "changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sales_forecast_ht": { + "name": "sales_forecast_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "hours_budget": { + "name": "hours_budget", + "type": "numeric(8, 2)", + "primaryKey": false, + "notNull": false + }, + "published_teams": { + "name": "published_teams", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "published_pdf": { + "name": "published_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "planning_weeks_uq": { + "name": "planning_weeks_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "week_start", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "planning_weeks_organization_id_organizations_id_fk": { + "name": "planning_weeks_organization_id_organizations_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_weeks_establishment_id_establishments_id_fk": { + "name": "planning_weeks_establishment_id_establishments_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "planning_weeks_published_by_users_id_fk": { + "name": "planning_weeks_published_by_users_id_fk", + "tableFrom": "planning_weeks", + "tableTo": "users", + "columnsFrom": [ + "published_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_settings": { + "name": "platform_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "default": 1 + }, + "signup_open": { + "name": "signup_open", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "mail_organization_id": { + "name": "mail_organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "vapid_public_key": { + "name": "vapid_public_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vapid_private_enc": { + "name": "vapid_private_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "platform_settings_mail_organization_id_organizations_id_fk": { + "name": "platform_settings_mail_organization_id_organizations_id_fk", + "tableFrom": "platform_settings", + "tableTo": "organizations", + "columnsFrom": [ + "mail_organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "platform_settings_updated_by_users_id_fk": { + "name": "platform_settings_updated_by_users_id_fk", + "tableFrom": "platform_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "platform_settings_single_ck": { + "name": "platform_settings_single_ck", + "value": "\"platform_settings\".\"id\" = 1" + } + }, + "isRLSEnabled": false + }, + "public.posting_records": { + "name": "posting_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "values": { + "name": "values", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installed_on": { + "name": "installed_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_size": { + "name": "photo_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "validated_by_name": { + "name": "validated_by_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "posting_records_uq": { + "name": "posting_records_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "posting_records_org_idx": { + "name": "posting_records_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "posting_records_organization_id_organizations_id_fk": { + "name": "posting_records_organization_id_organizations_id_fk", + "tableFrom": "posting_records", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "posting_records_establishment_id_establishments_id_fk": { + "name": "posting_records_establishment_id_establishments_id_fk", + "tableFrom": "posting_records", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "posting_records_validated_by_users_id_fk": { + "name": "posting_records_validated_by_users_id_fk", + "tableFrom": "posting_records", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "posting_records_updated_by_users_id_fk": { + "name": "posting_records_updated_by_users_id_fk", + "tableFrom": "posting_records", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "posting_records_photo_ck": { + "name": "posting_records_photo_ck", + "value": "(\"posting_records\".\"photo\" IS NULL) = (\"posting_records\".\"photo_mime\" IS NULL) AND (\"posting_records\".\"photo\" IS NULL OR \"posting_records\".\"photo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + }, + "posting_records_validation_ck": { + "name": "posting_records_validation_ck", + "value": "(\"posting_records\".\"validated_at\" IS NULL) = (\"posting_records\".\"validated_by_name\" IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.price_request_lines": { + "name": "price_request_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "price_request_lines_item_uq": { + "name": "price_request_lines_item_uq", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_lines_organization_id_organizations_id_fk": { + "name": "price_request_lines_organization_id_organizations_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_lines_request_id_price_requests_id_fk": { + "name": "price_request_lines_request_id_price_requests_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "price_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_lines_item_id_purchase_items_id_fk": { + "name": "price_request_lines_item_id_purchase_items_id_fk", + "tableFrom": "price_request_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_lines_amount_ck": { + "name": "price_request_lines_amount_ck", + "value": "\"price_request_lines\".\"amount\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.price_request_offers": { + "name": "price_request_offers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_supplier_id": { + "name": "request_supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "line_id": { + "name": "line_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "awarded": { + "name": "awarded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_request_offers_uq": { + "name": "price_request_offers_uq", + "columns": [ + { + "expression": "request_supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "line_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_offers_organization_id_organizations_id_fk": { + "name": "price_request_offers_organization_id_organizations_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_offers_request_supplier_id_price_request_suppliers_id_fk": { + "name": "price_request_offers_request_supplier_id_price_request_suppliers_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "price_request_suppliers", + "columnsFrom": [ + "request_supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_offers_line_id_price_request_lines_id_fk": { + "name": "price_request_offers_line_id_price_request_lines_id_fk", + "tableFrom": "price_request_offers", + "tableTo": "price_request_lines", + "columnsFrom": [ + "line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_offers_price_ck": { + "name": "price_request_offers_price_ck", + "value": "\"price_request_offers\".\"unit_price_ht\" IS NULL OR \"price_request_offers\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.price_request_suppliers": { + "name": "price_request_suppliers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emailed": { + "name": "emailed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "answered_at": { + "name": "answered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "answered_via": { + "name": "answered_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answered_name": { + "name": "answered_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "answer_note": { + "name": "answer_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_request_suppliers_uq": { + "name": "price_request_suppliers_uq", + "columns": [ + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "price_request_suppliers_token_uq": { + "name": "price_request_suppliers_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_request_suppliers_organization_id_organizations_id_fk": { + "name": "price_request_suppliers_organization_id_organizations_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_suppliers_request_id_price_requests_id_fk": { + "name": "price_request_suppliers_request_id_price_requests_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "price_requests", + "columnsFrom": [ + "request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_request_suppliers_supplier_id_suppliers_id_fk": { + "name": "price_request_suppliers_supplier_id_suppliers_id_fk", + "tableFrom": "price_request_suppliers", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_request_suppliers_via_ck": { + "name": "price_request_suppliers_via_ck", + "value": "\"price_request_suppliers\".\"answered_via\" IS NULL OR \"price_request_suppliers\".\"answered_via\" IN ('en_ligne', 'saisie')" + } + }, + "isRLSEnabled": false + }, + "public.price_requests": { + "name": "price_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_by": { + "name": "reply_by", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "needed_by": { + "name": "needed_by", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "awarded_at": { + "name": "awarded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "price_requests_number_uq": { + "name": "price_requests_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "price_requests_est_idx": { + "name": "price_requests_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "price_requests_organization_id_organizations_id_fk": { + "name": "price_requests_organization_id_organizations_id_fk", + "tableFrom": "price_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "price_requests_establishment_id_establishments_id_fk": { + "name": "price_requests_establishment_id_establishments_id_fk", + "tableFrom": "price_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "price_requests_created_by_users_id_fk": { + "name": "price_requests_created_by_users_id_fk", + "tableFrom": "price_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "price_requests_status_ck": { + "name": "price_requests_status_ck", + "value": "\"price_requests\".\"status\" IN ('brouillon', 'envoyee', 'attribuee', 'annulee')" + } + }, + "isRLSEnabled": false + }, + "public.privacy_requests": { + "name": "privacy_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_kind": { + "name": "subject_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "subject_label": { + "name": "subject_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_type": { + "name": "request_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "target_on": { + "name": "target_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'recue'" + }, + "responded_on": { + "name": "responded_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "handled_by": { + "name": "handled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "privacy_requests_org_idx": { + "name": "privacy_requests_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "privacy_requests_organization_id_organizations_id_fk": { + "name": "privacy_requests_organization_id_organizations_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "privacy_requests_establishment_id_establishments_id_fk": { + "name": "privacy_requests_establishment_id_establishments_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "privacy_requests_employee_id_employees_id_fk": { + "name": "privacy_requests_employee_id_employees_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_customer_id_customers_id_fk": { + "name": "privacy_requests_customer_id_customers_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_handled_by_users_id_fk": { + "name": "privacy_requests_handled_by_users_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "users", + "columnsFrom": [ + "handled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "privacy_requests_created_by_users_id_fk": { + "name": "privacy_requests_created_by_users_id_fk", + "tableFrom": "privacy_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "privacy_requests_kind_ck": { + "name": "privacy_requests_kind_ck", + "value": "\"privacy_requests\".\"subject_kind\" IN ('salarie', 'client', 'autre')" + }, + "privacy_requests_type_ck": { + "name": "privacy_requests_type_ck", + "value": "\"privacy_requests\".\"request_type\" IN ('acces', 'rectification', 'effacement', 'opposition')" + }, + "privacy_requests_channel_ck": { + "name": "privacy_requests_channel_ck", + "value": "\"privacy_requests\".\"channel\" IN ('email', 'courrier', 'oral', 'sur_place', 'autre')" + }, + "privacy_requests_status_ck": { + "name": "privacy_requests_status_ck", + "value": "\"privacy_requests\".\"status\" IN ('recue', 'en_cours', 'traitee', 'refusee', 'sans_suite')" + }, + "privacy_requests_done_ck": { + "name": "privacy_requests_done_ck", + "value": "\"privacy_requests\".\"status\" NOT IN ('traitee', 'refusee') OR \"privacy_requests\".\"responded_on\" IS NOT NULL" + }, + "privacy_requests_refused_ck": { + "name": "privacy_requests_refused_ck", + "value": "\"privacy_requests\".\"status\" <> 'refusee' OR \"privacy_requests\".\"outcome\" IS NOT NULL" + }, + "privacy_requests_dates_ck": { + "name": "privacy_requests_dates_ck", + "value": "\"privacy_requests\".\"responded_on\" IS NULL OR \"privacy_requests\".\"responded_on\" >= \"privacy_requests\".\"received_on\"" + } + }, + "isRLSEnabled": false + }, + "public.product_recalls": { + "name": "product_recalls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source_id": { + "name": "source_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "fiche_number": { + "name": "fiche_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subcategory": { + "name": "subcategory", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "references": { + "name": "references", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gtins": { + "name": "gtins", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "lots": { + "name": "lots", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "risks": { + "name": "risks", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "consumer_actions": { + "name": "consumer_actions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sale_area": { + "name": "sale_area", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "distributors": { + "name": "distributors", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fiche_url": { + "name": "fiche_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ends_on": { + "name": "ends_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "product_recalls_source_uq": { + "name": "product_recalls_source_uq", + "columns": [ + { + "expression": "source_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "product_recalls_published_idx": { + "name": "product_recalls_published_idx", + "columns": [ + { + "expression": "published_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.product_temperatures": { + "name": "product_temperatures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_at": { + "name": "start_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "start_temp": { + "name": "start_temp", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": true + }, + "end_at": { + "name": "end_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "end_temp": { + "name": "end_temp", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "completed_by": { + "name": "completed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "product_temperatures_est_idx": { + "name": "product_temperatures_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "start_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "product_temperatures_organization_id_organizations_id_fk": { + "name": "product_temperatures_organization_id_organizations_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_temperatures_establishment_id_establishments_id_fk": { + "name": "product_temperatures_establishment_id_establishments_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "product_temperatures_recorded_by_users_id_fk": { + "name": "product_temperatures_recorded_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_temperatures_completed_by_users_id_fk": { + "name": "product_temperatures_completed_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "completed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_temperatures_cancelled_by_users_id_fk": { + "name": "product_temperatures_cancelled_by_users_id_fk", + "tableFrom": "product_temperatures", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "product_temperatures_kind_ck": { + "name": "product_temperatures_kind_ck", + "value": "\"product_temperatures\".\"kind\" IN ('refroidissement', 'remise_en_temperature', 'coeur_chaud', 'coeur_froid')" + }, + "product_temperatures_status_ck": { + "name": "product_temperatures_status_ck", + "value": "\"product_temperatures\".\"status\" IN ('en_cours', 'termine')" + }, + "product_temperatures_action_ck": { + "name": "product_temperatures_action_ck", + "value": "\"product_temperatures\".\"conform\" IS NOT FALSE OR \"product_temperatures\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.purchase_control_settings": { + "name": "purchase_control_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rise_threshold_pct": { + "name": "rise_threshold_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "rise_window_days": { + "name": "rise_window_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "reception_tolerance_pct": { + "name": "reception_tolerance_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_control_settings_org_uq": { + "name": "purchase_control_settings_org_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_control_settings\".\"establishment_id\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_control_settings_est_uq": { + "name": "purchase_control_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_control_settings\".\"establishment_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_control_settings_organization_id_organizations_id_fk": { + "name": "purchase_control_settings_organization_id_organizations_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_control_settings_establishment_id_establishments_id_fk": { + "name": "purchase_control_settings_establishment_id_establishments_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_control_settings_updated_by_users_id_fk": { + "name": "purchase_control_settings_updated_by_users_id_fk", + "tableFrom": "purchase_control_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_control_settings_ck": { + "name": "purchase_control_settings_ck", + "value": "(\"purchase_control_settings\".\"rise_threshold_pct\" IS NULL OR (\"purchase_control_settings\".\"rise_threshold_pct\" > 0 AND \"purchase_control_settings\".\"rise_threshold_pct\" <= 100)) AND (\"purchase_control_settings\".\"rise_window_days\" IS NULL OR \"purchase_control_settings\".\"rise_window_days\" BETWEEN 7 AND 365) AND (\"purchase_control_settings\".\"reception_tolerance_pct\" IS NULL OR (\"purchase_control_settings\".\"reception_tolerance_pct\" >= 0 AND \"purchase_control_settings\".\"reception_tolerance_pct\" <= 50))" + } + }, + "isRLSEnabled": false + }, + "public.purchase_invoice_lines": { + "name": "purchase_invoice_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_id": { + "name": "invoice_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "line_ht": { + "name": "line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_lines_invoice_idx": { + "name": "purchase_lines_invoice_idx", + "columns": [ + { + "expression": "invoice_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_lines_item_idx": { + "name": "purchase_lines_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_invoice_lines_organization_id_organizations_id_fk": { + "name": "purchase_invoice_lines_organization_id_organizations_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoice_lines_invoice_id_purchase_invoices_id_fk": { + "name": "purchase_invoice_lines_invoice_id_purchase_invoices_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "purchase_invoices", + "columnsFrom": [ + "invoice_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoice_lines_item_id_purchase_items_id_fk": { + "name": "purchase_invoice_lines_item_id_purchase_items_id_fk", + "tableFrom": "purchase_invoice_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_lines_qty_ck": { + "name": "purchase_lines_qty_ck", + "value": "\"purchase_invoice_lines\".\"quantity\" > 0" + }, + "purchase_lines_price_ck": { + "name": "purchase_lines_price_ck", + "value": "\"purchase_invoice_lines\".\"unit_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.purchase_invoices": { + "name": "purchase_invoices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'invoice'" + }, + "invoice_date": { + "name": "invoice_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_vat": { + "name": "total_vat", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "printed_ttc": { + "name": "printed_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "credit_request_id": { + "name": "credit_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paid_at": { + "name": "paid_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_invoices_period_idx": { + "name": "purchase_invoices_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "invoice_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_number_uq": { + "name": "purchase_invoices_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"invoice_number\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_credit_request_uq": { + "name": "purchase_invoices_credit_request_uq", + "columns": [ + { + "expression": "credit_request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL AND \"purchase_invoices\".\"credit_request_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_invoices_order_uq": { + "name": "purchase_invoices_order_uq", + "columns": [ + { + "expression": "purchase_order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_invoices\".\"cancelled_at\" IS NULL AND \"purchase_invoices\".\"kind\" = 'invoice' AND \"purchase_invoices\".\"purchase_order_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_invoices_organization_id_organizations_id_fk": { + "name": "purchase_invoices_organization_id_organizations_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_invoices_establishment_id_establishments_id_fk": { + "name": "purchase_invoices_establishment_id_establishments_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_supplier_id_suppliers_id_fk": { + "name": "purchase_invoices_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_purchase_order_id_purchase_orders_id_fk": { + "name": "purchase_invoices_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_credit_request_id_credit_requests_id_fk": { + "name": "purchase_invoices_credit_request_id_credit_requests_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "credit_requests", + "columnsFrom": [ + "credit_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_invoices_created_by_users_id_fk": { + "name": "purchase_invoices_created_by_users_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_invoices_cancelled_by_users_id_fk": { + "name": "purchase_invoices_cancelled_by_users_id_fk", + "tableFrom": "purchase_invoices", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_invoices_kind_ck": { + "name": "purchase_invoices_kind_ck", + "value": "\"purchase_invoices\".\"kind\" IN ('invoice', 'credit_note')" + }, + "purchase_invoices_ttc_ck": { + "name": "purchase_invoices_ttc_ck", + "value": "\"purchase_invoices\".\"total_ttc\" = \"purchase_invoices\".\"total_ht\" + \"purchase_invoices\".\"total_vat\"" + }, + "purchase_invoices_due_ck": { + "name": "purchase_invoices_due_ck", + "value": "\"purchase_invoices\".\"due_date\" IS NULL OR \"purchase_invoices\".\"due_date\" >= \"purchase_invoices\".\"invoice_date\"" + } + }, + "isRLSEnabled": false + }, + "public.purchase_items": { + "name": "purchase_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "storage_zone": { + "name": "storage_zone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "default_supplier_id": { + "name": "default_supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_ref": { + "name": "supplier_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "barcode": { + "name": "barcode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "catalog_price_ht": { + "name": "catalog_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "catalog_price_date": { + "name": "catalog_price_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "opened_shelf_life_days": { + "name": "opened_shelf_life_days", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_items_org_idx": { + "name": "purchase_items_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_items_org_name_unit_uq": { + "name": "purchase_items_org_name_unit_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "unit", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_items_org_barcode_uq": { + "name": "purchase_items_org_barcode_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "barcode", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"purchase_items\".\"barcode\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_items_organization_id_organizations_id_fk": { + "name": "purchase_items_organization_id_organizations_id_fk", + "tableFrom": "purchase_items", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_items_default_supplier_id_suppliers_id_fk": { + "name": "purchase_items_default_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_items", + "tableTo": "suppliers", + "columnsFrom": [ + "default_supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_items_opened_life_ck": { + "name": "purchase_items_opened_life_ck", + "value": "\"purchase_items\".\"opened_shelf_life_days\" IS NULL OR \"purchase_items\".\"opened_shelf_life_days\" BETWEEN 1 AND 60" + }, + "purchase_items_pack_ck": { + "name": "purchase_items_pack_ck", + "value": "\"purchase_items\".\"pack_size\" IS NULL OR \"purchase_items\".\"pack_size\" > 0" + }, + "purchase_items_catalog_ck": { + "name": "purchase_items_catalog_ck", + "value": "\"purchase_items\".\"catalog_price_ht\" IS NULL OR \"purchase_items\".\"catalog_price_ht\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.purchase_order_groups": { + "name": "purchase_order_groups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expected_date": { + "name": "expected_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_order_groups_number_uq": { + "name": "purchase_order_groups_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_order_groups_organization_id_organizations_id_fk": { + "name": "purchase_order_groups_organization_id_organizations_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_groups_supplier_id_suppliers_id_fk": { + "name": "purchase_order_groups_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_order_groups_created_by_users_id_fk": { + "name": "purchase_order_groups_created_by_users_id_fk", + "tableFrom": "purchase_order_groups", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_order_groups_status_ck": { + "name": "purchase_order_groups_status_ck", + "value": "\"purchase_order_groups\".\"status\" IN ('draft', 'sent', 'cancelled')" + } + }, + "isRLSEnabled": false + }, + "public.purchase_order_lines": { + "name": "purchase_order_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "packs": { + "name": "packs", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_size": { + "name": "pack_size", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "pack_label": { + "name": "pack_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_price_ht": { + "name": "unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "line_ht": { + "name": "line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "received_quantity": { + "name": "received_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "received_unit_price_ht": { + "name": "received_unit_price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "received_line_ht": { + "name": "received_line_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "reception_note": { + "name": "reception_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_order_lines_order_idx": { + "name": "purchase_order_lines_order_idx", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_order_lines_item_uq": { + "name": "purchase_order_lines_item_uq", + "columns": [ + { + "expression": "order_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_order_lines_organization_id_organizations_id_fk": { + "name": "purchase_order_lines_organization_id_organizations_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_lines_order_id_purchase_orders_id_fk": { + "name": "purchase_order_lines_order_id_purchase_orders_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "purchase_orders", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_order_lines_item_id_purchase_items_id_fk": { + "name": "purchase_order_lines_item_id_purchase_items_id_fk", + "tableFrom": "purchase_order_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_order_lines_qty_ck": { + "name": "purchase_order_lines_qty_ck", + "value": "\"purchase_order_lines\".\"quantity\" > 0 AND \"purchase_order_lines\".\"unit_price_ht\" >= 0 AND (\"purchase_order_lines\".\"received_quantity\" IS NULL OR \"purchase_order_lines\".\"received_quantity\" >= 0)" + } + }, + "isRLSEnabled": false + }, + "public.purchase_orders": { + "name": "purchase_orders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "expected_date": { + "name": "expected_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines_ht": { + "name": "lines_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "delivery_fee_ht": { + "name": "delivery_fee_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "ordered_at": { + "name": "ordered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "received_date": { + "name": "received_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "received_time": { + "name": "received_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "delivery_note_number": { + "name": "delivery_note_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplier_gaps_ack_at": { + "name": "supplier_gaps_ack_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "supplier_gaps_ack_by": { + "name": "supplier_gaps_ack_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "received_ht": { + "name": "received_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "reception_comment": { + "name": "reception_comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "received_by": { + "name": "received_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_request_id": { + "name": "price_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "purchase_orders_group_idx": { + "name": "purchase_orders_group_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_orders_est_idx": { + "name": "purchase_orders_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "purchase_orders_number_uq": { + "name": "purchase_orders_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "purchase_orders_organization_id_organizations_id_fk": { + "name": "purchase_orders_organization_id_organizations_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "purchase_orders_establishment_id_establishments_id_fk": { + "name": "purchase_orders_establishment_id_establishments_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_supplier_id_suppliers_id_fk": { + "name": "purchase_orders_supplier_id_suppliers_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_supplier_gaps_ack_by_users_id_fk": { + "name": "purchase_orders_supplier_gaps_ack_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "supplier_gaps_ack_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_orders_received_by_users_id_fk": { + "name": "purchase_orders_received_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "received_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "purchase_orders_price_request_id_price_requests_id_fk": { + "name": "purchase_orders_price_request_id_price_requests_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "price_requests", + "columnsFrom": [ + "price_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_group_id_purchase_order_groups_id_fk": { + "name": "purchase_orders_group_id_purchase_order_groups_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "purchase_order_groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "purchase_orders_created_by_users_id_fk": { + "name": "purchase_orders_created_by_users_id_fk", + "tableFrom": "purchase_orders", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "purchase_orders_status_ck": { + "name": "purchase_orders_status_ck", + "value": "\"purchase_orders\".\"status\" IN ('draft', 'sent', 'confirmed', 'received', 'cancelled')" + }, + "purchase_orders_time_ck": { + "name": "purchase_orders_time_ck", + "value": "\"purchase_orders\".\"received_time\" IS NULL OR \"purchase_orders\".\"received_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + } + }, + "isRLSEnabled": false + }, + "public.push_subscriptions": { + "name": "push_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Appareil'" + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "push_subscriptions_endpoint_uq": { + "name": "push_subscriptions_endpoint_uq", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "push_subscriptions_user_idx": { + "name": "push_subscriptions_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "push_subscriptions_organization_id_organizations_id_fk": { + "name": "push_subscriptions_organization_id_organizations_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.quotes": { + "name": "quotes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_kind": { + "name": "event_kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "event_time": { + "name": "event_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "guests": { + "name": "guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "client_name": { + "name": "client_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_company": { + "name": "client_company", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_email": { + "name": "client_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_phone": { + "name": "client_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_address": { + "name": "client_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'brouillon'" + }, + "issued_on": { + "name": "issued_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_vat": { + "name": "total_vat", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "deposit_percent": { + "name": "deposit_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "deposit_amount": { + "name": "deposit_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "deposit_received_on": { + "name": "deposit_received_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "terms": { + "name": "terms", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "viewed_at": { + "name": "viewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_name": { + "name": "accepted_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_via": { + "name": "accepted_via", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_meta": { + "name": "accepted_meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "refused_reason": { + "name": "refused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lead_id": { + "name": "lead_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "quotes_number_uq": { + "name": "quotes_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "quotes_token_uq": { + "name": "quotes_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"quotes\".\"token_hash\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "quotes_org_idx": { + "name": "quotes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "quotes_organization_id_organizations_id_fk": { + "name": "quotes_organization_id_organizations_id_fk", + "tableFrom": "quotes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "quotes_establishment_id_establishments_id_fk": { + "name": "quotes_establishment_id_establishments_id_fk", + "tableFrom": "quotes", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "quotes_customer_id_customers_id_fk": { + "name": "quotes_customer_id_customers_id_fk", + "tableFrom": "quotes", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_reservation_id_reservations_id_fk": { + "name": "quotes_reservation_id_reservations_id_fk", + "tableFrom": "quotes", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_lead_id_leads_id_fk": { + "name": "quotes_lead_id_leads_id_fk", + "tableFrom": "quotes", + "tableTo": "leads", + "columnsFrom": [ + "lead_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "quotes_created_by_users_id_fk": { + "name": "quotes_created_by_users_id_fk", + "tableFrom": "quotes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "quotes_status_ck": { + "name": "quotes_status_ck", + "value": "\"quotes\".\"status\" IN ('brouillon', 'envoye', 'accepte', 'refuse', 'annule')" + }, + "quotes_valid_ck": { + "name": "quotes_valid_ck", + "value": "\"quotes\".\"valid_until\" >= \"quotes\".\"issued_on\"" + }, + "quotes_guests_ck": { + "name": "quotes_guests_ck", + "value": "\"quotes\".\"guests\" IS NULL OR \"quotes\".\"guests\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reception_control_lines": { + "name": "reception_control_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "control_id": { + "name": "control_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "stock_lot_id": { + "name": "stock_lot_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "packaging_ok": { + "name": "packaging_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "label_ok": { + "name": "label_ok", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "reception_control_lines_ctl_idx": { + "name": "reception_control_lines_ctl_idx", + "columns": [ + { + "expression": "control_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reception_control_lines_organization_id_organizations_id_fk": { + "name": "reception_control_lines_organization_id_organizations_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_control_lines_control_id_reception_controls_id_fk": { + "name": "reception_control_lines_control_id_reception_controls_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "reception_controls", + "columnsFrom": [ + "control_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_control_lines_item_id_purchase_items_id_fk": { + "name": "reception_control_lines_item_id_purchase_items_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reception_control_lines_stock_lot_id_stock_expiry_lots_id_fk": { + "name": "reception_control_lines_stock_lot_id_stock_expiry_lots_id_fk", + "tableFrom": "reception_control_lines", + "tableTo": "stock_expiry_lots", + "columnsFrom": [ + "stock_lot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reception_controls": { + "name": "reception_controls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purchase_order_id": { + "name": "purchase_order_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "delivery_note": { + "name": "delivery_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "truck_temperature": { + "name": "truck_temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "vehicle_clean": { + "name": "vehicle_clean", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "decision": { + "name": "decision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reception_controls_est_idx": { + "name": "reception_controls_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reception_controls_organization_id_organizations_id_fk": { + "name": "reception_controls_organization_id_organizations_id_fk", + "tableFrom": "reception_controls", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reception_controls_establishment_id_establishments_id_fk": { + "name": "reception_controls_establishment_id_establishments_id_fk", + "tableFrom": "reception_controls", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reception_controls_supplier_id_suppliers_id_fk": { + "name": "reception_controls_supplier_id_suppliers_id_fk", + "tableFrom": "reception_controls", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reception_controls_purchase_order_id_purchase_orders_id_fk": { + "name": "reception_controls_purchase_order_id_purchase_orders_id_fk", + "tableFrom": "reception_controls", + "tableTo": "purchase_orders", + "columnsFrom": [ + "purchase_order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reception_controls_recorded_by_users_id_fk": { + "name": "reception_controls_recorded_by_users_id_fk", + "tableFrom": "reception_controls", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reception_controls_cancelled_by_users_id_fk": { + "name": "reception_controls_cancelled_by_users_id_fk", + "tableFrom": "reception_controls", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reception_controls_decision_ck": { + "name": "reception_controls_decision_ck", + "value": "\"reception_controls\".\"decision\" IN ('accepte', 'accepte_reserve', 'refuse')" + }, + "reception_controls_action_ck": { + "name": "reception_controls_action_ck", + "value": "\"reception_controls\".\"conform\" OR \"reception_controls\".\"corrective_action\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.recipe_lines": { + "name": "recipe_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sub_recipe_id": { + "name": "sub_recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "waste_pct": { + "name": "waste_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_lines_recipe_idx": { + "name": "recipe_lines_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_lines_sub_idx": { + "name": "recipe_lines_sub_idx", + "columns": [ + { + "expression": "sub_recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_lines_organization_id_organizations_id_fk": { + "name": "recipe_lines_organization_id_organizations_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_lines_recipe_id_recipes_id_fk": { + "name": "recipe_lines_recipe_id_recipes_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_lines_item_id_purchase_items_id_fk": { + "name": "recipe_lines_item_id_purchase_items_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "recipe_lines_sub_recipe_id_recipes_id_fk": { + "name": "recipe_lines_sub_recipe_id_recipes_id_fk", + "tableFrom": "recipe_lines", + "tableTo": "recipes", + "columnsFrom": [ + "sub_recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipe_lines_waste_ck": { + "name": "recipe_lines_waste_ck", + "value": "\"recipe_lines\".\"waste_pct\" IS NULL OR (\"recipe_lines\".\"waste_pct\" >= 0 AND \"recipe_lines\".\"waste_pct\" < 100)" + }, + "recipe_lines_qty_ck": { + "name": "recipe_lines_qty_ck", + "value": "\"recipe_lines\".\"quantity\" > 0" + }, + "recipe_lines_source_ck": { + "name": "recipe_lines_source_ck", + "value": "(\"recipe_lines\".\"item_id\" IS NULL) <> (\"recipe_lines\".\"sub_recipe_id\" IS NULL)" + }, + "recipe_lines_self_ck": { + "name": "recipe_lines_self_ck", + "value": "\"recipe_lines\".\"sub_recipe_id\" IS NULL OR \"recipe_lines\".\"sub_recipe_id\" <> \"recipe_lines\".\"recipe_id\"" + } + }, + "isRLSEnabled": false + }, + "public.recipe_versions": { + "name": "recipe_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "effective_from": { + "name": "effective_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "yield_quantity": { + "name": "yield_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "yield_unit": { + "name": "yield_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_versions_no_uq": { + "name": "recipe_versions_no_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_from_uq": { + "name": "recipe_versions_from_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_origin_uq": { + "name": "recipe_versions_origin_uq", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"recipe_versions\".\"effective_from\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipe_versions_org_idx": { + "name": "recipe_versions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_versions_organization_id_organizations_id_fk": { + "name": "recipe_versions_organization_id_organizations_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_versions_recipe_id_recipes_id_fk": { + "name": "recipe_versions_recipe_id_recipes_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_versions_created_by_users_id_fk": { + "name": "recipe_versions_created_by_users_id_fk", + "tableFrom": "recipe_versions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipe_versions_ck": { + "name": "recipe_versions_ck", + "value": "\"recipe_versions\".\"version\" >= 1 AND \"recipe_versions\".\"portions\" > 0 AND ((\"recipe_versions\".\"version\" = 1) = (\"recipe_versions\".\"effective_from\" IS NULL))" + } + }, + "isRLSEnabled": false + }, + "public.recipes": { + "name": "recipes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "course": { + "name": "course", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'plat'" + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'1'" + }, + "selling_price_ttc": { + "name": "selling_price_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0.10'" + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "yield_quantity": { + "name": "yield_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "yield_unit": { + "name": "yield_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "target_margin_pct": { + "name": "target_margin_pct", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "allergen_traces": { + "name": "allergen_traces", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "portion_weight_g": { + "name": "portion_weight_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "quality_tolerance_pct": { + "name": "quality_tolerance_pct", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "plating_standard": { + "name": "plating_standard", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "shelf_life_days": { + "name": "shelf_life_days", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "storage_note": { + "name": "storage_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipes_org_idx": { + "name": "recipes_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipes_org_name_uq": { + "name": "recipes_org_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipes_organization_id_organizations_id_fk": { + "name": "recipes_organization_id_organizations_id_fk", + "tableFrom": "recipes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipes_created_by_users_id_fk": { + "name": "recipes_created_by_users_id_fk", + "tableFrom": "recipes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "recipes_shelf_life_ck": { + "name": "recipes_shelf_life_ck", + "value": "\"recipes\".\"shelf_life_days\" IS NULL OR \"recipes\".\"shelf_life_days\" BETWEEN 1 AND 90" + }, + "recipes_portions_ck": { + "name": "recipes_portions_ck", + "value": "\"recipes\".\"portions\" > 0" + }, + "recipes_yield_ck": { + "name": "recipes_yield_ck", + "value": "(\"recipes\".\"yield_quantity\" IS NULL AND \"recipes\".\"yield_unit\" IS NULL) OR (\"recipes\".\"yield_quantity\" > 0 AND \"recipes\".\"yield_unit\" IS NOT NULL)" + }, + "recipes_margin_ck": { + "name": "recipes_margin_ck", + "value": "\"recipes\".\"target_margin_pct\" IS NULL OR (\"recipes\".\"target_margin_pct\" >= 0 AND \"recipes\".\"target_margin_pct\" < 100)" + }, + "recipes_quality_ck": { + "name": "recipes_quality_ck", + "value": "(\"recipes\".\"portion_weight_g\" IS NULL OR \"recipes\".\"portion_weight_g\" BETWEEN 1 AND 20000) AND (\"recipes\".\"quality_tolerance_pct\" IS NULL OR \"recipes\".\"quality_tolerance_pct\" BETWEEN 1 AND 50)" + } + }, + "isRLSEnabled": false + }, + "public.recovery_codes": { + "name": "recovery_codes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recovery_codes_user_idx": { + "name": "recovery_codes_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recovery_codes_user_id_users_id_fk": { + "name": "recovery_codes_user_id_users_id_fk", + "tableFrom": "recovery_codes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.register_entries": { + "name": "register_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "topic": { + "name": "topic", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "organism": { + "name": "organism", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "performed_on": { + "name": "performed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "next_due_on": { + "name": "next_due_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "participants": { + "name": "participants", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "observations": { + "name": "observations", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'saisie'" + }, + "source_ref": { + "name": "source_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "register_entries_est_idx": { + "name": "register_entries_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "performed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "register_entries_source_uq": { + "name": "register_entries_source_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"register_entries\".\"source_ref\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "register_entries_organization_id_organizations_id_fk": { + "name": "register_entries_organization_id_organizations_id_fk", + "tableFrom": "register_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "register_entries_establishment_id_establishments_id_fk": { + "name": "register_entries_establishment_id_establishments_id_fk", + "tableFrom": "register_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "register_entries_employee_id_employees_id_fk": { + "name": "register_entries_employee_id_employees_id_fk", + "tableFrom": "register_entries", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_supplier_id_suppliers_id_fk": { + "name": "register_entries_supplier_id_suppliers_id_fk", + "tableFrom": "register_entries", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_document_id_business_documents_id_fk": { + "name": "register_entries_document_id_business_documents_id_fk", + "tableFrom": "register_entries", + "tableTo": "business_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "register_entries_created_by_users_id_fk": { + "name": "register_entries_created_by_users_id_fk", + "tableFrom": "register_entries", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "register_entries_cancelled_by_users_id_fk": { + "name": "register_entries_cancelled_by_users_id_fk", + "tableFrom": "register_entries", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "register_entries_kind_ck": { + "name": "register_entries_kind_ck", + "value": "\"register_entries\".\"kind\" IN ('epi', 'exercice_incendie', 'controle', 'vigilance')" + }, + "register_entries_result_ck": { + "name": "register_entries_result_ck", + "value": "\"register_entries\".\"result\" IS NULL OR \"register_entries\".\"result\" IN ('conforme', 'reserves', 'non_conforme')" + }, + "register_entries_source_ck": { + "name": "register_entries_source_ck", + "value": "\"register_entries\".\"source\" IN ('saisie', 'document')" + }, + "register_entries_due_ck": { + "name": "register_entries_due_ck", + "value": "\"register_entries\".\"next_due_on\" IS NULL OR \"register_entries\".\"next_due_on\" >= \"register_entries\".\"performed_on\"" + }, + "register_entries_counts_ck": { + "name": "register_entries_counts_ck", + "value": "(\"register_entries\".\"quantity\" IS NULL OR \"register_entries\".\"quantity\" BETWEEN 1 AND 1000) AND (\"register_entries\".\"participants\" IS NULL OR \"register_entries\".\"participants\" BETWEEN 0 AND 10000) AND (\"register_entries\".\"duration_minutes\" IS NULL OR \"register_entries\".\"duration_minutes\" BETWEEN 1 AND 1440)" + }, + "register_entries_cancel_ck": { + "name": "register_entries_cancel_ck", + "value": "\"register_entries\".\"cancelled_at\" IS NULL OR (\"register_entries\".\"cancelled_by\" IS NOT NULL AND \"register_entries\".\"cancel_reason\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.regulatory_obligations": { + "name": "regulatory_obligations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "applicability": { + "name": "applicability", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source_status": { + "name": "source_status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_reference": { + "name": "source_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference_origin": { + "name": "reference_origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "catalogued_on": { + "name": "catalogued_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "verified_at": { + "name": "verified_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "validation_status": { + "name": "validation_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'non_validee'" + }, + "validator_name": { + "name": "validator_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validator_quality": { + "name": "validator_quality", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "validated_on": { + "name": "validated_on", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "legal_delay_text": { + "name": "legal_delay_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hr_check": { + "name": "hr_check", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "regulatory_obligations_code_uq": { + "name": "regulatory_obligations_code_uq", + "columns": [ + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "regulatory_obligations_domain_ck": { + "name": "regulatory_obligations_domain_ck", + "value": "\"regulatory_obligations\".\"domain\" IN ('hygiene', 'social', 'securite', 'fiscal', 'affichage', 'licences', 'consommateurs', 'environnement', 'donnees_personnelles')" + }, + "regulatory_obligations_source_ck": { + "name": "regulatory_obligations_source_ck", + "value": "\"regulatory_obligations\".\"source_status\" IN ('documentee', 'a_documenter') AND (\"regulatory_obligations\".\"source_status\" = 'a_documenter' OR \"regulatory_obligations\".\"source_reference\" IS NOT NULL)" + }, + "regulatory_obligations_validation_ck": { + "name": "regulatory_obligations_validation_ck", + "value": "\"regulatory_obligations\".\"validation_status\" IN ('non_validee', 'validee_par_professionnel') AND (\"regulatory_obligations\".\"validation_status\" = 'non_validee' OR (\"regulatory_obligations\".\"validator_name\" IS NOT NULL AND \"regulatory_obligations\".\"validator_quality\" IS NOT NULL AND \"regulatory_obligations\".\"validated_on\" IS NOT NULL))" + }, + "regulatory_obligations_active_ck": { + "name": "regulatory_obligations_active_ck", + "value": "NOT \"regulatory_obligations\".\"active\" OR (\"regulatory_obligations\".\"validation_status\" = 'validee_par_professionnel' AND \"regulatory_obligations\".\"source_status\" = 'documentee' AND \"regulatory_obligations\".\"source_url\" IS NOT NULL AND \"regulatory_obligations\".\"verified_at\" IS NOT NULL)" + }, + "regulatory_obligations_hr_ck": { + "name": "regulatory_obligations_hr_ck", + "value": "\"regulatory_obligations\".\"hr_check\" IS NULL OR \"regulatory_obligations\".\"hr_check\" IN ('work_permit', 'medical_visit', 'dpae')" + } + }, + "isRLSEnabled": false + }, + "public.report_schedules": { + "name": "report_schedules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gestion'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Rapport de gestion'" + }, + "send_time": { + "name": "send_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'07:00'" + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "attach_pdf": { + "name": "attach_pdf", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notify_in_app": { + "name": "notify_in_app", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "recipients": { + "name": "recipients", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "last_period_from": { + "name": "last_period_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "last_sent_at": { + "name": "last_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "indicators": { + "name": "indicators", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "send_condition": { + "name": "send_condition", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "report_schedules_org_idx": { + "name": "report_schedules_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "report_schedules_organization_id_organizations_id_fk": { + "name": "report_schedules_organization_id_organizations_id_fk", + "tableFrom": "report_schedules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_schedules_establishment_id_establishments_id_fk": { + "name": "report_schedules_establishment_id_establishments_id_fk", + "tableFrom": "report_schedules", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "report_schedules_created_by_users_id_fk": { + "name": "report_schedules_created_by_users_id_fk", + "tableFrom": "report_schedules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "report_schedules_audience_ck": { + "name": "report_schedules_audience_ck", + "value": "\"report_schedules\".\"audience\" IS NULL OR \"report_schedules\".\"audience\" IN ('proprietaire', 'direction', 'comptable', 'equipe', 'cuisine')" + }, + "report_schedules_freq_ck": { + "name": "report_schedules_freq_ck", + "value": "\"report_schedules\".\"frequency\" IN ('daily', 'weekly', 'monthly')" + }, + "report_schedules_time_ck": { + "name": "report_schedules_time_ck", + "value": "\"report_schedules\".\"send_time\" ~ '^(0[5-9]|1[0-9]|2[0-2]):(00|15|30|45)$'" + }, + "report_schedules_days_ck": { + "name": "report_schedules_days_ck", + "value": "\"report_schedules\".\"frequency\" <> 'daily' OR (CASE WHEN jsonb_typeof(\"report_schedules\".\"weekdays\") = 'array' THEN jsonb_array_length(\"report_schedules\".\"weekdays\") >= 1 ELSE false END)" + }, + "report_schedules_kind_ck": { + "name": "report_schedules_kind_ck", + "value": "\"report_schedules\".\"kind\" IN ('gestion', 'fermeture', 'groupe')" + }, + "report_schedules_closing_ck": { + "name": "report_schedules_closing_ck", + "value": "\"report_schedules\".\"kind\" <> 'fermeture' OR (\"report_schedules\".\"frequency\" = 'daily' AND \"report_schedules\".\"establishment_id\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.reputation_policies": { + "name": "reputation_policies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "levels": { + "name": "levels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "forbidden_words": { + "name": "forbidden_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "email_alerts": { + "name": "email_alerts", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "escalate_to": { + "name": "escalate_to", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reputation_policies_org_uq": { + "name": "reputation_policies_org_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reputation_policies\".\"establishment_id\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "reputation_policies_est_uq": { + "name": "reputation_policies_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reputation_policies\".\"establishment_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reputation_policies_organization_id_organizations_id_fk": { + "name": "reputation_policies_organization_id_organizations_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_policies_establishment_id_establishments_id_fk": { + "name": "reputation_policies_establishment_id_establishments_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_policies_escalate_to_users_id_fk": { + "name": "reputation_policies_escalate_to_users_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "users", + "columnsFrom": [ + "escalate_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reputation_policies_updated_by_users_id_fk": { + "name": "reputation_policies_updated_by_users_id_fk", + "tableFrom": "reputation_policies", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reputation_policies_tone_ck": { + "name": "reputation_policies_tone_ck", + "value": "\"reputation_policies\".\"tone\" IS NULL OR \"reputation_policies\".\"tone\" IN ('formel', 'chaleureux', 'sobre')" + }, + "reputation_policies_lang_ck": { + "name": "reputation_policies_lang_ck", + "value": "\"reputation_policies\".\"language\" IS NULL OR \"reputation_policies\".\"language\" IN ('fr', 'en')" + } + }, + "isRLSEnabled": false + }, + "public.reputation_settings": { + "name": "reputation_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "review_url": { + "name": "review_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signature": { + "name": "signature", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reputation_settings_establishment_id_establishments_id_fk": { + "name": "reputation_settings_establishment_id_establishments_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_settings_organization_id_organizations_id_fk": { + "name": "reputation_settings_organization_id_organizations_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reputation_settings_updated_by_users_id_fk": { + "name": "reputation_settings_updated_by_users_id_fk", + "tableFrom": "reputation_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reservation_exceptions": { + "name": "reservation_exceptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "service_id": { + "name": "service_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed": { + "name": "closed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "service_capacity": { + "name": "service_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_exceptions_day_idx": { + "name": "reservation_exceptions_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_exceptions_organization_id_organizations_id_fk": { + "name": "reservation_exceptions_organization_id_organizations_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_exceptions_establishment_id_establishments_id_fk": { + "name": "reservation_exceptions_establishment_id_establishments_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservation_exceptions_service_id_reservation_services_id_fk": { + "name": "reservation_exceptions_service_id_reservation_services_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "reservation_services", + "columnsFrom": [ + "service_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_exceptions_created_by_users_id_fk": { + "name": "reservation_exceptions_created_by_users_id_fk", + "tableFrom": "reservation_exceptions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_exceptions_cap_ck": { + "name": "reservation_exceptions_cap_ck", + "value": "\"reservation_exceptions\".\"closed\" OR \"reservation_exceptions\".\"service_capacity\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reservation_services": { + "name": "reservation_services", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "first_time": { + "name": "first_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_time": { + "name": "last_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slot_minutes": { + "name": "slot_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 30 + }, + "slot_capacity": { + "name": "slot_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "service_capacity": { + "name": "service_capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_services_est_idx": { + "name": "reservation_services_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_services_organization_id_organizations_id_fk": { + "name": "reservation_services_organization_id_organizations_id_fk", + "tableFrom": "reservation_services", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_services_establishment_id_establishments_id_fk": { + "name": "reservation_services_establishment_id_establishments_id_fk", + "tableFrom": "reservation_services", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_services_time_ck": { + "name": "reservation_services_time_ck", + "value": "\"reservation_services\".\"first_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_services\".\"last_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "reservation_services_slot_ck": { + "name": "reservation_services_slot_ck", + "value": "\"reservation_services\".\"slot_minutes\" IN (15, 30, 60) AND \"reservation_services\".\"duration_minutes\" BETWEEN 15 AND 720" + }, + "reservation_services_cap_ck": { + "name": "reservation_services_cap_ck", + "value": "(\"reservation_services\".\"slot_capacity\" IS NULL OR \"reservation_services\".\"slot_capacity\" > 0) AND (\"reservation_services\".\"service_capacity\" IS NULL OR \"reservation_services\".\"service_capacity\" > 0)" + } + }, + "isRLSEnabled": false + }, + "public.reservation_settings": { + "name": "reservation_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reminder_email": { + "name": "reminder_email", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reminder_hour": { + "name": "reminder_hour", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "online_enabled": { + "name": "online_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "online_token": { + "name": "online_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "online_by": { + "name": "online_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "online_max_covers": { + "name": "online_max_covers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 8 + }, + "waitlist_auto_offer": { + "name": "waitlist_auto_offer", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "online_auto_confirm": { + "name": "online_auto_confirm", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "online_lead_minutes": { + "name": "online_lead_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "online_days": { + "name": "online_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 60 + }, + "online_message": { + "name": "online_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "online_groups": { + "name": "online_groups", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "self_cancel_enabled": { + "name": "self_cancel_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "self_cancel_minutes": { + "name": "self_cancel_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 120 + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_settings_online_token_uq": { + "name": "reservation_settings_online_token_uq", + "columns": [ + { + "expression": "online_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_settings_establishment_id_establishments_id_fk": { + "name": "reservation_settings_establishment_id_establishments_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_settings_organization_id_organizations_id_fk": { + "name": "reservation_settings_organization_id_organizations_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_settings_online_by_users_id_fk": { + "name": "reservation_settings_online_by_users_id_fk", + "tableFrom": "reservation_settings", + "tableTo": "users", + "columnsFrom": [ + "online_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_settings_hour_ck": { + "name": "reservation_settings_hour_ck", + "value": "\"reservation_settings\".\"reminder_hour\" BETWEEN 7 AND 21" + }, + "reservation_settings_online_ck": { + "name": "reservation_settings_online_ck", + "value": "\"reservation_settings\".\"online_max_covers\" BETWEEN 1 AND 50 AND \"reservation_settings\".\"online_lead_minutes\" BETWEEN 0 AND 2880 AND \"reservation_settings\".\"online_days\" BETWEEN 1 AND 365" + }, + "reservation_settings_self_cancel_ck": { + "name": "reservation_settings_self_cancel_ck", + "value": "\"reservation_settings\".\"self_cancel_minutes\" BETWEEN 0 AND 10080" + } + }, + "isRLSEnabled": false + }, + "public.reservation_tables": { + "name": "reservation_tables", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "starts_at": { + "name": "starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ends_at": { + "name": "ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "released_at": { + "name": "released_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_tables_res_idx": { + "name": "reservation_tables_res_idx", + "columns": [ + { + "expression": "reservation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservation_tables_table_idx": { + "name": "reservation_tables_table_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "starts_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_tables_organization_id_organizations_id_fk": { + "name": "reservation_tables_organization_id_organizations_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_tables_establishment_id_establishments_id_fk": { + "name": "reservation_tables_establishment_id_establishments_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservation_tables_reservation_id_reservations_id_fk": { + "name": "reservation_tables_reservation_id_reservations_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_tables_table_id_floor_items_id_fk": { + "name": "reservation_tables_table_id_floor_items_id_fk", + "tableFrom": "reservation_tables", + "tableTo": "floor_items", + "columnsFrom": [ + "table_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_tables_range_ck": { + "name": "reservation_tables_range_ck", + "value": "\"reservation_tables\".\"ends_at\" > \"reservation_tables\".\"starts_at\"" + } + }, + "isRLSEnabled": false + }, + "public.reservation_waitlist": { + "name": "reservation_waitlist", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "time_from": { + "name": "time_from", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "time_to": { + "name": "time_to", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "offered_at": { + "name": "offered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "offered_from_reservation_id": { + "name": "offered_from_reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "offered_time": { + "name": "offered_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reservation_id": { + "name": "reservation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "close_reason": { + "name": "close_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservation_waitlist_day_idx": { + "name": "reservation_waitlist_day_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservation_waitlist_organization_id_organizations_id_fk": { + "name": "reservation_waitlist_organization_id_organizations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_waitlist_establishment_id_establishments_id_fk": { + "name": "reservation_waitlist_establishment_id_establishments_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservation_waitlist_offered_from_reservation_id_reservations_id_fk": { + "name": "reservation_waitlist_offered_from_reservation_id_reservations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "reservations", + "columnsFrom": [ + "offered_from_reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservation_waitlist_reservation_id_reservations_id_fk": { + "name": "reservation_waitlist_reservation_id_reservations_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "reservations", + "columnsFrom": [ + "reservation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservation_waitlist_created_by_users_id_fk": { + "name": "reservation_waitlist_created_by_users_id_fk", + "tableFrom": "reservation_waitlist", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservation_waitlist_status_ck": { + "name": "reservation_waitlist_status_ck", + "value": "\"reservation_waitlist\".\"status\" IN ('en_attente', 'proposee', 'convertie', 'annulee')" + }, + "reservation_waitlist_covers_ck": { + "name": "reservation_waitlist_covers_ck", + "value": "\"reservation_waitlist\".\"covers\" BETWEEN 1 AND 500" + }, + "reservation_waitlist_time_ck": { + "name": "reservation_waitlist_time_ck", + "value": "\"reservation_waitlist\".\"time_from\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_waitlist\".\"time_to\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservation_waitlist\".\"time_to\" >= \"reservation_waitlist\".\"time_from\"" + }, + "reservation_waitlist_contact_ck": { + "name": "reservation_waitlist_contact_ck", + "value": "\"reservation_waitlist\".\"phone\" IS NOT NULL OR \"reservation_waitlist\".\"email\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.reservations": { + "name": "reservations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "service_id": { + "name": "service_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "customer_id": { + "name": "customer_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "time": { + "name": "time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "starts_at": { + "name": "starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ends_at": { + "name": "ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'confirmee'" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'telephone'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request": { + "name": "request", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "arrived_at": { + "name": "arrived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "confirmation_sent_at": { + "name": "confirmation_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reminder_sent_at": { + "name": "reminder_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "external_ref": { + "name": "external_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "manage_token": { + "name": "manage_token", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "replace(gen_random_uuid()::text, '-', '') || replace(gen_random_uuid()::text, '-', '')" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reservations_day_idx": { + "name": "reservations_day_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_customer_idx": { + "name": "reservations_customer_idx", + "columns": [ + { + "expression": "customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_manage_token_uq": { + "name": "reservations_manage_token_uq", + "columns": [ + { + "expression": "manage_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reservations_external_ref_uq": { + "name": "reservations_external_ref_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reservations\".\"external_ref\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reservations_organization_id_organizations_id_fk": { + "name": "reservations_organization_id_organizations_id_fk", + "tableFrom": "reservations", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reservations_establishment_id_establishments_id_fk": { + "name": "reservations_establishment_id_establishments_id_fk", + "tableFrom": "reservations", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "reservations_service_id_reservation_services_id_fk": { + "name": "reservations_service_id_reservation_services_id_fk", + "tableFrom": "reservations", + "tableTo": "reservation_services", + "columnsFrom": [ + "service_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservations_customer_id_customers_id_fk": { + "name": "reservations_customer_id_customers_id_fk", + "tableFrom": "reservations", + "tableTo": "customers", + "columnsFrom": [ + "customer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reservations_created_by_users_id_fk": { + "name": "reservations_created_by_users_id_fk", + "tableFrom": "reservations", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reservations_status_ck": { + "name": "reservations_status_ck", + "value": "\"reservations\".\"status\" IN ('en_attente', 'confirmee', 'arrivee', 'terminee', 'no_show', 'annulee')" + }, + "reservations_covers_ck": { + "name": "reservations_covers_ck", + "value": "\"reservations\".\"covers\" BETWEEN 1 AND 500" + }, + "reservations_time_ck": { + "name": "reservations_time_ck", + "value": "\"reservations\".\"time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"reservations\".\"ends_at\" > \"reservations\".\"starts_at\"" + } + }, + "isRLSEnabled": false + }, + "public.review_autopublish": { + "name": "review_autopublish", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "levels": { + "name": "levels", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled_by": { + "name": "enabled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "enabled_at": { + "name": "enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "confirmation": { + "name": "confirmation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paused_reason": { + "name": "paused_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "review_autopublish_establishment_id_establishments_id_fk": { + "name": "review_autopublish_establishment_id_establishments_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_autopublish_organization_id_organizations_id_fk": { + "name": "review_autopublish_organization_id_organizations_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_autopublish_enabled_by_users_id_fk": { + "name": "review_autopublish_enabled_by_users_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "users", + "columnsFrom": [ + "enabled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "review_autopublish_updated_by_users_id_fk": { + "name": "review_autopublish_updated_by_users_id_fk", + "tableFrom": "review_autopublish", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.review_publications": { + "name": "review_publications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "review_id": { + "name": "review_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blocked_words": { + "name": "blocked_words", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "google_reply_state": { + "name": "google_reply_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "review_publications_review_uq": { + "name": "review_publications_review_uq", + "columns": [ + { + "expression": "review_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "review_publications_due_idx": { + "name": "review_publications_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "review_publications_organization_id_organizations_id_fk": { + "name": "review_publications_organization_id_organizations_id_fk", + "tableFrom": "review_publications", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_publications_establishment_id_establishments_id_fk": { + "name": "review_publications_establishment_id_establishments_id_fk", + "tableFrom": "review_publications", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "review_publications_review_id_reviews_id_fk": { + "name": "review_publications_review_id_reviews_id_fk", + "tableFrom": "review_publications", + "tableTo": "reviews", + "columnsFrom": [ + "review_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "review_publications_status_ck": { + "name": "review_publications_status_ck", + "value": "\"review_publications\".\"status\" IN ('scheduled', 'publishing', 'published', 'failed', 'blocked', 'cancelled', 'skipped')" + } + }, + "isRLSEnabled": false + }, + "public.reviews": { + "name": "reviews", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reviewed_on": { + "name": "reviewed_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fingerprint": { + "name": "fingerprint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reply_text": { + "name": "reply_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "replied_at": { + "name": "replied_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "replied_by": { + "name": "replied_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "internal_note": { + "name": "internal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assigned_to": { + "name": "assigned_to", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "assigned_by": { + "name": "assigned_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rule_action": { + "name": "rule_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "alerted_at": { + "name": "alerted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_name": { + "name": "external_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_updated_at": { + "name": "external_updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reply_origin": { + "name": "reply_origin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reviews_fingerprint_uq": { + "name": "reviews_fingerprint_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "fingerprint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_external_uq": { + "name": "reviews_external_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"reviews\".\"external_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_est_day_idx": { + "name": "reviews_est_day_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reviewed_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reviews_assigned_idx": { + "name": "reviews_assigned_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "assigned_to", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"reviews\".\"assigned_to\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reviews_organization_id_organizations_id_fk": { + "name": "reviews_organization_id_organizations_id_fk", + "tableFrom": "reviews", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reviews_establishment_id_establishments_id_fk": { + "name": "reviews_establishment_id_establishments_id_fk", + "tableFrom": "reviews", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reviews_replied_by_users_id_fk": { + "name": "reviews_replied_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "replied_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reviews_assigned_to_users_id_fk": { + "name": "reviews_assigned_to_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "assigned_to" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reviews_assigned_by_users_id_fk": { + "name": "reviews_assigned_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "assigned_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "reviews_created_by_users_id_fk": { + "name": "reviews_created_by_users_id_fk", + "tableFrom": "reviews", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reviews_reply_origin_ck": { + "name": "reviews_reply_origin_ck", + "value": "\"reviews\".\"reply_origin\" IS NULL OR \"reviews\".\"reply_origin\" IN ('manuel', 'google', 'auto')" + }, + "reviews_rating_ck": { + "name": "reviews_rating_ck", + "value": "\"reviews\".\"rating\" BETWEEN 1 AND 5" + }, + "reviews_source_ck": { + "name": "reviews_source_ck", + "value": "\"reviews\".\"source\" IN ('google', 'tripadvisor', 'thefork', 'facebook', 'direct', 'autre')" + }, + "reviews_rule_action_ck": { + "name": "reviews_rule_action_ck", + "value": "\"reviews\".\"rule_action\" IS NULL OR \"reviews\".\"rule_action\" IN ('remercier', 'remercier_inviter', 'demander_retour', 'transmettre', 'alerte')" + } + }, + "isRLSEnabled": false + }, + "public.sales_challenges": { + "name": "sales_challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "preset": { + "name": "preset", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'perso'" + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keywords": { + "name": "keywords", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "categories": { + "name": "categories", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "from_day": { + "name": "from_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "to_day": { + "name": "to_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "rewards": { + "name": "rewards", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "target_value": { + "name": "target_value", + "type": "numeric(14, 3)", + "primaryKey": false, + "notNull": false + }, + "results": { + "name": "results", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_challenges_org_idx": { + "name": "sales_challenges_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_challenges_organization_id_organizations_id_fk": { + "name": "sales_challenges_organization_id_organizations_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_challenges_establishment_id_establishments_id_fk": { + "name": "sales_challenges_establishment_id_establishments_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_challenges_created_by_users_id_fk": { + "name": "sales_challenges_created_by_users_id_fk", + "tableFrom": "sales_challenges", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_challenges_metric_ck": { + "name": "sales_challenges_metric_ck", + "value": "\"sales_challenges\".\"metric\" IN ('quantite', 'ca_ht', 'ca_heure')" + }, + "sales_challenges_range_ck": { + "name": "sales_challenges_range_ck", + "value": "\"sales_challenges\".\"to_day\" >= \"sales_challenges\".\"from_day\" AND \"sales_challenges\".\"to_day\" - \"sales_challenges\".\"from_day\" <= 366" + }, + "sales_challenges_target_ck": { + "name": "sales_challenges_target_ck", + "value": "\"sales_challenges\".\"target_value\" IS NULL OR \"sales_challenges\".\"target_value\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.sales_entries": { + "name": "sales_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "batch_id": { + "name": "batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_date": { + "name": "business_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "ticket_ref": { + "name": "ticket_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount_ht": { + "name": "amount_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_rate": { + "name": "vat_rate", + "type": "numeric(6, 4)", + "primaryKey": false, + "notNull": true + }, + "vat_amount": { + "name": "vat_amount", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "covers": { + "name": "covers", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "payment_method": { + "name": "payment_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "format_version": { + "name": "format_version", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "line_ref": { + "name": "line_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sold_time": { + "name": "sold_time", + "type": "time", + "primaryKey": false, + "notNull": false + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "product": { + "name": "product", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "quantity": { + "name": "quantity", + "type": "numeric(12, 3)", + "primaryKey": false, + "notNull": false + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "table_label": { + "name": "table_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "discount_ttc": { + "name": "discount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "comp_ttc": { + "name": "comp_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "product_code": { + "name": "product_code", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sales_entries_row_uq": { + "name": "sales_entries_row_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_entries_period_idx": { + "name": "sales_entries_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_entries_ticket_idx": { + "name": "sales_entries_ticket_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ticket_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_entries_organization_id_organizations_id_fk": { + "name": "sales_entries_organization_id_organizations_id_fk", + "tableFrom": "sales_entries", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_entries_establishment_id_establishments_id_fk": { + "name": "sales_entries_establishment_id_establishments_id_fk", + "tableFrom": "sales_entries", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_entries_batch_id_sales_import_batches_id_fk": { + "name": "sales_entries_batch_id_sales_import_batches_id_fk", + "tableFrom": "sales_entries", + "tableTo": "sales_import_batches", + "columnsFrom": [ + "batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_ttc_consistency_ck": { + "name": "sales_ttc_consistency_ck", + "value": "\"sales_entries\".\"amount_ttc\" = \"sales_entries\".\"amount_ht\" + \"sales_entries\".\"vat_amount\"" + }, + "sales_format_version_ck": { + "name": "sales_format_version_ck", + "value": "\"sales_entries\".\"format_version\" IN (1, 2)" + }, + "sales_channel_ck": { + "name": "sales_channel_ck", + "value": "\"sales_entries\".\"channel\" IS NULL OR \"sales_entries\".\"channel\" IN ('sur_place', 'emporter', 'livraison', 'click_collect', 'autre')" + }, + "sales_discount_ck": { + "name": "sales_discount_ck", + "value": "\"sales_entries\".\"discount_ttc\" IS NULL OR \"sales_entries\".\"discount_ttc\" >= 0" + }, + "sales_comp_ck": { + "name": "sales_comp_ck", + "value": "\"sales_entries\".\"comp_ttc\" IS NULL OR \"sales_entries\".\"comp_ttc\" >= 0" + }, + "sales_quantity_ck": { + "name": "sales_quantity_ck", + "value": "\"sales_entries\".\"quantity\" IS NULL OR \"sales_entries\".\"quantity\" <> 0" + } + }, + "isRLSEnabled": false + }, + "public.sales_families": { + "name": "sales_families", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_families_name_uq": { + "name": "sales_families_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_families_organization_id_organizations_id_fk": { + "name": "sales_families_organization_id_organizations_id_fk", + "tableFrom": "sales_families", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_families_created_by_users_id_fk": { + "name": "sales_families_created_by_users_id_fk", + "tableFrom": "sales_families", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_family_rules": { + "name": "sales_family_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "family_id": { + "name": "family_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_kind": { + "name": "match_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_family_rules_uq": { + "name": "sales_family_rules_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_family_rules_organization_id_organizations_id_fk": { + "name": "sales_family_rules_organization_id_organizations_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_family_rules_family_id_sales_families_id_fk": { + "name": "sales_family_rules_family_id_sales_families_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "sales_families", + "columnsFrom": [ + "family_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_family_rules_created_by_users_id_fk": { + "name": "sales_family_rules_created_by_users_id_fk", + "tableFrom": "sales_family_rules", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_family_rules_kind_ck": { + "name": "sales_family_rules_kind_ck", + "value": "\"sales_family_rules\".\"match_kind\" IN ('category', 'product')" + } + }, + "isRLSEnabled": false + }, + "public.sales_import_batches": { + "name": "sales_import_batches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_sha256": { + "name": "file_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "row_count": { + "name": "row_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_ht": { + "name": "total_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "total_ttc": { + "name": "total_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "period_from": { + "name": "period_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "period_to": { + "name": "period_to", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "import_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "imported_by": { + "name": "imported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reverted_at": { + "name": "reverted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reverted_by": { + "name": "reverted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payment_count": { + "name": "payment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_batches_file_uq": { + "name": "sales_batches_file_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "file_sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_import_batches_organization_id_organizations_id_fk": { + "name": "sales_import_batches_organization_id_organizations_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_import_batches_establishment_id_establishments_id_fk": { + "name": "sales_import_batches_establishment_id_establishments_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_import_batches_imported_by_users_id_fk": { + "name": "sales_import_batches_imported_by_users_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "users", + "columnsFrom": [ + "imported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sales_import_batches_reverted_by_users_id_fk": { + "name": "sales_import_batches_reverted_by_users_id_fk", + "tableFrom": "sales_import_batches", + "tableTo": "users", + "columnsFrom": [ + "reverted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_import_profiles": { + "name": "sales_import_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header_signature": { + "name": "header_signature", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "headers": { + "name": "headers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "mapping": { + "name": "mapping", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "use_count": { + "name": "use_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_import_profiles_sig_uq": { + "name": "sales_import_profiles_sig_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "header_signature", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_import_profiles_organization_id_organizations_id_fk": { + "name": "sales_import_profiles_organization_id_organizations_id_fk", + "tableFrom": "sales_import_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_import_profiles_created_by_users_id_fk": { + "name": "sales_import_profiles_created_by_users_id_fk", + "tableFrom": "sales_import_profiles", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_import_profiles_name_ck": { + "name": "sales_import_profiles_name_ck", + "value": "length(\"sales_import_profiles\".\"name\") BETWEEN 1 AND 80" + } + }, + "isRLSEnabled": false + }, + "public.sales_payments": { + "name": "sales_payments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "batch_id": { + "name": "batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_date": { + "name": "business_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "ticket_ref": { + "name": "ticket_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount_ttc": { + "name": "amount_ttc", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "row_hash": { + "name": "row_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data_status": { + "name": "data_status", + "type": "data_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'real_unvalidated'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_payments_row_uq": { + "name": "sales_payments_row_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "row_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_payments_period_idx": { + "name": "sales_payments_period_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_payments_organization_id_organizations_id_fk": { + "name": "sales_payments_organization_id_organizations_id_fk", + "tableFrom": "sales_payments", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_payments_establishment_id_establishments_id_fk": { + "name": "sales_payments_establishment_id_establishments_id_fk", + "tableFrom": "sales_payments", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_payments_batch_id_sales_import_batches_id_fk": { + "name": "sales_payments_batch_id_sales_import_batches_id_fk", + "tableFrom": "sales_payments", + "tableTo": "sales_import_batches", + "columnsFrom": [ + "batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_product_recipe_history": { + "name": "sales_product_recipe_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "portions_per_sale": { + "name": "portions_per_sale", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "valid_until": { + "name": "valid_until", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_product_recipe_history_uq": { + "name": "sales_product_recipe_history_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "valid_until", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_product_recipe_history_organization_id_organizations_id_fk": { + "name": "sales_product_recipe_history_organization_id_organizations_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_product_recipe_history_recipe_id_recipes_id_fk": { + "name": "sales_product_recipe_history_recipe_id_recipes_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_product_recipe_history_created_by_users_id_fk": { + "name": "sales_product_recipe_history_created_by_users_id_fk", + "tableFrom": "sales_product_recipe_history", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sales_product_recipes": { + "name": "sales_product_recipes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "match_key": { + "name": "match_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "match_label": { + "name": "match_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "portions_per_sale": { + "name": "portions_per_sale", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "match_code": { + "name": "match_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_product_recipes_key_uq": { + "name": "sales_product_recipes_key_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_product_recipes_code_uq": { + "name": "sales_product_recipes_code_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "match_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"sales_product_recipes\".\"match_code\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_product_recipes_recipe_idx": { + "name": "sales_product_recipes_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_product_recipes_organization_id_organizations_id_fk": { + "name": "sales_product_recipes_organization_id_organizations_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_product_recipes_recipe_id_recipes_id_fk": { + "name": "sales_product_recipes_recipe_id_recipes_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "sales_product_recipes_created_by_users_id_fk": { + "name": "sales_product_recipes_created_by_users_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "sales_product_recipes_updated_by_users_id_fk": { + "name": "sales_product_recipes_updated_by_users_id_fk", + "tableFrom": "sales_product_recipes", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_product_recipes_ck": { + "name": "sales_product_recipes_ck", + "value": "(\"sales_product_recipes\".\"recipe_id\" IS NULL AND \"sales_product_recipes\".\"portions_per_sale\" IS NULL) OR (\"sales_product_recipes\".\"recipe_id\" IS NOT NULL AND \"sales_product_recipes\".\"portions_per_sale\" > 0)" + } + }, + "isRLSEnabled": false + }, + "public.sales_server_links": { + "name": "sales_server_links", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "server_key": { + "name": "server_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "server_label": { + "name": "server_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_server_links_uq": { + "name": "sales_server_links_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "server_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sales_server_links_org_idx": { + "name": "sales_server_links_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_server_links_organization_id_organizations_id_fk": { + "name": "sales_server_links_organization_id_organizations_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_establishment_id_establishments_id_fk": { + "name": "sales_server_links_establishment_id_establishments_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_employee_id_employees_id_fk": { + "name": "sales_server_links_employee_id_employees_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_server_links_created_by_users_id_fk": { + "name": "sales_server_links_created_by_users_id_fk", + "tableFrom": "sales_server_links", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_server_links_key_ck": { + "name": "sales_server_links_key_ck", + "value": "length(\"sales_server_links\".\"server_key\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + }, + "public.sales_service_periods": { + "name": "sales_service_periods", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sales_service_periods_name_uq": { + "name": "sales_service_periods_name_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sales_service_periods_organization_id_organizations_id_fk": { + "name": "sales_service_periods_organization_id_organizations_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_service_periods_establishment_id_establishments_id_fk": { + "name": "sales_service_periods_establishment_id_establishments_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sales_service_periods_created_by_users_id_fk": { + "name": "sales_service_periods_created_by_users_id_fk", + "tableFrom": "sales_service_periods", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "sales_service_periods_time_ck": { + "name": "sales_service_periods_time_ck", + "value": "\"sales_service_periods\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"sales_service_periods\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"sales_service_periods\".\"start_time\" <> \"sales_service_periods\".\"end_time\"" + } + }, + "isRLSEnabled": false + }, + "public.sensitive_views": { + "name": "sensitive_views", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "area": { + "name": "area", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "viewed_at": { + "name": "viewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sensitive_views_org_idx": { + "name": "sensitive_views_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "viewed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sensitive_views_user_idx": { + "name": "sensitive_views_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "viewed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sensitive_views_organization_id_organizations_id_fk": { + "name": "sensitive_views_organization_id_organizations_id_fk", + "tableFrom": "sensitive_views", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sensitive_views_user_id_users_id_fk": { + "name": "sensitive_views_user_id_users_id_fk", + "tableFrom": "sensitive_views", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.seo_listings": { + "name": "seo_listings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "directory": { + "name": "directory", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "nap_hash": { + "name": "nap_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "checked_by": { + "name": "checked_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "checked_at": { + "name": "checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_listings_est_dir_uq": { + "name": "seo_listings_est_dir_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "directory", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_listings_org_idx": { + "name": "seo_listings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_listings_organization_id_organizations_id_fk": { + "name": "seo_listings_organization_id_organizations_id_fk", + "tableFrom": "seo_listings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_listings_establishment_id_establishments_id_fk": { + "name": "seo_listings_establishment_id_establishments_id_fk", + "tableFrom": "seo_listings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_listings_checked_by_users_id_fk": { + "name": "seo_listings_checked_by_users_id_fk", + "tableFrom": "seo_listings", + "tableTo": "users", + "columnsFrom": [ + "checked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "seo_listings_status_ck": { + "name": "seo_listings_status_ck", + "value": "\"seo_listings\".\"status\" IN ('en_ligne', 'absent', 'non_concerne')" + } + }, + "isRLSEnabled": false + }, + "public.seo_profiles": { + "name": "seo_profiles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cuisines": { + "name": "cuisines", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "price_range": { + "name": "price_range", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "menu_url": { + "name": "menu_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "links": { + "name": "links", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "keywords": { + "name": "keywords", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "seo_profiles_est_uq": { + "name": "seo_profiles_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "seo_profiles_org_idx": { + "name": "seo_profiles_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "seo_profiles_organization_id_organizations_id_fk": { + "name": "seo_profiles_organization_id_organizations_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_profiles_establishment_id_establishments_id_fk": { + "name": "seo_profiles_establishment_id_establishments_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "seo_profiles_updated_by_users_id_fk": { + "name": "seo_profiles_updated_by_users_id_fk", + "tableFrom": "seo_profiles", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "seo_profiles_price_ck": { + "name": "seo_profiles_price_ck", + "value": "\"seo_profiles\".\"price_range\" IS NULL OR \"seo_profiles\".\"price_range\" IN ('\u20ac', '\u20ac\u20ac', '\u20ac\u20ac\u20ac', '\u20ac\u20ac\u20ac\u20ac')" + } + }, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sessions_user_idx": { + "name": "sessions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sessions_organization_id_organizations_id_fk": { + "name": "sessions_organization_id_organizations_id_fk", + "tableFrom": "sessions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.set_menus": { + "name": "set_menus", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "occasion": { + "name": "occasion", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "min_guests": { + "name": "min_guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_guests": { + "name": "max_guests", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "available_from": { + "name": "available_from", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "available_to": { + "name": "available_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "recipe_ids": { + "name": "recipe_ids", + "type": "uuid[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::uuid[]" + }, + "courses": { + "name": "courses", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "set_menus_est_idx": { + "name": "set_menus_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "set_menus_organization_id_organizations_id_fk": { + "name": "set_menus_organization_id_organizations_id_fk", + "tableFrom": "set_menus", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "set_menus_establishment_id_establishments_id_fk": { + "name": "set_menus_establishment_id_establishments_id_fk", + "tableFrom": "set_menus", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "set_menus_created_by_users_id_fk": { + "name": "set_menus_created_by_users_id_fk", + "tableFrom": "set_menus", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "set_menus_category_ck": { + "name": "set_menus_category_ck", + "value": "\"set_menus\".\"category\" IN ('carte', 'groupe', 'evenement')" + }, + "set_menus_guests_ck": { + "name": "set_menus_guests_ck", + "value": "(\"set_menus\".\"min_guests\" IS NULL OR \"set_menus\".\"min_guests\" > 0) AND (\"set_menus\".\"max_guests\" IS NULL OR \"set_menus\".\"max_guests\" > 0) AND (\"set_menus\".\"min_guests\" IS NULL OR \"set_menus\".\"max_guests\" IS NULL OR \"set_menus\".\"min_guests\" <= \"set_menus\".\"max_guests\")" + }, + "set_menus_dates_ck": { + "name": "set_menus_dates_ck", + "value": "\"set_menus\".\"available_from\" IS NULL OR \"set_menus\".\"available_to\" IS NULL OR \"set_menus\".\"available_from\" <= \"set_menus\".\"available_to\"" + } + }, + "isRLSEnabled": false + }, + "public.shift_swaps": { + "name": "shift_swaps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "shift_id": { + "name": "shift_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "from_employee_id": { + "name": "from_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_employee_id": { + "name": "to_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "counter_shift_id": { + "name": "counter_shift_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "shift_snapshot": { + "name": "shift_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counter_snapshot": { + "name": "counter_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'attente_collegue'" + }, + "colleague_answered_at": { + "name": "colleague_answered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decided_by": { + "name": "decided_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "decision_note": { + "name": "decision_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shift_swaps_est_status_idx": { + "name": "shift_swaps_est_status_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shift_swaps_from_idx": { + "name": "shift_swaps_from_idx", + "columns": [ + { + "expression": "from_employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shift_swaps_to_idx": { + "name": "shift_swaps_to_idx", + "columns": [ + { + "expression": "to_employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shift_swaps_organization_id_organizations_id_fk": { + "name": "shift_swaps_organization_id_organizations_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_establishment_id_establishments_id_fk": { + "name": "shift_swaps_establishment_id_establishments_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_shift_id_shifts_id_fk": { + "name": "shift_swaps_shift_id_shifts_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "shifts", + "columnsFrom": [ + "shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "shift_swaps_from_employee_id_employees_id_fk": { + "name": "shift_swaps_from_employee_id_employees_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "employees", + "columnsFrom": [ + "from_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_to_employee_id_employees_id_fk": { + "name": "shift_swaps_to_employee_id_employees_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "employees", + "columnsFrom": [ + "to_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_swaps_counter_shift_id_shifts_id_fk": { + "name": "shift_swaps_counter_shift_id_shifts_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "shifts", + "columnsFrom": [ + "counter_shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "shift_swaps_decided_by_users_id_fk": { + "name": "shift_swaps_decided_by_users_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shift_swaps_created_by_users_id_fk": { + "name": "shift_swaps_created_by_users_id_fk", + "tableFrom": "shift_swaps", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shift_swaps_status_ck": { + "name": "shift_swaps_status_ck", + "value": "\"shift_swaps\".\"status\" IN ('attente_collegue', 'attente_responsable', 'acceptee', 'refusee', 'annulee', 'expiree')" + }, + "shift_swaps_people_ck": { + "name": "shift_swaps_people_ck", + "value": "\"shift_swaps\".\"from_employee_id\" <> \"shift_swaps\".\"to_employee_id\"" + } + }, + "isRLSEnabled": false + }, + "public.shift_templates": { + "name": "shift_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "break_minutes": { + "name": "break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shift_templates_est_idx": { + "name": "shift_templates_est_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shift_templates_organization_id_organizations_id_fk": { + "name": "shift_templates_organization_id_organizations_id_fk", + "tableFrom": "shift_templates", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_templates_establishment_id_establishments_id_fk": { + "name": "shift_templates_establishment_id_establishments_id_fk", + "tableFrom": "shift_templates", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shift_templates_created_by_users_id_fk": { + "name": "shift_templates_created_by_users_id_fk", + "tableFrom": "shift_templates", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shift_templates_time_ck": { + "name": "shift_templates_time_ck", + "value": "\"shift_templates\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shift_templates\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shift_templates\".\"start_time\" <> \"shift_templates\".\"end_time\"" + }, + "shift_templates_break_ck": { + "name": "shift_templates_break_ck", + "value": "\"shift_templates\".\"break_minutes\" >= 0 AND \"shift_templates\".\"break_minutes\" <= 240" + } + }, + "isRLSEnabled": false + }, + "public.shifts": { + "name": "shifts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "break_minutes": { + "name": "break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_start": { + "name": "actual_start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_end": { + "name": "actual_end", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actual_break_minutes": { + "name": "actual_break_minutes", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "meals": { + "name": "meals", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "no_show": { + "name": "no_show", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "validated_at": { + "name": "validated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "validated_by": { + "name": "validated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shifts_est_date_idx": { + "name": "shifts_est_date_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shifts_emp_date_idx": { + "name": "shifts_emp_date_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shifts_organization_id_organizations_id_fk": { + "name": "shifts_organization_id_organizations_id_fk", + "tableFrom": "shifts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_establishment_id_establishments_id_fk": { + "name": "shifts_establishment_id_establishments_id_fk", + "tableFrom": "shifts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_employee_id_employees_id_fk": { + "name": "shifts_employee_id_employees_id_fk", + "tableFrom": "shifts", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shifts_validated_by_users_id_fk": { + "name": "shifts_validated_by_users_id_fk", + "tableFrom": "shifts", + "tableTo": "users", + "columnsFrom": [ + "validated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shifts_created_by_users_id_fk": { + "name": "shifts_created_by_users_id_fk", + "tableFrom": "shifts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "shifts_meals_ck": { + "name": "shifts_meals_ck", + "value": "\"shifts\".\"meals\" >= 0 AND \"shifts\".\"meals\" <= 3" + }, + "shifts_time_ck": { + "name": "shifts_time_ck", + "value": "\"shifts\".\"start_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shifts\".\"end_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"shifts\".\"start_time\" <> \"shifts\".\"end_time\"" + }, + "shifts_break_ck": { + "name": "shifts_break_ck", + "value": "\"shifts\".\"break_minutes\" >= 0 AND \"shifts\".\"break_minutes\" <= 240" + } + }, + "isRLSEnabled": false + }, + "public.signature_requests": { + "name": "signature_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_id": { + "name": "contract_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_pdf": { + "name": "document_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "document_sha256": { + "name": "document_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en_attente'" + }, + "signer_email": { + "name": "signer_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "employer_name": { + "name": "employer_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code_expires_at": { + "name": "code_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "code_sent_at": { + "name": "code_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "codes_sent": { + "name": "codes_sent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "code_attempts": { + "name": "code_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "signed_at": { + "name": "signed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "signed_name": { + "name": "signed_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "signed_pdf": { + "name": "signed_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "signed_sha256": { + "name": "signed_sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refusal_note": { + "name": "refusal_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "file_id": { + "name": "file_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "drawn_signature": { + "name": "drawn_signature", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "reminders_sent": { + "name": "reminders_sent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_reminder_at": { + "name": "last_reminder_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "signature_requests_token_uq": { + "name": "signature_requests_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "signature_requests_emp_idx": { + "name": "signature_requests_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "signature_requests_organization_id_organizations_id_fk": { + "name": "signature_requests_organization_id_organizations_id_fk", + "tableFrom": "signature_requests", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_establishment_id_establishments_id_fk": { + "name": "signature_requests_establishment_id_establishments_id_fk", + "tableFrom": "signature_requests", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_employee_id_employees_id_fk": { + "name": "signature_requests_employee_id_employees_id_fk", + "tableFrom": "signature_requests", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "signature_requests_file_id_employee_files_id_fk": { + "name": "signature_requests_file_id_employee_files_id_fk", + "tableFrom": "signature_requests", + "tableTo": "employee_files", + "columnsFrom": [ + "file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "signature_requests_created_by_users_id_fk": { + "name": "signature_requests_created_by_users_id_fk", + "tableFrom": "signature_requests", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "signature_requests_status_ck": { + "name": "signature_requests_status_ck", + "value": "\"signature_requests\".\"status\" IN ('en_attente', 'signe', 'refuse', 'annule')" + } + }, + "isRLSEnabled": false + }, + "public.skills": { + "name": "skills", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "skills_name_uq": { + "name": "skills_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"skills\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "skills_organization_id_organizations_id_fk": { + "name": "skills_organization_id_organizations_id_fk", + "tableFrom": "skills", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.social_posts": { + "name": "social_posts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "visual_id": { + "name": "visual_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "networks": { + "name": "networks", + "type": "text[]", + "primaryKey": false, + "notNull": true + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_mime": { + "name": "image_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "image_format": { + "name": "image_format", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_token": { + "name": "public_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external": { + "name": "external", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stats": { + "name": "stats", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "stats_at": { + "name": "stats_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "social_posts_cal_idx": { + "name": "social_posts_cal_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_due_idx": { + "name": "social_posts_due_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scheduled_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_source_uq": { + "name": "social_posts_source_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"social_posts\".\"source_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "social_posts_token_uq": { + "name": "social_posts_token_uq", + "columns": [ + { + "expression": "public_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "social_posts_organization_id_organizations_id_fk": { + "name": "social_posts_organization_id_organizations_id_fk", + "tableFrom": "social_posts", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_posts_establishment_id_establishments_id_fk": { + "name": "social_posts_establishment_id_establishments_id_fk", + "tableFrom": "social_posts", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_posts_visual_id_studio_visuals_id_fk": { + "name": "social_posts_visual_id_studio_visuals_id_fk", + "tableFrom": "social_posts", + "tableTo": "studio_visuals", + "columnsFrom": [ + "visual_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "social_posts_approved_by_users_id_fk": { + "name": "social_posts_approved_by_users_id_fk", + "tableFrom": "social_posts", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "social_posts_created_by_users_id_fk": { + "name": "social_posts_created_by_users_id_fk", + "tableFrom": "social_posts", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "social_posts_source_ck": { + "name": "social_posts_source_ck", + "value": "\"social_posts\".\"source\" IN ('manuel', 'menu_du_jour', 'evenement', 'fermeture', 'avis')" + }, + "social_posts_status_ck": { + "name": "social_posts_status_ck", + "value": "\"social_posts\".\"status\" IN ('a_valider', 'planifie', 'publie', 'partiel', 'echec', 'annule')" + }, + "social_posts_networks_ck": { + "name": "social_posts_networks_ck", + "value": "\"social_posts\".\"networks\" <@ ARRAY['instagram','facebook']::text[] AND cardinality(\"social_posts\".\"networks\") >= 1" + }, + "social_posts_image_ck": { + "name": "social_posts_image_ck", + "value": "(\"social_posts\".\"image\" IS NULL) = (\"social_posts\".\"image_mime\" IS NULL) AND (\"social_posts\".\"image_mime\" IS NULL OR \"social_posts\".\"image_mime\" = 'image/png')" + }, + "social_posts_format_ck": { + "name": "social_posts_format_ck", + "value": "\"social_posts\".\"image_format\" IS NULL OR \"social_posts\".\"image_format\" IN ('carre', 'portrait', 'facebook')" + }, + "social_posts_caption_ck": { + "name": "social_posts_caption_ck", + "value": "char_length(\"social_posts\".\"caption\") BETWEEN 1 AND 2200" + } + }, + "isRLSEnabled": false + }, + "public.social_settings": { + "name": "social_settings", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "networks": { + "name": "networks", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY['instagram','facebook']::text[]" + }, + "require_approval": { + "name": "require_approval", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "auto_menu": { + "name": "auto_menu", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "menu_time": { + "name": "menu_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'11:00'" + }, + "auto_events": { + "name": "auto_events", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "event_time": { + "name": "event_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'18:00'" + }, + "closure_days_before": { + "name": "closure_days_before", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "auto_reviews": { + "name": "auto_reviews", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "review_min_rating": { + "name": "review_min_rating", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 5 + }, + "review_time": { + "name": "review_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'17:30'" + }, + "hashtags": { + "name": "hashtags", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_posts_per_day": { + "name": "max_posts_per_day", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "repeat_days": { + "name": "repeat_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 14 + }, + "auto_best_times": { + "name": "auto_best_times", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "social_settings_org_idx": { + "name": "social_settings_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "social_settings_establishment_id_establishments_id_fk": { + "name": "social_settings_establishment_id_establishments_id_fk", + "tableFrom": "social_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_settings_organization_id_organizations_id_fk": { + "name": "social_settings_organization_id_organizations_id_fk", + "tableFrom": "social_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "social_settings_updated_by_users_id_fk": { + "name": "social_settings_updated_by_users_id_fk", + "tableFrom": "social_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "social_settings_repeat_ck": { + "name": "social_settings_repeat_ck", + "value": "\"social_settings\".\"max_posts_per_day\" BETWEEN 1 AND 5 AND \"social_settings\".\"repeat_days\" BETWEEN 0 AND 90" + }, + "social_settings_networks_ck": { + "name": "social_settings_networks_ck", + "value": "\"social_settings\".\"networks\" <@ ARRAY['instagram','facebook']::text[] AND cardinality(\"social_settings\".\"networks\") >= 1" + }, + "social_settings_times_ck": { + "name": "social_settings_times_ck", + "value": "\"social_settings\".\"menu_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"social_settings\".\"event_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$' AND \"social_settings\".\"review_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "social_settings_rating_ck": { + "name": "social_settings_rating_ck", + "value": "\"social_settings\".\"review_min_rating\" BETWEEN 4 AND 5" + }, + "social_settings_days_ck": { + "name": "social_settings_days_ck", + "value": "\"social_settings\".\"closure_days_before\" BETWEEN 0 AND 14" + } + }, + "isRLSEnabled": false + }, + "public.staff_meals": { + "name": "staff_meals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "meal_date": { + "name": "meal_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "service": { + "name": "service", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "employee_id": { + "name": "employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "beneficiary_name": { + "name": "beneficiary_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recipe_id": { + "name": "recipe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dish_label": { + "name": "dish_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "portions": { + "name": "portions", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'1'" + }, + "pricing": { + "name": "pricing", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "total_cost": { + "name": "total_cost", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "amount_paid": { + "name": "amount_paid", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "meal_value": { + "name": "meal_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "staff_meals_est_idx": { + "name": "staff_meals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "meal_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "staff_meals_emp_idx": { + "name": "staff_meals_emp_idx", + "columns": [ + { + "expression": "employee_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "meal_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "staff_meals_organization_id_organizations_id_fk": { + "name": "staff_meals_organization_id_organizations_id_fk", + "tableFrom": "staff_meals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "staff_meals_establishment_id_establishments_id_fk": { + "name": "staff_meals_establishment_id_establishments_id_fk", + "tableFrom": "staff_meals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "staff_meals_employee_id_employees_id_fk": { + "name": "staff_meals_employee_id_employees_id_fk", + "tableFrom": "staff_meals", + "tableTo": "employees", + "columnsFrom": [ + "employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "staff_meals_recipe_id_recipes_id_fk": { + "name": "staff_meals_recipe_id_recipes_id_fk", + "tableFrom": "staff_meals", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "staff_meals_created_by_users_id_fk": { + "name": "staff_meals_created_by_users_id_fk", + "tableFrom": "staff_meals", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_meals_cancelled_by_users_id_fk": { + "name": "staff_meals_cancelled_by_users_id_fk", + "tableFrom": "staff_meals", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "staff_meals_pricing_ck": { + "name": "staff_meals_pricing_ck", + "value": "\"staff_meals\".\"pricing\" IN ('offert', 'cout', 'prix_libre')" + }, + "staff_meals_beneficiary_ck": { + "name": "staff_meals_beneficiary_ck", + "value": "(\"staff_meals\".\"employee_id\" IS NULL) <> (\"staff_meals\".\"beneficiary_name\" IS NULL)" + }, + "staff_meals_amounts_ck": { + "name": "staff_meals_amounts_ck", + "value": "\"staff_meals\".\"portions\" > 0 AND \"staff_meals\".\"portions\" <= 20 AND \"staff_meals\".\"amount_paid\" >= 0 AND (\"staff_meals\".\"pricing\" <> 'offert' OR \"staff_meals\".\"amount_paid\" = 0)" + }, + "staff_meals_service_ck": { + "name": "staff_meals_service_ck", + "value": "\"staff_meals\".\"service\" IS NULL OR \"staff_meals\".\"service\" IN ('midi', 'soir')" + } + }, + "isRLSEnabled": false + }, + "public.stock_expiry_lots": { + "name": "stock_expiry_lots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_on": { + "name": "expires_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "received_on": { + "name": "received_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_line_id": { + "name": "order_line_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "closed_reason": { + "name": "closed_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "closed_by": { + "name": "closed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "loss_id": { + "name": "loss_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_expiry_lots_loss_idx": { + "name": "stock_expiry_lots_loss_idx", + "columns": [ + { + "expression": "loss_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"stock_expiry_lots\".\"loss_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_expiry_lots_open_idx": { + "name": "stock_expiry_lots_open_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_on", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"stock_expiry_lots\".\"closed_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_expiry_lots_item_idx": { + "name": "stock_expiry_lots_item_idx", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_expiry_lots_organization_id_organizations_id_fk": { + "name": "stock_expiry_lots_organization_id_organizations_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_establishment_id_establishments_id_fk": { + "name": "stock_expiry_lots_establishment_id_establishments_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_item_id_purchase_items_id_fk": { + "name": "stock_expiry_lots_item_id_purchase_items_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_expiry_lots_order_line_id_purchase_order_lines_id_fk": { + "name": "stock_expiry_lots_order_line_id_purchase_order_lines_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "purchase_order_lines", + "columnsFrom": [ + "order_line_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "stock_expiry_lots_closed_by_users_id_fk": { + "name": "stock_expiry_lots_closed_by_users_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "users", + "columnsFrom": [ + "closed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_expiry_lots_loss_id_stock_losses_id_fk": { + "name": "stock_expiry_lots_loss_id_stock_losses_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "stock_losses", + "columnsFrom": [ + "loss_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "stock_expiry_lots_created_by_users_id_fk": { + "name": "stock_expiry_lots_created_by_users_id_fk", + "tableFrom": "stock_expiry_lots", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_expiry_lots_kind_ck": { + "name": "stock_expiry_lots_kind_ck", + "value": "\"stock_expiry_lots\".\"kind\" IN ('dlc', 'ddm')" + }, + "stock_expiry_lots_qty_ck": { + "name": "stock_expiry_lots_qty_ck", + "value": "\"stock_expiry_lots\".\"quantity\" > 0" + }, + "stock_expiry_lots_close_ck": { + "name": "stock_expiry_lots_close_ck", + "value": "(\"stock_expiry_lots\".\"closed_at\" IS NULL) = (\"stock_expiry_lots\".\"closed_reason\" IS NULL) AND (\"stock_expiry_lots\".\"closed_reason\" IS NULL OR \"stock_expiry_lots\".\"closed_reason\" IN ('ecoule', 'perte', 'retour', 'erreur'))" + } + }, + "isRLSEnabled": false + }, + "public.stock_losses": { + "name": "stock_losses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "loss_date": { + "name": "loss_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credit_request_id": { + "name": "credit_request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_losses_est_idx": { + "name": "stock_losses_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "loss_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_losses_organization_id_organizations_id_fk": { + "name": "stock_losses_organization_id_organizations_id_fk", + "tableFrom": "stock_losses", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_losses_establishment_id_establishments_id_fk": { + "name": "stock_losses_establishment_id_establishments_id_fk", + "tableFrom": "stock_losses", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_losses_item_id_purchase_items_id_fk": { + "name": "stock_losses_item_id_purchase_items_id_fk", + "tableFrom": "stock_losses", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_losses_created_by_users_id_fk": { + "name": "stock_losses_created_by_users_id_fk", + "tableFrom": "stock_losses", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_losses_cancelled_by_users_id_fk": { + "name": "stock_losses_cancelled_by_users_id_fk", + "tableFrom": "stock_losses", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_losses_credit_request_id_credit_requests_id_fk": { + "name": "stock_losses_credit_request_id_credit_requests_id_fk", + "tableFrom": "stock_losses", + "tableTo": "credit_requests", + "columnsFrom": [ + "credit_request_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_losses_qty_ck": { + "name": "stock_losses_qty_ck", + "value": "\"stock_losses\".\"quantity\" > 0" + }, + "stock_losses_reason_ck": { + "name": "stock_losses_reason_ck", + "value": "\"stock_losses\".\"reason\" IN ('peremption', 'casse', 'erreur_production', 'retour_client', 'repas_personnel', 'offert', 'vol', 'retour_fournisseur', 'autre')" + } + }, + "isRLSEnabled": false + }, + "public.stock_rotation_settings": { + "name": "stock_rotation_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "overstock_days": { + "name": "overstock_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "lookback_days": { + "name": "lookback_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 28 + }, + "level_basis": { + "name": "level_basis", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'compte'" + }, + "expiry_alert_days": { + "name": "expiry_alert_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_rotation_settings_est_uq": { + "name": "stock_rotation_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_rotation_settings_organization_id_organizations_id_fk": { + "name": "stock_rotation_settings_organization_id_organizations_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_rotation_settings_establishment_id_establishments_id_fk": { + "name": "stock_rotation_settings_establishment_id_establishments_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_rotation_settings_updated_by_users_id_fk": { + "name": "stock_rotation_settings_updated_by_users_id_fk", + "tableFrom": "stock_rotation_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_rotation_overstock_ck": { + "name": "stock_rotation_overstock_ck", + "value": "\"stock_rotation_settings\".\"overstock_days\" IS NULL OR \"stock_rotation_settings\".\"overstock_days\" BETWEEN 1 AND 365" + }, + "stock_rotation_lookback_ck": { + "name": "stock_rotation_lookback_ck", + "value": "\"stock_rotation_settings\".\"lookback_days\" BETWEEN 7 AND 365" + }, + "stock_rotation_basis_ck": { + "name": "stock_rotation_basis_ck", + "value": "\"stock_rotation_settings\".\"level_basis\" IN ('compte', 'theorique')" + }, + "stock_rotation_expiry_ck": { + "name": "stock_rotation_expiry_ck", + "value": "\"stock_rotation_settings\".\"expiry_alert_days\" BETWEEN 0 AND 30" + } + }, + "isRLSEnabled": false + }, + "public.stock_transfer_lines": { + "name": "stock_transfer_lines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "transfer_id": { + "name": "transfer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "unit_cost": { + "name": "unit_cost", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_transfer_lines_item_uq": { + "name": "stock_transfer_lines_item_uq", + "columns": [ + { + "expression": "transfer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfer_lines_item_idx": { + "name": "stock_transfer_lines_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_transfer_lines_organization_id_organizations_id_fk": { + "name": "stock_transfer_lines_organization_id_organizations_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfer_lines_transfer_id_stock_transfers_id_fk": { + "name": "stock_transfer_lines_transfer_id_stock_transfers_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "stock_transfers", + "columnsFrom": [ + "transfer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfer_lines_item_id_purchase_items_id_fk": { + "name": "stock_transfer_lines_item_id_purchase_items_id_fk", + "tableFrom": "stock_transfer_lines", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_transfer_lines_ck": { + "name": "stock_transfer_lines_ck", + "value": "\"stock_transfer_lines\".\"quantity\" > 0 AND \"stock_transfer_lines\".\"unit_cost\" >= 0" + } + }, + "isRLSEnabled": false + }, + "public.stock_transfers": { + "name": "stock_transfers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "from_establishment_id": { + "name": "from_establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_establishment_id": { + "name": "to_establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "number": { + "name": "number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "transfer_date": { + "name": "transfer_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_value": { + "name": "total_value", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "stock_transfers_number_uq": { + "name": "stock_transfers_number_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfers_from_idx": { + "name": "stock_transfers_from_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "from_establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "transfer_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "stock_transfers_to_idx": { + "name": "stock_transfers_to_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "to_establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "transfer_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stock_transfers_organization_id_organizations_id_fk": { + "name": "stock_transfers_organization_id_organizations_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stock_transfers_from_establishment_id_establishments_id_fk": { + "name": "stock_transfers_from_establishment_id_establishments_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "establishments", + "columnsFrom": [ + "from_establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_transfers_to_establishment_id_establishments_id_fk": { + "name": "stock_transfers_to_establishment_id_establishments_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "establishments", + "columnsFrom": [ + "to_establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "stock_transfers_created_by_users_id_fk": { + "name": "stock_transfers_created_by_users_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stock_transfers_cancelled_by_users_id_fk": { + "name": "stock_transfers_cancelled_by_users_id_fk", + "tableFrom": "stock_transfers", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "stock_transfers_distinct_ck": { + "name": "stock_transfers_distinct_ck", + "value": "\"stock_transfers\".\"from_establishment_id\" <> \"stock_transfers\".\"to_establishment_id\"" + } + }, + "isRLSEnabled": false + }, + "public.studio_brands": { + "name": "studio_brands", + "schema": "", + "columns": { + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "handle": { + "name": "handle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact": { + "name": "contact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "background": { + "name": "background", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#1f2a24'" + }, + "primary": { + "name": "primary", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#d9a441'" + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#fbf7ee'" + }, + "font": { + "name": "font", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'classique'" + }, + "logo_mime": { + "name": "logo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo": { + "name": "logo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "studio_brands_org_idx": { + "name": "studio_brands_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "studio_brands_establishment_id_establishments_id_fk": { + "name": "studio_brands_establishment_id_establishments_id_fk", + "tableFrom": "studio_brands", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_brands_organization_id_organizations_id_fk": { + "name": "studio_brands_organization_id_organizations_id_fk", + "tableFrom": "studio_brands", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_brands_updated_by_users_id_fk": { + "name": "studio_brands_updated_by_users_id_fk", + "tableFrom": "studio_brands", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "studio_brands_colors_ck": { + "name": "studio_brands_colors_ck", + "value": "\"studio_brands\".\"background\" ~ '^#[0-9a-f]{6}$' AND \"studio_brands\".\"primary\" ~ '^#[0-9a-f]{6}$' AND \"studio_brands\".\"text\" ~ '^#[0-9a-f]{6}$'" + }, + "studio_brands_font_ck": { + "name": "studio_brands_font_ck", + "value": "\"studio_brands\".\"font\" IN ('classique', 'moderne', 'elegant')" + }, + "studio_brands_logo_ck": { + "name": "studio_brands_logo_ck", + "value": "(\"studio_brands\".\"logo\" IS NULL) = (\"studio_brands\".\"logo_mime\" IS NULL) AND (\"studio_brands\".\"logo_mime\" IS NULL OR \"studio_brands\".\"logo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + } + }, + "isRLSEnabled": false + }, + "public.studio_visuals": { + "name": "studio_visuals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "studio_visuals_est_idx": { + "name": "studio_visuals_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "studio_visuals_organization_id_organizations_id_fk": { + "name": "studio_visuals_organization_id_organizations_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_visuals_establishment_id_establishments_id_fk": { + "name": "studio_visuals_establishment_id_establishments_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "studio_visuals_created_by_users_id_fk": { + "name": "studio_visuals_created_by_users_id_fk", + "tableFrom": "studio_visuals", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "studio_visuals_template_ck": { + "name": "studio_visuals_template_ck", + "value": "\"studio_visuals\".\"template\" IN ('menu_du_jour', 'plat', 'evenement', 'avis')" + }, + "studio_visuals_format_ck": { + "name": "studio_visuals_format_ck", + "value": "\"studio_visuals\".\"format\" IN ('carre', 'portrait', 'story', 'facebook')" + }, + "studio_visuals_photo_ck": { + "name": "studio_visuals_photo_ck", + "value": "(\"studio_visuals\".\"photo\" IS NULL) = (\"studio_visuals\".\"photo_mime\" IS NULL) AND (\"studio_visuals\".\"photo_mime\" IS NULL OR \"studio_visuals\".\"photo_mime\" IN ('image/jpeg', 'image/png', 'image/webp'))" + } + }, + "isRLSEnabled": false + }, + "public.supplier_offer_prices": { + "name": "supplier_offer_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "offer_id": { + "name": "offer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "price_ht": { + "name": "price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "content_quantity": { + "name": "content_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "content_unit": { + "name": "content_unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_date": { + "name": "effective_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_offer_prices_offer_idx": { + "name": "supplier_offer_prices_offer_idx", + "columns": [ + { + "expression": "offer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "effective_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_offer_prices_organization_id_organizations_id_fk": { + "name": "supplier_offer_prices_organization_id_organizations_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offer_prices_offer_id_supplier_offers_id_fk": { + "name": "supplier_offer_prices_offer_id_supplier_offers_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "supplier_offers", + "columnsFrom": [ + "offer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offer_prices_created_by_users_id_fk": { + "name": "supplier_offer_prices_created_by_users_id_fk", + "tableFrom": "supplier_offer_prices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "supplier_offer_prices_source_ck": { + "name": "supplier_offer_prices_source_ck", + "value": "\"supplier_offer_prices\".\"source\" IN ('manual', 'import', 'migration', 'demande_prix')" + }, + "supplier_offer_prices_price_ck": { + "name": "supplier_offer_prices_price_ck", + "value": "\"supplier_offer_prices\".\"price_ht\" >= 0 AND \"supplier_offer_prices\".\"content_quantity\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.supplier_offers": { + "name": "supplier_offers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_id": { + "name": "supplier_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supplier_ref": { + "name": "supplier_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_ht": { + "name": "price_ht", + "type": "numeric(19, 6)", + "primaryKey": false, + "notNull": true + }, + "content_quantity": { + "name": "content_quantity", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": true + }, + "content_unit": { + "name": "content_unit", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price_date": { + "name": "price_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'manual'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_offers_item_idx": { + "name": "supplier_offers_item_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "supplier_offers_supplier_idx": { + "name": "supplier_offers_supplier_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "supplier_offers_active_uq": { + "name": "supplier_offers_active_uq", + "columns": [ + { + "expression": "item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "supplier_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(coalesce(\"supplier_ref\", ''))", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"supplier_offers\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_offers_organization_id_organizations_id_fk": { + "name": "supplier_offers_organization_id_organizations_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offers_item_id_purchase_items_id_fk": { + "name": "supplier_offers_item_id_purchase_items_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_offers_supplier_id_suppliers_id_fk": { + "name": "supplier_offers_supplier_id_suppliers_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "suppliers", + "columnsFrom": [ + "supplier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "supplier_offers_created_by_users_id_fk": { + "name": "supplier_offers_created_by_users_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "supplier_offers_updated_by_users_id_fk": { + "name": "supplier_offers_updated_by_users_id_fk", + "tableFrom": "supplier_offers", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "supplier_offers_price_ck": { + "name": "supplier_offers_price_ck", + "value": "\"supplier_offers\".\"price_ht\" >= 0 AND \"supplier_offers\".\"content_quantity\" > 0" + }, + "supplier_offers_unit_ck": { + "name": "supplier_offers_unit_ck", + "value": "\"supplier_offers\".\"content_unit\" IN ('kg', 'g', 'L', 'cl', 'pi\u00e8ce', 'botte', 'carton', 'colis', 'bouteille', 'f\u00fbt', 'lot', 'heure', 'forfait')" + }, + "supplier_offers_source_ck": { + "name": "supplier_offers_source_ck", + "value": "\"supplier_offers\".\"source\" IN ('manual', 'import', 'migration', 'demande_prix')" + } + }, + "isRLSEnabled": false + }, + "public.supplier_order_reminders": { + "name": "supplier_order_reminders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "suppliers": { + "name": "suppliers", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "supplier_order_reminders_uq": { + "name": "supplier_order_reminders_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "supplier_order_reminders_organization_id_organizations_id_fk": { + "name": "supplier_order_reminders_organization_id_organizations_id_fk", + "tableFrom": "supplier_order_reminders", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "supplier_order_reminders_establishment_id_establishments_id_fk": { + "name": "supplier_order_reminders_establishment_id_establishments_id_fk", + "tableFrom": "supplier_order_reminders", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.suppliers": { + "name": "suppliers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "siret": { + "name": "siret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_number": { + "name": "vat_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address_line": { + "name": "address_line", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payment_terms_days": { + "name": "payment_terms_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "default_category": { + "name": "default_category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'food'" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "min_order_ht": { + "name": "min_order_ht", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "order_cutoff": { + "name": "order_cutoff", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lead_time_days": { + "name": "lead_time_days", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "delivery_days": { + "name": "delivery_days", + "type": "integer[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::integer[]" + }, + "delivery_fee_mode": { + "name": "delivery_fee_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "delivery_fee_fixed": { + "name": "delivery_fee_fixed", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_percent": { + "name": "delivery_fee_percent", + "type": "numeric(7, 4)", + "primaryKey": false, + "notNull": false + }, + "delivery_fee_tiers": { + "name": "delivery_fee_tiers", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "suppliers_org_idx": { + "name": "suppliers_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "suppliers_org_name_uq": { + "name": "suppliers_org_name_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"name\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "suppliers_organization_id_organizations_id_fk": { + "name": "suppliers_organization_id_organizations_id_fk", + "tableFrom": "suppliers", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "suppliers_created_by_users_id_fk": { + "name": "suppliers_created_by_users_id_fk", + "tableFrom": "suppliers", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "suppliers_fee_mode_ck": { + "name": "suppliers_fee_mode_ck", + "value": "\"suppliers\".\"delivery_fee_mode\" IN ('none', 'fixed', 'tiers', 'percent')" + }, + "suppliers_delivery_days_ck": { + "name": "suppliers_delivery_days_ck", + "value": "\"suppliers\".\"delivery_days\" <@ ARRAY[1,2,3,4,5,6,7]" + }, + "suppliers_cutoff_ck": { + "name": "suppliers_cutoff_ck", + "value": "\"suppliers\".\"order_cutoff\" IS NULL OR \"suppliers\".\"order_cutoff\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "suppliers_siret_ck": { + "name": "suppliers_siret_ck", + "value": "\"suppliers\".\"siret\" IS NULL OR \"suppliers\".\"siret\" ~ '^[0-9]{14}$'" + }, + "suppliers_terms_ck": { + "name": "suppliers_terms_ck", + "value": "\"suppliers\".\"payment_terms_days\" IS NULL OR (\"suppliers\".\"payment_terms_days\" >= 0 AND \"suppliers\".\"payment_terms_days\" <= 365)" + } + }, + "isRLSEnabled": false + }, + "public.tablet_devices": { + "name": "tablet_devices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo_on_punch": { + "name": "photo_on_punch", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "pairing_code_hash": { + "name": "pairing_code_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pairing_expires_at": { + "name": "pairing_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "paired_at": { + "name": "paired_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "operator_employee_id": { + "name": "operator_employee_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "operator_token_hash": { + "name": "operator_token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "operator_until": { + "name": "operator_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tablet_devices_org_idx": { + "name": "tablet_devices_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tablet_devices_token_uq": { + "name": "tablet_devices_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tablet_devices_pairing_uq": { + "name": "tablet_devices_pairing_uq", + "columns": [ + { + "expression": "pairing_code_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tablet_devices_organization_id_organizations_id_fk": { + "name": "tablet_devices_organization_id_organizations_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tablet_devices_establishment_id_establishments_id_fk": { + "name": "tablet_devices_establishment_id_establishments_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tablet_devices_operator_employee_id_employees_id_fk": { + "name": "tablet_devices_operator_employee_id_employees_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "employees", + "columnsFrom": [ + "operator_employee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "tablet_devices_created_by_users_id_fk": { + "name": "tablet_devices_created_by_users_id_fk", + "tableFrom": "tablet_devices", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "tablet_devices_mode_ck": { + "name": "tablet_devices_mode_ck", + "value": "\"tablet_devices\".\"mode\" IN ('pointeuse', 'haccp')" + } + }, + "isRLSEnabled": false + }, + "public.task_completions": { + "name": "task_completions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "occurrence": { + "name": "occurrence", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "done_at": { + "name": "done_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "done_by": { + "name": "done_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "task_completions_est_idx": { + "name": "task_completions_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "task_completions_once_uq": { + "name": "task_completions_once_uq", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurrence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"task_completions\".\"cancelled_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_completions_organization_id_organizations_id_fk": { + "name": "task_completions_organization_id_organizations_id_fk", + "tableFrom": "task_completions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_completions_establishment_id_establishments_id_fk": { + "name": "task_completions_establishment_id_establishments_id_fk", + "tableFrom": "task_completions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_completions_task_id_task_definitions_id_fk": { + "name": "task_completions_task_id_task_definitions_id_fk", + "tableFrom": "task_completions", + "tableTo": "task_definitions", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_completions_done_by_users_id_fk": { + "name": "task_completions_done_by_users_id_fk", + "tableFrom": "task_completions", + "tableTo": "users", + "columnsFrom": [ + "done_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "task_completions_cancelled_by_users_id_fk": { + "name": "task_completions_cancelled_by_users_id_fk", + "tableFrom": "task_completions", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_definitions": { + "name": "task_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "instructions": { + "name": "instructions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'autre'" + }, + "frequency": { + "name": "frequency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weekdays": { + "name": "weekdays", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "month_day": { + "name": "month_day", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "once_date": { + "name": "once_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "due_time": { + "name": "due_time", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_required": { + "name": "photo_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "starts_on": { + "name": "starts_on", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "task_definitions_est_idx": { + "name": "task_definitions_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_definitions_organization_id_organizations_id_fk": { + "name": "task_definitions_organization_id_organizations_id_fk", + "tableFrom": "task_definitions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_definitions_establishment_id_establishments_id_fk": { + "name": "task_definitions_establishment_id_establishments_id_fk", + "tableFrom": "task_definitions", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "task_definitions_assignee_user_id_users_id_fk": { + "name": "task_definitions_assignee_user_id_users_id_fk", + "tableFrom": "task_definitions", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "task_definitions_created_by_users_id_fk": { + "name": "task_definitions_created_by_users_id_fk", + "tableFrom": "task_definitions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "task_definitions_freq_ck": { + "name": "task_definitions_freq_ck", + "value": "\"task_definitions\".\"frequency\" IN ('once', 'daily', 'weekly', 'monthly')" + }, + "task_definitions_due_ck": { + "name": "task_definitions_due_ck", + "value": "\"task_definitions\".\"due_time\" IS NULL OR \"task_definitions\".\"due_time\" ~ '^([01][0-9]|2[0-3]):[0-5][0-9]$'" + }, + "task_definitions_month_ck": { + "name": "task_definitions_month_ck", + "value": "\"task_definitions\".\"month_day\" IS NULL OR \"task_definitions\".\"month_day\" BETWEEN 1 AND 31" + } + }, + "isRLSEnabled": false + }, + "public.temperature_readings": { + "name": "temperature_readings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "temperature": { + "name": "temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": true + }, + "temp_min": { + "name": "temp_min", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "temp_max": { + "name": "temp_max", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "conform": { + "name": "conform", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "corrective_action": { + "name": "corrective_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sensor_id": { + "name": "sensor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "client_ref": { + "name": "client_ref", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "entered_offline": { + "name": "entered_offline", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "temperature_readings_est_idx": { + "name": "temperature_readings_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_readings_eq_idx": { + "name": "temperature_readings_eq_idx", + "columns": [ + { + "expression": "equipment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_readings_sensor_idx": { + "name": "temperature_readings_sensor_idx", + "columns": [ + { + "expression": "sensor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_readings_client_ref_uq": { + "name": "temperature_readings_client_ref_uq", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "client_ref", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"temperature_readings\".\"client_ref\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "temperature_readings_organization_id_organizations_id_fk": { + "name": "temperature_readings_organization_id_organizations_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "temperature_readings_establishment_id_establishments_id_fk": { + "name": "temperature_readings_establishment_id_establishments_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_equipment_id_equipment_id_fk": { + "name": "temperature_readings_equipment_id_equipment_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_recorded_by_users_id_fk": { + "name": "temperature_readings_recorded_by_users_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "temperature_readings_sensor_id_temperature_sensors_id_fk": { + "name": "temperature_readings_sensor_id_temperature_sensors_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "temperature_sensors", + "columnsFrom": [ + "sensor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_readings_cancelled_by_users_id_fk": { + "name": "temperature_readings_cancelled_by_users_id_fk", + "tableFrom": "temperature_readings", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "temperature_readings_action_ck": { + "name": "temperature_readings_action_ck", + "value": "\"temperature_readings\".\"conform\" OR \"temperature_readings\".\"corrective_action\" IS NOT NULL OR \"temperature_readings\".\"sensor_id\" IS NOT NULL" + }, + "temperature_readings_author_ck": { + "name": "temperature_readings_author_ck", + "value": "\"temperature_readings\".\"recorded_by\" IS NOT NULL OR \"temperature_readings\".\"sensor_id\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.temperature_sensors": { + "name": "temperature_sensors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "equipment_id": { + "name": "equipment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hint": { + "name": "token_hint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "keep_every_minutes": { + "name": "keep_every_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 15 + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_temperature": { + "name": "last_temperature", + "type": "numeric(5, 1)", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "temperature_sensors_token_uq": { + "name": "temperature_sensors_token_uq", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "temperature_sensors_est_idx": { + "name": "temperature_sensors_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "temperature_sensors_organization_id_organizations_id_fk": { + "name": "temperature_sensors_organization_id_organizations_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "temperature_sensors_establishment_id_establishments_id_fk": { + "name": "temperature_sensors_establishment_id_establishments_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_sensors_equipment_id_equipment_id_fk": { + "name": "temperature_sensors_equipment_id_equipment_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "equipment", + "columnsFrom": [ + "equipment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "temperature_sensors_created_by_users_id_fk": { + "name": "temperature_sensors_created_by_users_id_fk", + "tableFrom": "temperature_sensors", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "temperature_sensors_keep_ck": { + "name": "temperature_sensors_keep_ck", + "value": "\"temperature_sensors\".\"keep_every_minutes\" BETWEEN 1 AND 240" + } + }, + "isRLSEnabled": false + }, + "public.trace_labels": { + "name": "trace_labels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "taken_at": { + "name": "taken_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "photo": { + "name": "photo", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "photo_mime": { + "name": "photo_mime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_size": { + "name": "photo_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "item_id": { + "name": "item_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "product_label": { + "name": "product_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplier_name": { + "name": "supplier_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dlc": { + "name": "dlc", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "usage": { + "name": "usage", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allergens": { + "name": "allergens", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "production_name": { + "name": "production_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "trace_labels_est_idx": { + "name": "trace_labels_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "taken_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "trace_labels_organization_id_organizations_id_fk": { + "name": "trace_labels_organization_id_organizations_id_fk", + "tableFrom": "trace_labels", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "trace_labels_establishment_id_establishments_id_fk": { + "name": "trace_labels_establishment_id_establishments_id_fk", + "tableFrom": "trace_labels", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "trace_labels_item_id_purchase_items_id_fk": { + "name": "trace_labels_item_id_purchase_items_id_fk", + "tableFrom": "trace_labels", + "tableTo": "purchase_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "trace_labels_recorded_by_users_id_fk": { + "name": "trace_labels_recorded_by_users_id_fk", + "tableFrom": "trace_labels", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "trace_labels_cancelled_by_users_id_fk": { + "name": "trace_labels_cancelled_by_users_id_fk", + "tableFrom": "trace_labels", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "trace_labels_usage_ck": { + "name": "trace_labels_usage_ck", + "value": "\"trace_labels\".\"usage\" IN ('reception', 'ouverture', 'production')" + }, + "trace_labels_size_ck": { + "name": "trace_labels_size_ck", + "value": "\"trace_labels\".\"photo_size\" IS NULL OR \"trace_labels\".\"photo_size\" <= 5242880" + } + }, + "isRLSEnabled": false + }, + "public.treasury_settings": { + "name": "treasury_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "vat_regime": { + "name": "vat_regime", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vat_due_day": { + "name": "vat_due_day", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "alert_threshold": { + "name": "alert_threshold", + "type": "numeric(19, 4)", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "treasury_settings_est_uq": { + "name": "treasury_settings_est_uq", + "columns": [ + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "treasury_settings_organization_id_organizations_id_fk": { + "name": "treasury_settings_organization_id_organizations_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "treasury_settings_establishment_id_establishments_id_fk": { + "name": "treasury_settings_establishment_id_establishments_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "treasury_settings_updated_by_users_id_fk": { + "name": "treasury_settings_updated_by_users_id_fk", + "tableFrom": "treasury_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "treasury_settings_vat_ck": { + "name": "treasury_settings_vat_ck", + "value": "(\"treasury_settings\".\"vat_regime\" IS NULL OR \"treasury_settings\".\"vat_regime\" IN ('monthly', 'quarterly')) AND (\"treasury_settings\".\"vat_due_day\" IS NULL OR \"treasury_settings\".\"vat_due_day\" BETWEEN 1 AND 31)" + } + }, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "totp_secret_enc": { + "name": "totp_secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "totp_enabled_at": { + "name": "totp_enabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "totp_last_step": { + "name": "totp_last_step", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "password_changed_at": { + "name": "password_changed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "failed_login_count": { + "name": "failed_login_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "disabled_at": { + "name": "disabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "message_emails": { + "name": "message_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notification_phone": { + "name": "notification_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seen_release": { + "name": "seen_release", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_login_at": { + "name": "last_login_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "platform_admin": { + "name": "platform_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "email_verification_pending": { + "name": "email_verification_pending", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by_organization_id": { + "name": "created_by_organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_lower_uq": { + "name": "users_email_lower_uq", + "columns": [ + { + "expression": "lower(\"email\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_created_by_organization_id_organizations_id_fk": { + "name": "users_created_by_organization_id_organizations_id_fk", + "tableFrom": "users", + "tableTo": "organizations", + "columnsFrom": [ + "created_by_organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.waiter_closings": { + "name": "waiter_closings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "establishment_id": { + "name": "establishment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "business_day": { + "name": "business_day", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "waiter_label": { + "name": "waiter_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "waiter_key": { + "name": "waiter_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "groupe": { + "name": "groupe", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "cb": { + "name": "cb", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "especes": { + "name": "especes", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "autre": { + "name": "autre", + "type": "numeric(12, 2)", + "primaryKey": false, + "notNull": true + }, + "recorded_by": { + "name": "recorded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recorded_at": { + "name": "recorded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_by": { + "name": "cancelled_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "waiter_closings_est_idx": { + "name": "waiter_closings_est_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "establishment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "business_day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "waiter_closings_organization_id_organizations_id_fk": { + "name": "waiter_closings_organization_id_organizations_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "waiter_closings_establishment_id_establishments_id_fk": { + "name": "waiter_closings_establishment_id_establishments_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "establishments", + "columnsFrom": [ + "establishment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "waiter_closings_recorded_by_users_id_fk": { + "name": "waiter_closings_recorded_by_users_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "users", + "columnsFrom": [ + "recorded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "waiter_closings_cancelled_by_users_id_fk": { + "name": "waiter_closings_cancelled_by_users_id_fk", + "tableFrom": "waiter_closings", + "tableTo": "users", + "columnsFrom": [ + "cancelled_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "waiter_closings_amounts_ck": { + "name": "waiter_closings_amounts_ck", + "value": "\"waiter_closings\".\"groupe\" >= 0 AND \"waiter_closings\".\"cb\" >= 0 AND \"waiter_closings\".\"especes\" >= 0 AND \"waiter_closings\".\"autre\" >= 0" + }, + "waiter_closings_key_ck": { + "name": "waiter_closings_key_ck", + "value": "length(\"waiter_closings\".\"waiter_key\") BETWEEN 1 AND 120" + } + }, + "isRLSEnabled": false + } + }, + "enums": { + "public.connection_status": { + "name": "connection_status", + "schema": "public", + "values": [ + "not_configured", + "pending_verification", + "connected", + "error", + "disabled" + ] + }, + "public.data_status": { + "name": "data_status", + "schema": "public", + "values": [ + "real_validated", + "real_unvalidated", + "provisional", + "estimated", + "forecast", + "missing" + ] + }, + "public.import_status": { + "name": "import_status", + "schema": "public", + "values": [ + "completed", + "rejected", + "reverted" + ] + }, + "public.member_role": { + "name": "member_role", + "schema": "public", + "values": [ + "owner", + "admin", + "director", + "manager", + "accountant", + "chef", + "staff", + "cuisine", + "viewer", + "rh", + "controller", + "purchasing" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index c9430745..5d401523 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -869,6 +869,34 @@ "when": 1796132436678, "tag": "0123_automatisations_avancees", "breakpoints": true + }, + { + "idx": 124, + "version": "7", + "when": 1796138120998, + "tag": "0124_reponses_mail", + "breakpoints": true + }, + { + "idx": 125, + "version": "7", + "when": 1796138180998, + "tag": "0125_etiquettes_repas_personnel", + "breakpoints": true + }, + { + "idx": 126, + "version": "7", + "when": 1796142764729, + "tag": "0126_formules_commandes_annulation", + "breakpoints": true + }, + { + "idx": 127, + "version": "7", + "when": 1796143692919, + "tag": "0127_hygiene_rappels_nuisibles", + "breakpoints": true } ] } \ No newline at end of file diff --git a/package.json b/package.json index 4230820a..719b5695 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "altair", - "version": "0.168.0", + "version": "0.172.0", "private": true, "description": "ALTAIR Restaurant Operating System — Tout voir. Tout comprendre. Tout anticiper.", "engines": { diff --git a/src/app/(app)/achats/actions.ts b/src/app/(app)/achats/actions.ts index 0fd15856..322a03d5 100644 --- a/src/app/(app)/achats/actions.ts +++ b/src/app/(app)/achats/actions.ts @@ -29,7 +29,7 @@ const SUPPLIER_FIELDS = ["name", "siret", "vatNumber", "contactName", "email", " "minOrderHt", "orderCutoff", "leadTimeDays", "deliveryFeeMode", "deliveryFeeFixed", "deliveryFeePercent"] as const; const supplierValues = (f: FormData) => { const from = f.getAll("tierFrom").map(String), fee = f.getAll("tierFee").map(String); - return { ...Object.fromEntries(SUPPLIER_FIELDS.map((k) => [k, String(f.get(k) ?? "")])), deliveryFeeTiers: from.map((v, i) => ({ from: v, fee: fee[i] ?? "" })) }; + return { ...Object.fromEntries(SUPPLIER_FIELDS.map((k) => [k, String(f.get(k) ?? "")])), deliveryFeeTiers: from.map((v, i) => ({ from: v, fee: fee[i] ?? "" })), deliveryDays: f.getAll("deliveryDays").map(String) }; }; export async function createSupplierAction(_p: ActionState, f: FormData): Promise { diff --git a/src/app/(app)/achats/commandes/actions.ts b/src/app/(app)/achats/commandes/actions.ts index deb17da6..bbb65e8b 100644 --- a/src/app/(app)/achats/commandes/actions.ts +++ b/src/app/(app)/achats/commandes/actions.ts @@ -6,6 +6,7 @@ import { requirePage } from "@/lib/auth/session"; import { PermissionDeniedError } from "@/lib/auth/permissions"; import { FinancialInputError } from "@/lib/finance"; import { SupplierControlError, acknowledgeSupplierGaps, scanDeliveryNote } from "@/lib/services/supplier-control"; +import { prepareOrderFromPlan } from "@/lib/services/order-planning"; import { OrderError, cancelOrder, confirmOrder, createOrder, deleteDraftOrder, receiveOrder, reorderOrder, saveOrderDraft, sendOrder, type OrderLinesInput, type ReceptionInput } from "@/lib/services/orders"; export type OrderState = { status: "idle" | "success" | "error"; message: string | null }; @@ -111,3 +112,12 @@ export async function acknowledgeSupplierGapsAction(f: FormData): Promise await acknowledgeSupplierGaps(s.ctx, str(f, "id")); revalidatePath("/", "layout"); } + +/** Commandes du jour (v0.171) : brouillon prérempli avec les quantités proposées, ouvert pour relecture. */ +export async function prepareFromPlanAction(_p: OrderState, f: FormData): Promise { + const s = await requirePage("purchases.manage"); + let id: string; + try { id = (await prepareOrderFromPlan(s.ctx, str(f, "establishmentId"), str(f, "supplierId"))).id; } catch (e) { return toError(e); } + revalidatePath("/achats/commandes", "layout"); + redirect(`/achats/commandes/${id}`); +} diff --git a/src/app/(app)/achats/commandes/du-jour/page.tsx b/src/app/(app)/achats/commandes/du-jour/page.tsx new file mode 100644 index 00000000..c7cccb11 --- /dev/null +++ b/src/app/(app)/achats/commandes/du-jour/page.tsx @@ -0,0 +1,122 @@ +import type { Metadata } from "next"; +import Link from "next/link"; +import { requirePage } from "@/lib/auth/session"; +import { hasPermission } from "@/lib/auth/permissions"; +import { D, Money, formatEUR } from "@/lib/finance"; +import { WEEKDAYS, weekdayLabel } from "@/lib/purchasing/order-day"; +import { orderPlan, ORDER_FORECAST_WINDOW_DAYS, type SupplierPlan } from "@/lib/services/order-planning"; +import { ActionForm } from "@/components/ui/action-form"; +import { Alert, Badge, Card, EmptyState, PageHeader, Select, buttonClass, tableClass } from "@/components/ui/primitives"; +import { loadScope } from "../../../scope-data"; +import { prepareFromPlanAction } from "../actions"; + +export const metadata: Metadata = { title: "Commandes du jour" }; +const fr = (iso: string | null) => (iso ? `${weekdayLabel(iso)} ${iso.split("-").reverse().slice(0, 2).join("/")}` : "—"); +const qty = (v: string | null) => (v === null ? "Donnée manquante" : new D(v).toDecimalPlaces(2).toString().replace(".", ",")); +const STATUS: Record = { + a_commander: { label: "À commander aujourd'hui", tone: "danger" }, + heure_passee: { label: "Heure limite passée", tone: "warning" }, + pas_aujourdhui: { label: "Pas aujourd'hui", tone: "neutral" }, +}; + +export default async function OrdersOfTheDayPage({ searchParams }: { searchParams: Promise> }) { + const s = await requirePage("purchases.view"); + const sp = await searchParams; + const scope = await loadScope(s.ctx, sp, { allowAll: false }); + const est = scope.selection; + const canManage = hasPermission(s.ctx, "purchases.manage"); + if (!hasPermission(s.ctx, "stock.view")) { + return <>; + } + const p = await orderPlan(s.ctx, est); + const due = p.suppliers.filter((x) => x.plan.status !== "pas_aujourdhui"); + const later = p.suppliers.filter((x) => x.plan.status === "pas_aujourdhui"); + return ( + <> + 1 ? ( +
+ ) : undefined} /> + {!p.forecastBasis.hasConsumption && ( + + Aucune vente des {ORDER_FORECAST_WINDOW_DAYS} derniers jours n'est reliée à une fiche technique : les quantités suivent seulement vos stocks cibles. Reliez vos produits vendus à vos fiches dans Menus › Correspondances. + + )} + {!p.suppliers.length ? ( + + Indiquez le fournisseur habituel de vos produits (Stocks › Produits) et ses jours de livraison (fiche du fournisseur) : la liste se remplit toute seule. + + ) : ( +
+ {!due.length && } + {due.map((x) => )} + {later.length > 0 && ( + +

Les prochains jours

+
    {later.map((x) => ( +
  • + {x.supplier.name} + {x.plan.nextOrderDay ? `commander ${fr(x.plan.nextOrderDay)}${x.plan.cutoff ? ` avant ${x.plan.cutoff}` : ""} · livré ${fr(x.plan.delivery)}` : "aucune livraison prévue dans les 3 semaines"} + {x.rhythmMissing && jours de livraison à renseigner} +
  • + ))}
+
+ )} +

Estimation de gestion (règle FIN-PURCH-010) : quantité = consommation prévue d'aujourd'hui jusqu'à la livraison suivante + stock minimum − stock − déjà commandé, arrondie au colis supérieur ; sans prévision, stock cible − stock − déjà commandé. Rien n'est envoyé au fournisseur sans vous : « Préparer le bon » crée un brouillon à relire. Jours fermés (Réservations › Horaires) comptés à zéro.

+
+ )} + + ); +} + +function SupplierBlock({ x, establishmentId, canManage }: { x: SupplierPlan; establishmentId: string; canManage: boolean }) { + const st = STATUS[x.plan.status]; + const toOrder = x.lines.filter((l) => l.need.packs); + return ( + +
+
+

{x.supplier.name} {st.label}

+

+ {[x.plan.cutoff ? `heure limite ${x.plan.cutoff}` : "pas d'heure limite renseignée", + x.plan.status === "heure_passee" ? `prochaine commande ${fr(x.plan.nextOrderDay)}, livrée ${fr(x.plan.delivery)}` : `livré ${fr(x.plan.delivery)}`, + x.plan.nextDelivery ? `couvre jusqu'au ${fr(x.plan.nextDelivery)} (exclu, ${x.coverage.length} j)` : null, + x.supplier.deliveryDays.length ? `livre le ${x.supplier.deliveryDays.map((d) => WEEKDAYS[d - 1]!.short.toLowerCase()).join(", ")}` : null, + x.supplier.phone].filter(Boolean).join(" · ")} +

+ {x.rhythmMissing &&

Jours de livraison non renseignés : ALTAIR suppose une livraison tous les jours. Les renseigner

} +
+
+

{x.totalHt ? formatEUR(x.totalHt) : "Donnée manquante"} HT estimé

+ {x.belowMinimum && x.supplier.minOrderHt &&

Sous le minimum de commande ({formatEUR(Money.of(x.supplier.minOrderHt))} HT)

} +
+
+ {toOrder.length ? ( +
+ + + {toOrder.map((l) => ( + + + + + + + + + ))} +
ProduitStockDéjà commandéBesoin prévuÀ commanderMontant HT
{l.name}{l.need.basis === "stock_cible" && (stock cible)}{l.need.stockUnknown && stock inconnu (aucun inventaire) : à vérifier}{qty(l.stock)} {l.unit}{new D(l.incoming).isZero() ? "—" : `${qty(l.incoming)} ${l.unit}`}{l.consumption ? `${qty(l.consumption)} ${l.unit}` : "—"}{l.need.packs!.toString().replace(".", ",")} {l.packSize ? `${l.packLabel ?? "colis"} de ${qty(l.packSize)} ${l.unit}` : l.unit}{l.amountHt ? formatEUR(l.amountHt) : "prix manquant"}
+
+ ) :

Stock suffisant d'après la prévision : rien à commander pour cette livraison.

} + {canManage && toOrder.length > 0 && ( +
+ {x.draftId + ? Ouvrir le brouillon déjà préparé + :
+ )} +
+ ); +} diff --git a/src/app/(app)/achats/layout.tsx b/src/app/(app)/achats/layout.tsx index 631bde42..1593c28b 100644 --- a/src/app/(app)/achats/layout.tsx +++ b/src/app/(app)/achats/layout.tsx @@ -6,7 +6,8 @@ export default function PurchasesLayout({ children }: { children: ReactNode }) { <> {children} diff --git a/src/app/(app)/boite-mail/reponses/actions.ts b/src/app/(app)/boite-mail/reponses/actions.ts new file mode 100644 index 00000000..01946b0c --- /dev/null +++ b/src/app/(app)/boite-mail/reponses/actions.ts @@ -0,0 +1,46 @@ +"use server"; +import { revalidatePath } from "next/cache"; +import { ZodError } from "zod"; +import { requirePage } from "@/lib/auth/session"; +import { PermissionDeniedError } from "@/lib/auth/permissions"; +import { + MailReplyError, createReplyTemplate, createReplyTemplateFromPreset, deleteReplyTemplate, discardReplyDraft, sendReplyDraft, updateReplyTemplate, +} from "@/lib/services/mail-replies"; +import type { FormState } from "@/components/ui/action-form"; + +const str = (f: FormData, k: string) => String(f.get(k) ?? ""); +async function run(fn: (ctx: Awaited>["ctx"]) => Promise): Promise { + const s = await requirePage("mail.manage"); + let message: string; + try { message = await fn(s.ctx); } + catch (e) { + if (e instanceof ZodError) return { status: "error", message: [...new Set(e.issues.map((i) => i.message))].slice(0, 3).join(" · ") }; + if (e instanceof MailReplyError || e instanceof PermissionDeniedError) return { status: "error", message: e.message }; + console.error("[réponses mail]", e); + return { status: "error", message: "Erreur technique : rien n'a été envoyé ni enregistré." }; + } + revalidatePath("/boite-mail", "layout"); + return { status: "success", message }; +} +const template = (f: FormData) => ({ name: str(f, "name"), category: str(f, "category"), keyword: str(f, "keyword"), subject: str(f, "subject"), body: str(f, "body"), active: f.get("active") === "on" }); + +export async function sendReplyAction(_p: FormState, f: FormData) { + return run(async (ctx) => { await sendReplyDraft(ctx, str(f, "id"), { subject: str(f, "subject"), body: str(f, "body") }); return "Réponse envoyée."; }); +} +export async function discardReplyAction(_p: FormState, f: FormData) { + return run(async (ctx) => { await discardReplyDraft(ctx, str(f, "id")); return "Brouillon écarté : rien n'est envoyé."; }); +} +export async function saveTemplateAction(_p: FormState, f: FormData) { + return run(async (ctx) => { + const id = str(f, "id"); + if (id) { await updateReplyTemplate(ctx, id, template(f)); return "Modèle enregistré."; } + await createReplyTemplate(ctx, template(f)); + return "Modèle créé : les prochains e-mails de cette catégorie recevront un brouillon à relire."; + }); +} +export async function presetTemplateAction(_p: FormState, f: FormData) { + return run(async (ctx) => { await createReplyTemplateFromPreset(ctx, str(f, "code")); return "Modèle ajouté, modifiable ci-dessous."; }); +} +export async function deleteTemplateAction(_p: FormState, f: FormData) { + return run(async (ctx) => { await deleteReplyTemplate(ctx, str(f, "id")); return "Modèle supprimé."; }); +} diff --git a/src/app/(app)/boite-mail/reponses/page.tsx b/src/app/(app)/boite-mail/reponses/page.tsx new file mode 100644 index 00000000..795f0892 --- /dev/null +++ b/src/app/(app)/boite-mail/reponses/page.tsx @@ -0,0 +1,114 @@ +import type { Metadata } from "next"; +import Link from "next/link"; +import { requirePage } from "@/lib/auth/session"; +import { hasPermission } from "@/lib/auth/permissions"; +import { listReplyDrafts, listReplyTemplates } from "@/lib/services/mail-replies"; +import { MAIL_CATEGORIES, mailCategoryLabel } from "@/lib/mail/classify"; +import { REPLY_FIELDS, REPLY_PRESETS } from "@/lib/mail/replies"; +import { activeMailConfig } from "@/lib/services/mail"; +import { ActionForm } from "@/components/ui/action-form"; +import { Alert, Badge, Card, EmptyState, Input, Label, PageHeader, Select } from "@/components/ui/primitives"; +import { deleteTemplateAction, discardReplyAction, presetTemplateAction, saveTemplateAction, sendReplyAction } from "./actions"; + +export const metadata: Metadata = { title: "Réponses à relire" }; +const btn = "inline-flex h-11 items-center rounded-xl border border-border px-3 text-sm hover:border-accent disabled:opacity-50 lg:h-9"; +const primary = "inline-flex h-11 items-center rounded-xl bg-accent px-4 text-sm font-semibold text-white disabled:opacity-50 lg:h-9"; +const area = "w-full rounded-xl border border-border bg-surface-2 px-3 py-2 text-base lg:text-sm"; +const when = (d: Date) => new Intl.DateTimeFormat("fr-FR", { timeZone: "Europe/Paris", day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit" }).format(d); +const TABS = [["a_valider", "À relire"], ["envoye", "Envoyées"], ["ecarte", "Écartées"]] as const; +type Status = (typeof TABS)[number][0]; + +function TemplateFields({ prefix, t }: { prefix: string; t?: { name: string; category: string; keyword: string | null; subject: string; body: string; active: boolean } }) { + return ( +
+
+
+
+
+
+