=== 0) Version & horodatage ==================================== version -------------------------------------------------------------------------------------------------------------------- PostgreSQL 17.6 (Debian 17.6-1.pgdg13+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit (1 row) executed_at ------------------------------- 2025-09-19 08:16:02.305781+00 (1 row) === 1) Comptes & répartition par rôle ========================== role | nb -----------------------+---- parent | 6 assistante_maternelle | 3 administrateur | 1 gestionnaire | 1 super_admin | 1 (5 rows) === 2) Utilisateurs en attente / acceptés / rejetés ============ statut | nb --------+---- actif | 12 (1 row) === 3) Parents avec co-parents (NULL si pas de co-parent) ====== parent_id | parent_email | id_co_parent | co_parent_email --------------------------------------+------------------------------+--------------------------------------+------------------------------ f1d3c5b7-8a9e-4f2d-9c1b-3e7a5d8c2f1b | amelie.durand@ptits-pas.fr | b6c4d2e3-5f7a-4b8c-9d1e-2a3c5f7b8d9e | julien.rousseau@ptits-pas.fr c4e2d1f5-6b7a-4c3d-8f2a-1e9c3b5a7d6f | claire.martin@ptits-pas.fr | | d3e5f7a9-1c2b-4d6e-8f3a-2b4c6d8e9f1a | david.lecomte@ptits-pas.fr | | b6c4d2e3-5f7a-4b8c-9d1e-2a3c5f7b8d9e | julien.rousseau@ptits-pas.fr | f1d3c5b7-8a9e-4f2d-9c1b-3e7a5d8c2f1b | amelie.durand@ptits-pas.fr (4 rows) === 4) Enfants (statut, dates cohérentes) ====================== id | prenom | nom | statut | date_naissance | date_prevue_naissance --------------------------------------+--------+----------+-----------+----------------+----------------------- 5e8574b7-63e6-4d48-9af3-8d3bf7a6a6cf | Emma | Dupont | actif | 2020-06-01 | edd19cd1-bb67-4f14-8a37-c66b75c94537 | Lucas | Durand | scolarise | 2018-09-15 | e6f7a8b9-c1d2-4e3f-5a6b-7c8d9e0f1a2b | Maxime | Lecomte | actif | 2023-04-15 | e1a2b3c4-d5e6-4f7a-8b9c-1d2e3f4a5b6c | Emma | Martin | actif | 2023-02-15 | e3c4d5e6-f7a8-4b9c-1d2e-3f4a5b6c7d8e | Léa | Martin | actif | 2023-02-15 | e2b3c4d5-e6f7-4a8b-9c1d-2e3f4a5b6c7d | Noah | Martin | actif | 2023-02-15 | e4d5e6f7-a8b9-4c1d-2e3f-4a5b6c7d8e9f | Chloé | Rousseau | actif | 2022-04-20 | e5e6f7a8-b9c1-4d2e-3f4a-5b6c7d8e9f1a | Hugo | Rousseau | actif | 2024-03-10 | a5c3268e-07eb-41a4-9f6c-2f9f16f37c3d | | | actif | 2020-01-01 | 2025-01-01 (9 rows) === 5) Liaison N:N parents_enfants ============================= id_parent | parent_email | id_enfant | enfant --------------------------------------+------------------------------+--------------------------------------+-------- f1d3c5b7-8a9e-4f2d-9c1b-3e7a5d8c2f1b | amelie.durand@ptits-pas.fr | e4d5e6f7-a8b9-4c1d-2e3f-4a5b6c7d8e9f | Chloé f1d3c5b7-8a9e-4f2d-9c1b-3e7a5d8c2f1b | amelie.durand@ptits-pas.fr | e5e6f7a8-b9c1-4d2e-3f4a-5b6c7d8e9f1a | Hugo c4e2d1f5-6b7a-4c3d-8f2a-1e9c3b5a7d6f | claire.martin@ptits-pas.fr | e1a2b3c4-d5e6-4f7a-8b9c-1d2e3f4a5b6c | Emma c4e2d1f5-6b7a-4c3d-8f2a-1e9c3b5a7d6f | claire.martin@ptits-pas.fr | e3c4d5e6-f7a8-4b9c-1d2e-3f4a5b6c7d8e | Léa c4e2d1f5-6b7a-4c3d-8f2a-1e9c3b5a7d6f | claire.martin@ptits-pas.fr | e2b3c4d5-e6f7-4a8b-9c1d-2e3f4a5b6c7d | Noah d3e5f7a9-1c2b-4d6e-8f3a-2b4c6d8e9f1a | david.lecomte@ptits-pas.fr | e6f7a8b9-c1d2-4e3f-5a6b-7c8d9e0f1a2b | Maxime b6c4d2e3-5f7a-4b8c-9d1e-2a3c5f7b8d9e | julien.rousseau@ptits-pas.fr | e4d5e6f7-a8b9-4c1d-2e3f-4a5b6c7d8e9f | Chloé b6c4d2e3-5f7a-4b8c-9d1e-2a3c5f7b8d9e | julien.rousseau@ptits-pas.fr | e5e6f7a8-b9c1-4d2e-3f4a-5b6c7d8e9f1a | Hugo (8 rows) === 6) Dossiers (parent, enfant, statut) ======================= id | parent_email | enfant | statut | budget --------------------------------------+----------------------------+--------+--------+--------- bb9c30a0-60b4-4832-9947-8a7d2366673d | amelie.durand@ptits-pas.fr | Emma | envoye | 1200.00 (1 row) === 7) Messages par dossier (ordre chronologique) ============== id | id_dossier | id_expediteur | expediteur_email | contenu | cree_le ----+------------+---------------+------------------+---------+--------- (0 rows) === 8) Contrats 1:1 avec dossier + avenants ==================== contrat_id | id_dossier | statut | nb_avenants --------------------------------------+--------------------------------------+-----------+------------- f09c6ffa-4627-4aa8-b20b-829c2c828f0d | bb9c30a0-60b4-4832-9947-8a7d2366673d | brouillon | 0 (1 row) === 9) Evénements par enfant (30 derniers jours) ============== id | type | id_enfant | enfant | date_debut | date_fin | statut ----+------+-----------+--------+------------+----------+-------- (0 rows) === 10) Uploads & notifications récentes ======================= email | fichier_url | fichier_type | cree_le ---------------------+--------------------------------+--------------+------------------------------- parent1@example.com | https://placeholder.local/file | image | 2025-09-02 12:57:35.140078+00 (1 row) email | contenu | lu | cree_le ---------------------+-----------------------------+----+------------------------------- parent1@example.com | Votre dossier a été accepté | f | 2025-09-02 12:57:42.845264+00 (1 row) === 11) Validations (qui a validé quoi) ======================== id | utilisateur_email | type | statut | cree_le --------------------------------------+---------------------------+----------+--------+------------------------------- fcc45701-5708-4368-b467-b95ddb7e1580 | marie.dubois@ptits-pas.fr | | valide | 2025-09-09 14:52:47.339858+00 be1c4779-341b-436d-b17e-8bc486d22ef8 | am1@example.com | | valide | 2025-09-09 14:47:01.963573+00 8ec99565-e8c2-469f-9641-01b99b8281eb | am1@example.com | identité | valide | 2025-09-02 12:57:49.846424+00 (3 rows) === 12) Orphelins potentiels (doivent renvoyer 0 ligne) ======= id | id_dossier | id_expediteur | contenu | re_redige_par_ia | cree_le ----+------------+---------------+---------+------------------+--------- (0 rows) id_parent | id_enfant -----------+----------- (0 rows) id | id_dossier | planning | tarif_horaire | indemnites_repas | date_debut | statut | signe_parent | signe_am | finalise_le | cree_le | modifie_le ----+------------+----------+---------------+------------------+------------+--------+--------------+----------+-------------+---------+------------ (0 rows) id | id_contrat | modifications | initie_par | statut | cree_le | modifie_le ----+------------+---------------+------------+--------+---------+------------ (0 rows) id | type | id_enfant | id_am | id_parent | cree_par | date_debut | date_fin | commentaires | statut | delai_grace | urgent | cree_le | modifie_le ----+------+-----------+-------+-----------+----------+------------+----------+--------------+--------+-------------+--------+---------+------------ (0 rows) === 13) Performance : EXPLAIN sur requêtes clés =============== QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=11.31..11.31 rows=3 width=89) (actual time=0.027..0.029 rows=0 loops=1) -> Sort (cost=11.31..11.31 rows=3 width=89) (actual time=0.026..0.027 rows=0 loops=1) Sort Key: cree_le DESC Sort Method: quicksort Memory: 25kB -> Bitmap Heap Scan on messages m (cost=4.17..11.28 rows=3 width=89) (actual time=0.021..0.021 rows=0 loops=1) Recheck Cond: (id_dossier = 'dddddddd-dddd-dddd-dddd-dddddddddddd'::uuid) -> Bitmap Index Scan on idx_messages_id_dossier_cree_le (cost=0.00..4.17 rows=3 width=0) (actual time=0.011..0.011 rows=0 loops=1) Index Cond: (id_dossier = 'dddddddd-dddd-dddd-dddd-dddddddddddd'::uuid) Planning Time: 0.837 ms Execution Time: 0.079 ms (10 rows) QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------- Index Scan using idx_evenements_id_enfant_date_debut on evenements ev (cost=0.15..8.17 rows=1 width=161) (actual time=0.006..0.007 rows=0 loops=1) Index Cond: ((id_enfant = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'::uuid) AND (date_debut >= '2025-01-01 00:00:00+00'::timestamp with time zone)) Planning Time: 0.107 ms Execution Time: 0.099 ms (4 rows) QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------ Limit (cost=9.52..9.53 rows=2 width=73) (actual time=0.020..0.021 rows=0 loops=1) -> Sort (cost=9.52..9.53 rows=2 width=73) (actual time=0.019..0.020 rows=0 loops=1) Sort Key: cree_le DESC Sort Method: quicksort Memory: 25kB -> Bitmap Heap Scan on notifications n (cost=4.17..9.51 rows=2 width=73) (actual time=0.014..0.014 rows=0 loops=1) Recheck Cond: ((id_utilisateur = '33333333-3333-3333-3333-333333333333'::uuid) AND (NOT lu)) -> Bitmap Index Scan on idx_notifications_user_lu_cree_le (cost=0.00..4.17 rows=2 width=0) (actual time=0.008..0.008 rows=0 loops=1) Index Cond: ((id_utilisateur = '33333333-3333-3333-3333-333333333333'::uuid) AND (lu = false)) Planning Time: 0.122 ms Execution Time: 0.043 ms (10 rows) QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=8.18..8.18 rows=1 width=267) (actual time=0.429..0.431 rows=0 loops=1) Sort Key: cree_le DESC Sort Method: quicksort Memory: 25kB -> Index Scan using idx_dossiers_id_parent_enfant_statut_cree_le on dossiers d (cost=0.15..8.17 rows=1 width=267) (actual time=0.419..0.419 rows=0 loops=1) Index Cond: ((id_parent = '33333333-3333-3333-3333-333333333333'::uuid) AND (id_enfant = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'::uuid)) Planning Time: 1.115 ms Execution Time: 0.476 ms (7 rows) === 14) JSONB : exemples de filtrage =========================== id | planning_souhaite ----+------------------- (0 rows) id | planning ----+---------- (0 rows) === 15) Sanity check final ==================================== nb_utilisateurs | nb_parents | nb_am | nb_enfants | nb_liens_parent_enfant | nb_dossiers | nb_messages | nb_contrats | nb_avenants | nb_evenements | nb_uploads | nb_notifications | nb_validations -----------------+------------+-------+------------+------------------------+-------------+-------------+-------------+-------------+---------------+------------+------------------+---------------- 12 | 4 | 2 | 9 | 8 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | 3 (1 row)