Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification du pg_restore afin de prendre en compte que les tables nécessaires au dbt run #389

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 68 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,38 @@ 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="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" \
$(RESTORE_DIR) || true
@echo "\n\n### Database restored successfully ! ###\n"
endif

Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/depricated/deprecated/g ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

la honte

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

et merci !

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.
Loading