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

chore(db): Améliorer l'hydratation de la base de données en developpement #777

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vincentporte
Copy link
Contributor

@vincentporte vincentporte commented Sep 19, 2024

Description

🎸 Ajout de la commande resetdb dans le fichier Makefile pour automatiser l'hydratation d'une DB de dev
🎸 Amélioration du script de restauration des dump de DB : suppression surcouche docker, ajout des migrations

Type de changement

🚧 technique

@vincentporte vincentporte added the hot fix Pull requests that fix a bug to fix as soon as possible label Sep 19, 2024
Copy link
Contributor

@francoisfreitag francoisfreitag left a comment

Choose a reason for hiding this comment

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

La magie qui me semblerait intéressante serait de vérifier que le venv est bien actif et à jour (et le construire ou l’activer si besoin). C’est l’histoire de la dépendance $(VIRTUAL_ENV) sur le C1. Fais-moi signe si tu es intéressé pour une explication de cette magie noire (et imparfaite) :)

dropdb --if-exists $(POSTGRESQL_ADDON_DB)
createdb $(POSTGRESQL_ADDON_DB)
python manage.py migrate
python manage.py configure_bucket
Copy link
Contributor

Choose a reason for hiding this comment

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

Pinaillage, mais ce n’est pas de la DB, c’est pour minio.
Une fois que c’est fait, normalement pas besoin de le refaire.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

💯

Comment on lines -26 to -35
docker exec -ti commu_postgres dropdb $POSTGRESQL_ADDON_DB -U $POSTGRESQL_ADDON_USER --if-exists --echo
dropdb $POSTGRESQL_ADDON_DB -U $POSTGRESQL_ADDON_USER --if-exists --echo

echo "creating new db"
docker exec -ti commu_postgres createdb $POSTGRESQL_ADDON_DB -O $POSTGRESQL_ADDON_USER -U $POSTGRESQL_ADDON_USER --echo
createdb $POSTGRESQL_ADDON_DB -O $POSTGRESQL_ADDON_USER -U $POSTGRESQL_ADDON_USER --echo

echo "restoring db"
docker exec -ti commu_postgres pg_restore -U $POSTGRESQL_ADDON_USER --dbname=$POSTGRESQL_ADDON_DB --format=c --clean --no-owner --verbose /backups/$DB_BACKUP_NAME
pg_restore -U $POSTGRESQL_ADDON_USER --dbname=$POSTGRESQL_ADDON_DB --format=c --clean --no-owner $DB_BACKUP_PATH

echo "restarting db"
docker-compose down postgres; docker-compose up postgres -d
Copy link
Contributor

Choose a reason for hiding this comment

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

Ces changements font que le dev doit avoir installé le client PostgreSQL sur sa machine. Pas bien grave, mais peut-être l’ajouter dans le README ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hot fix Pull requests that fix a bug to fix as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants