Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
chore: amélioration du rendu des logs et suppression de trace niveau …
Browse files Browse the repository at this point in the history
…NOTICE superflues
  • Loading branch information
jbuget committed Oct 4, 2024
1 parent 7cc88bb commit 0c43887
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
34 changes: 30 additions & 4 deletions tools/update-metabase-db.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
#!/bin/bash

set -e
set -o pipefail

# Couleurs ANSI
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color (reset)

# Vérification de la présence du endpoint Metabase dans l'environnement
if [ -z "$METABASE_DB_URL" ];then echo "Pas de serveur Metabase connu ; export abandonné."; exit 0; fi

# Installe la dernière version de psql
echo -e "${CYAN}→ Installation de la dernière version de \`psql\`${NC}"
dbclient-fetcher psql
echo " "

# Installe et exporte les requêtes SQL du dossier `queries`
echo -e "${CYAN}→ Désactive les messages de niveau \"NOTICE\"${NC}"
psql $METABASE_DB_URL -c "SET client_min_messages TO WARNING;"
echo " "

echo -e "${CYAN}→ Installation et export des requêtes SQL du dossier \`queries\`${NC}"
echo -e "${YELLOW} tools/utils/install-sql-scripts.sh queries${NC}"
tools/utils/install-sql-scripts.sh queries
echo " "

# Exporte les tables de production restantes vers Metabase
echo -e "${CYAN}→ Export des tables de production restantes vers Metabase${NC}"
echo -e "${YELLOW} tools/utils/export-db-metabase.sh${NC}"
tools/utils/export-db-metabase.sh
echo " "

# Synchronise le schéma de la base de données
echo -e "${CYAN}→ Synchronisation du schéma de la base de données dans Metabase${NC}"
echo -e "${YELLOW} tools/utils/sync-metabase-schemas.sh${NC}"
tools/utils/sync-metabase-schemas.sh
echo " "

echo -e "${CYAN}→ Réactive les messages de niveau \"NOTICE\"${NC}"
psql $METABASE_DB_URL -c "SET client_min_messages TO NOTICE;"
echo " "
6 changes: 3 additions & 3 deletions tools/utils/install-sql-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ function walkDirs() {

echo "Suppression de '$tblname' sur la DB de destination"
drop_table_or_view_in_cascade_if_exists "$tblname"
echo "--"
echo " "
fi
done
if [ -n "$tables_stmt" ]; then
echo "Export du dump vers la DB de destination"
pg_dump $SRC_DB_URL -O -c $tables_stmt | psql -q $DEST_DB_URL
echo "Dump exporté"
echo " "
fi
}

Expand All @@ -83,5 +84,4 @@ if [ ! -d "$1" ]; then
fi

walkDirs "$1"
echo "--"
echo "✅ Terminé!"
echo " "
3 changes: 0 additions & 3 deletions tools/utils/sync-metabase-schemas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
# voir dans l'espace administrateur, rubrique : 'Bases de données'
# l'ID est affiché dans l'URL


echo "Synchronisation des schémas et champs Metabase"

if [ -z ${METABASE_API_URL} ]; then
echo " > l'URL de l'API Metabase n'est pas défini"
exit 1
Expand Down

0 comments on commit 0c43887

Please sign in to comment.