Skip to content

Commit

Permalink
Merge branch 'fix/dedoublonner-cs' of github.com:mission-apprentissag…
Browse files Browse the repository at this point in the history
…e/tjp-pilotage into fix/dedoublonner-cs
  • Loading branch information
LucasDetre committed Dec 19, 2024
2 parents 479573f + 6659d74 commit 63e3c2f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PQSL_USER=postgres
PSQL_PWD=password
PSQL_URI=postgresql://postgres:[email protected]:5432/orion-test-VITEST_POOL_ID
PSQL_CA=
PSQL_LOG_LEVEL=query
PSQL_LOG_LEVEL=error
# Auth
AUTH_JWT_SECRET=abcdef
ACTIVATION_JWT_SECRET=abcdef
Expand Down
25 changes: 15 additions & 10 deletions server/seed/generate-seed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,36 @@

readonly VAULT_PASSWORD_CLIENT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/vault/get-vault-password-client.sh"

echo "Chemin de VAULT_PASSWORD_CLIENT : $VAULT_PASSWORD_CLIENT"
echo ""
echo "🔀 Chemin de VAULT_PASSWORD_CLIENT : $VAULT_PASSWORD_CLIENT"
echo ""

readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly ANSIBLE_DIR="${SCRIPT_DIR}/../../.infra/ansible"
readonly INFRA_DIR="${SCRIPT_DIR}/../../.infra/vault"
readonly VAULT_FILE="${1:-${INFRA_DIR}/vault.yml}"
readonly VAULT_PASSWORD_FILE="${SCRIPT_DIR}/../../.bin/scripts/get-vault-password-client.sh"

echo "Lancement de la génération de la seed"

echo "🚀 Lancement de la génération de la seed"
echo ""
# Récupérer les informations d'identification de la base de données à partir du Vault

DB_URL=$(ansible-vault view $VAULT_FILE --vault-password-file "${VAULT_PASSWORD_FILE}" | grep PSQL_URI | head -n 1 | awk '{print $2}' | xargs)
SCHEMA_DUMP_FILE="seed_schema.dump"
DATA_DUMP_FILE="seed_data.dump"

echo "DB_URL : $DB_URL"
echo "🔑 DB_URL : $DB_URL"
echo ""

# Générer le fichier de dump
echo "Génération de la seed contenant le schéma de la DB"
echo "🌱 Génération de la seed contenant le schéma de la DB"
echo ""
pg_dump $DB_URL -Fc --clean --if-exists --create --schema-only --file $SCHEMA_DUMP_FILE
pg_dump $DB_URL --format=custom --clean --if-exists --create --schema-only --file $SCHEMA_DUMP_FILE

echo "Génération de la seed contenant les données de la DB"
pg_dump $DB_URL -Fc --data-only \
echo "🤖 Génération de la seed contenant les données de la DB"
echo ""

pg_dump $DB_URL --format=custom --data-only \
--exclude-table='public."changeLog"' \
--exclude-table='public."changementStatut"' \
--exclude-table='public."demande"' \
Expand All @@ -40,7 +44,8 @@ pg_dump $DB_URL -Fc --data-only \
--file $DATA_DUMP_FILE

if [ $? -eq 0 ]; then
echo "Dump de la base de données généré avec succès"
echo "Dump de la base de données généré avec succès"
else
echo "Échec de la génération du dump de la base de données."
echo "Échec de la génération du dump de la base de données."
fi

Binary file modified server/seed/seed_data.dump
Binary file not shown.
Binary file modified server/seed/seed_schema.dump
Binary file not shown.
2 changes: 2 additions & 0 deletions server/tests/pg.test.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const startAndConnectPg = async () => {

await connectToPgDb(dbUri);

await refreshViews();

await migrateToLatest(true, false);
console.log("Migration terminée");
console.log("Rafraichissement des vues matérialisées");
Expand Down

0 comments on commit 63e3c2f

Please sign in to comment.