Commit ffe18fe3 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Corrections dans le matériel de migration

parent 190f6899
Loading
Loading
Loading
Loading
+0 −1
Changes for .gitignore: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -11,4 +11,3 @@
# temporaire (pour la branche migration_postgres)
bin/aaa.sh
data/db/
 No newline at end of file
migration/
 No newline at end of file
+0 −2
Changes for migration/README.md: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -11,8 +11,6 @@ Pré-requis
- Se placer dans le répertoire racine du projet SyGAL. 
  Dans la suite, `${PWD}` correspond donc à ce répertoire racine.

- Configurer la connexion à la base de données Oracle source dans la configuration de l'application.


Génération des scripts SQL de migration
---------------------------------------
+37 −8
Changes for migration/docker/pg_after_import.sql: 37 added lines, 8 removed lines.
Original line number Diff line number Diff line

--
-- Cf. migration/docker/pg_before_import.sql
-- Correction de la vue `src_role` : colonne `these_dep` => booléen
--
CREATE MATERIALIZED VIEW mv_indicateur_121 AS
select * FROM individu
where SOURCE_CODE in (
    SELECT SOURCE_CODE
    FROM V_DIFF_INDIVIDU
    WHERE operation = 'insert'
)
drop view v_diff_role
;
drop view src_role
;
create or replace view src_role
            (id, source_code, source_id, libelle, code, role_id, these_dep, structure_id,
             type_structure_dependant_id) as
SELECT NULL::text                                       AS id,
       tmp.source_code,
       src.id                                           AS source_id,
       tmp.lib_roj                                      AS libelle,
       tmp.id                                           AS code,
       (tmp.lib_roj::text || ' '::text) || s.code::text AS role_id,
       true                                             AS these_dep,
       s.id                                             AS structure_id,
       NULL::bigint                                     AS type_structure_dependant_id
FROM tmp_role tmp
         JOIN structure s ON s.source_code::text = tmp.etablissement_id::text
         JOIN etablissement e ON e.structure_id = s.id
         JOIN source src ON src.code::text = tmp.source_id::text
;


--
-- Cf. migration/docker/pg_before_import.sql
--
-- >>>> On ne peut pas créer cette MV car elle se base sur V_DIFF_INDIVIDU qui est surpprimé/générée à chaque import par unicaen/db-import
--      la solution est d'inclure le source de V_DIFF_INDIVIDU dans cette MV.
--
-- CREATE MATERIALIZED VIEW mv_indicateur_121 AS
-- select * FROM individu
-- where SOURCE_CODE in (
--     SELECT SOURCE_CODE
--     FROM V_DIFF_INDIVIDU
--     WHERE operation = 'insert'
-- )
-- ;

--
-- Peuplement des VM.