Commit 64525ce0 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Mise à jour doc et script d'install de la bdd

parent 6ce8ea43
Loading
Loading
Loading
Loading
+15 −13
Changes for bin/database/README.md: 15 added lines, 13 removed lines.
Original line number Diff line number Diff line
# Base de données : génération de la doc d'installation

Ce README s'adresse au développeur souhaitant générer les scripts de création d'une base de données PostgreSQL
toute neuve *à partir d'une base de données modèle existante*.
toute neuve. 

Cette génération se fait *à partir d'une base de données PostgreSQL modèle existante* à laquelle on se connecte.


## Génération des fichiers

Le script shell [`./build_db_install_files.sh`](build_db_install_files.sh) génère dans un répertoire de votre choix :
  - un répertoire [`sql/`](sql) contenant un ensemble de scripts SQL ordonnés permettant de créer une base de 
    données toute neuve :

  - un répertoire [`sql/`](sql) contenant un ensemble de scripts SQL ordonnés :
    - [01_create_db_user.sql`](sql/01_create_db_user.sql)
    - [02_create_schema.sql`](sql/02_create_schema.sql)
    - [03_insert_bootstrap_data.sql`](sql/03_insert_bootstrap_data.sql)
@@ -17,10 +20,12 @@ Le script shell [`./build_db_install_files.sh`](build_db_install_files.sh) gén
    - [07_create_comue.sql.dist`](sql/07_create_comue.sql.dist)
    - [08_init.sql.dist`](sql/08_init.sql.dist)
    - [09_create_fixture.sql.dist`](sql/09_create_fixture.sql.dist)
      
  - un script bash et un fichier de config pour "préparer" les scripts SQL ayant l'extension `.sql.dist` :    
    - [`build_db_files.conf.dist`](build_db_files.conf.dist)
    - [`build_db_files.sh`](build_db_files.sh)
  - un fichier expliquant comment procéder pour créer la base de données à l'aide de tous ces scripts :
    
  - un fichier expliquant comment procéder pour créer une base de données à l'aide de tous ces scripts :
    - [`README.md`](README.md)

Ce script [`./build_db_install_files.sh`](build_db_install_files.sh) :
@@ -32,26 +37,23 @@ Le script prend en argument le chemin d'un fichier de config et le chemin du ré
les fichiers.

