Skip to content

Commit

Permalink
db hydratation
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Sep 19, 2024
1 parent 4550cf9 commit 6fe4f6b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ index:
INSTANCE_NUMBER=0 \
POSTGRESQL_ADDON_URI=$(POSTGRESQL_ADDON_URI) \
clevercloud/rebuild_index.sh

# DB

.PHONY: resetdb
resetdb:
dropdb --if-exists $(POSTGRESQL_ADDON_DB)
createdb $(POSTGRESQL_ADDON_DB)
python manage.py migrate
python manage.py configure_bucket
python manage.py populate
10 changes: 5 additions & 5 deletions scripts/import-latest-db-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ echo "Going to inject DB_BACKUP_PATH=$DB_BACKUP_PATH"
docker cp $DB_BACKUP_PATH commu_postgres:/backups

echo "dropping current db"
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
echo "applying new migrations"
python manage.py migrate

echo "faking password"
python manage.py set_fake_passwords
Expand Down

0 comments on commit 6fe4f6b

Please sign in to comment.