Skip to content

Commit

Permalink
improve the load dump to only gather the essential tables
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickPassa committed Feb 3, 2025
1 parent 31a4d7a commit ecd0dec
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 8 deletions.
73 changes: 65 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,45 @@ RESTORE_DIR ?= .latest.restore

pg_dump:
@PGDATABASE=${PROD_PGDATABASE} PGHOST=${PROD_PGHOST} PGPORT=${PROD_PGPORT} PGUSER=${PROD_PGUSER} PGPASSWORD=${PROD_PGPASSWORD} \
psql -c ";" || { \
echo "\n\n### Your connexion to the production database failed. Is the port blocked by a firewall ? ###\n" ; \
false ; \
}
psql -c ";" || { \
echo "\n\n### Your connexion to the production database failed. Is the port blocked by a firewall ? ###\n" ; \
false ; \
}
rm -rf $(DUMP_DIR)
@echo "\n\n### Dumping the production database on your machine, check your disk size and connection speeds ! ###\n"
PGDATABASE=${PROD_PGDATABASE} PGHOST=${PROD_PGHOST} PGPORT=${PROD_PGPORT} PGUSER=${PROD_PGUSER} PGPASSWORD=${PROD_PGPASSWORD} \
time pg_dump --format=directory --no-owner --no-acl --verbose --jobs=4 \
--exclude-table="lh_*" --exclude-table="yp_*" --exclude-table="z_*" \
--file=$(DUMP_DIR)
time pg_dump --format=directory --no-owner --no-acl --verbose --jobs=4 \
--table='"fluxIAE_"*' \
--table='c1_*' \
--table='candidats_v0' \
--table='candidatures' \
--table="cap_campagnes" \
--table="cap_candidatures" \
--table="cap_critères_iae" \
--table="cap_structures" \
--table="codes_rome" \
--table="collaborations" \
--table="communes" \
--table="critères_iae" \
--table="departements" \
--table="fiches_de_poste" \
--table="fiches_de_poste_par_candidature" \
--table="institutions" \
--table="organisations_v0" \
--table="pass_agréments" \
--table="structures" \
--table="utilisateurs_v0" \
--table="demandes_de_prolongation" \
--table="prolongations" \
--table="structures_v0" \
--table="insee_communes" \
--table="suivi_visiteurs_tb_prives" \
--table="suivi_visiteurs_tb_prives_v1" \
--table="suivi_utilisateurs_tb_prives" \
--table="suivi_visiteurs_tb_publics_v1" \
--table="sorties_v2" \
--table="sa_zones_infradepartementales" \
--file=$(DUMP_DIR)
@echo "\n\n### Database dumped successfully. ###\n"
rm -rf $(RESTORE_DIR)
mv $(DUMP_DIR) $(RESTORE_DIR)
Expand All @@ -108,7 +137,35 @@ ifneq (,$(findstring clever-cloud,$(PGHOST)))
else
dropdb ${PGDATABASE} || true
createdb ${PGDATABASE}
time pg_restore --format=directory --clean --jobs=4 --verbose --no-owner --no-acl -d ${PGDATABASE} $(RESTORE_DIR) || true
time pg_restore --format=directory --clean --jobs=4 --verbose --no-owner --no-acl -d ${PGDATABASE} \
--table='"fluxIAE_"*' \
--table='c1_*' \
--table='cap_*' \
--table="candidats_v0" \
--table="candidatures" \
--table="codes_rome" \
--table="collaborations" \
--table="communes" \
--table="critères_iae" \
--table="departements" \
--table="fiches_de_poste" \
--table="fiches_de_poste_par_candidature" \
--table="institutions" \
--table="organisations_v0" \
--table="pass_agréments" \
--table="structures" \
--table="utilisateurs_v0" \
--table="demandes_de_prolongation" \
--table="prolongations" \
--table="structures_v0" \
--table="insee_communes" \
--table="suivi_visiteurs_tb_prives" \
--table="suivi_visiteurs_tb_prives_v1" \
--table="suivi_utilisateurs_tb_prives" \
--table="suivi_visiteurs_tb_publics_v1" \
--table="sorties_v2" \
--table="sa_zones_infradepartementales" \
$(RESTORE_DIR) || true
@echo "\n\n### Database restored successfully ! ###\n"
endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ models:
description: >
Ce script permet de finaliser la traitement des données FT de recette, précedemment effectué via un notebook python (il y a 2 tb, un de prod un de recette avec deux tables différentes)
L'usage des seed nous permet d'anticiper de futures modifications dans les différentes colonnes ainsi que ne pas écrire de nombreux case...when.
- name: stg_france_travail
description: >
Les données France travail étaient traitées via un notebook python développé par Jules.
Ce premier script sql permet de faire une partie du traitement effectué par le notebook.
File renamed without changes.

0 comments on commit ecd0dec

Please sign in to comment.