Voici un exemple pour générer les fichiers de création d'une base de données...
  - dans le répertoire destination `./build`,
  - dans le répertoire destination `/tmp/build`,
  - à partir de la base modèle `sygal` (spécifiée par les variables d'env `PGDATABASE`, etc.),
  - qui permettront de créer une base et un utilisateur spécifiés dans le fichier de config 
    `./build_db_install_files.conf ` :
```bash
PGDATABASE='sygal' \
PGUSER='user' \
PGHOST='host.domain.fr' \
PGPORT=5432 \
PGPASSWORD='xxxxxx' \
./build_db_install_files.sh -c ./conf/build_db_install_files.conf -o ./build
PGHOST='localhost' PGPORT=54322 PGDATABASE='sygal' PGUSER='ad_sygal' PGPASSWORD='xxxxxx' \
./build_db_install_files.sh -c ./conf/build_db_install_files.conf -o /tmp/build
```

La façon de procéder pour créer une base de données à partir des fichiers générés est expliquée dans le fichier 
`README.md` (lui aussi généré).

## Copie des fichiers générés

## Mise à jour éventuelle de la doc

Copier les fichiers générés vers le répertoire contenant la documentation :

```bash
cp -r ./build/* ../../doc/database/
cp -r /tmp/build/* ../../doc/database/
```
+4 −5
Changes for doc/database/sql/02_create_schema.sql: 4 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -1446,22 +1446,21 @@ CREATE MATERIALIZED VIEW public.mv_recherche_these AS
           FROM (((public.individu i
             JOIN public.acteur a_1 ON ((i.id = a_1.individu_id)))
             JOIN public.these t_1 ON ((t_1.id = a_1.these_id)))
             JOIN public.role r ON (((a_1.role_id = r.id) AND ((r.code)::text = ANY ((ARRAY['D'::character varying, 'K'::character varying])::text[])))))
             JOIN public.role r ON (((a_1.role_id = r.id) AND ((r.code)::text = ANY (ARRAY[('D'::character varying)::text, ('K'::character varying)::text])))))
        )
 SELECT ('now'::text)::timestamp without time zone AS date_creation,
    t.source_code AS code_these,
    d.source_code AS code_doctorant,
    ed.source_code AS code_ecole_doct,
    btrim(public.str_reduce((((((((((((((((((((((('code-ed{'::text || (eds.code)::text) || '} '::text) || 'code-ur{'::text) || (urs.code)::text) || '} '::text) || 'titre{'::text) || (t.titre)::text) || '} '::text) || 'doctorant-numero{'::text) || substr((d.source_code)::text, ("position"((d.source_code)::text, '::'::text) + 2))) || '} '::text) || 'doctorant-nom{'::text) || (id.nom_patronymique)::text) || ' '::text) || (id.nom_usuel)::text) || '} '::text) || 'doctorant-prenom{'::text) || (id.prenom1)::text) || '} '::text) || 'directeur-nom{'::text) || (a.nom_usuel)::text) || '} '::text))) AS haystack
   FROM (((((((((public.these t
    btrim(public.str_reduce((((((((((((((((((((((('code-ed{'::text || COALESCE((eds.code)::text, ''::text)) || '} '::text) || 'code-ur{'::text) || COALESCE((urs.code)::text, ''::text)) || '} '::text) || 'titre{'::text) || (t.titre)::text) || '} '::text) || 'doctorant-numero{'::text) || substr((d.source_code)::text, ("position"((d.source_code)::text, '::'::text) + 2))) || '} '::text) || 'doctorant-nom{'::text) || (id.nom_patronymique)::text) || ' '::text) || (id.nom_usuel)::text) || '} '::text) || 'doctorant-prenom{'::text) || (id.prenom1)::text) || '} '::text) || 'directeur-nom{'::text) || COALESCE((ia.nom_usuel)::text, ''::text)) || '} '::text))) AS haystack
   FROM ((((((((public.these t
     JOIN public.doctorant d ON ((d.id = t.doctorant_id)))
     JOIN public.individu id ON ((id.id = d.individu_id)))
     JOIN public.these th ON (((th.source_code)::text = (t.source_code)::text)))
     LEFT JOIN public.ecole_doct ed ON ((t.ecole_doct_id = ed.id)))
     LEFT JOIN public.structure eds ON ((ed.structure_id = eds.id)))
     LEFT JOIN public.unite_rech ur ON ((t.unite_rech_id = ur.id)))
     LEFT JOIN public.structure urs ON ((ur.structure_id = urs.id)))
     LEFT JOIN acteurs a ON ((a.these_id = t.id)))
     LEFT JOIN public.acteur a ON ((a.these_id = t.id)))
     LEFT JOIN public.individu ia ON ((ia.id = a.individu_id)))
  WITH NO DATA;

+6 −1
Changes for doc/database/sql/04_insert_data.sql: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -291,6 +291,7 @@ INSERT INTO public.privilege (id, categorie_id, code, libelle, ordre) VALUES (36
INSERT INTO public.privilege (id, categorie_id, code, libelle, ordre) VALUES (37, 19, 'consultation-sa-structure', 'Consultation de la substitution de sa structure', 300);
INSERT INTO public.privilege (id, categorie_id, code, libelle, ordre) VALUES (38, 19, 'modification-toutes-structures', 'Modification de toutes les substitutions ', 400);
INSERT INTO public.privilege (id, categorie_id, code, libelle, ordre) VALUES (39, 19, 'modification-sa-structure', 'Modification de la substitution de sa structure', 500);
INSERT INTO public.privilege (id, categorie_id, code, libelle, ordre) VALUES (662, 101, 'simuler_remontees', 'Simulation des remontées du jury du SI', 1000);


--
@@ -881,7 +882,6 @@ INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (409, 21);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (83, 41);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (129, 41);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (520, 41);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (522, 41);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (11, 61);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (81, 61);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (82, 61);
@@ -902,6 +902,10 @@ INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (513, 61);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (520, 61);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (521, 61);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (518, 101);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (82, 41);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (409, 41);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (661, 6);
INSERT INTO public.profil_privilege (privilege_id, profil_id) VALUES (662, 6);


--
@@ -957,6 +961,7 @@ INSERT INTO public.soutenance_qualite (id, libelle, rang, hdr, emeritat, histo_c
INSERT INTO public.soutenance_qualite (id, libelle, rang, hdr, emeritat, histo_creation, histo_createur_id, histo_modification, histo_modificateur_id, histo_destruction, histo_destructeur_id, justificatif) VALUES (34, 'Membre étranger de rang A', 'A', 'N', 'N', '2021-05-28 15:22:14', 1446, '2021-05-28 15:22:14', 1446, NULL, NULL, 'O');
INSERT INTO public.soutenance_qualite (id, libelle, rang, hdr, emeritat, histo_creation, histo_createur_id, histo_modification, histo_modificateur_id, histo_destruction, histo_destructeur_id, justificatif) VALUES (35, 'Membre étranger de rang B', 'B', 'N', 'N', '2021-05-28 15:22:37', 1446, '2021-05-28 15:22:37', 1446, NULL, NULL, 'O');
INSERT INTO public.soutenance_qualite (id, libelle, rang, hdr, emeritat, histo_creation, histo_createur_id, histo_modification, histo_modificateur_id, histo_destruction, histo_destructeur_id, justificatif) VALUES (54, 'Chercheur HDR', 'A', 'O', 'N', '2021-07-07 09:07:44', 1461, '2021-07-07 09:07:44', 1461, NULL, NULL, 'O');
INSERT INTO public.soutenance_qualite (id, libelle, rang, hdr, emeritat, histo_creation, histo_createur_id, histo_modification, histo_modificateur_id, histo_destruction, histo_destructeur_id, justificatif) VALUES (74, 'Professeur des universités-praticien hospitalier ', 'A', 'O', 'N', '2021-07-12 13:43:02', 1446, '2021-07-12 13:43:02', 1446, NULL, NULL, 'N');


--