Update migrations to entry.sh and and dump script

This commit is contained in:
Ari Timonen 2020-04-09 04:21:50 +03:00
parent 7fcfe27084
commit 72782585be
3 changed files with 9 additions and 1 deletions

View file

@ -27,6 +27,8 @@ Install git: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
## 4. Put any database dumps to `db/initdb.d`. (optional)
You can use `script/db_dump.sh` to dump production database.
mysqldump --opt -h DATABASE_IP -u USERNAME DATABASE_NAME > 00_ensl.org.`date +%F`.sql
mv 00_ensl.org.`date +%F`.sql db/initdb.d/00_ensl.org.`date +%F`.sql

View file

@ -23,6 +23,6 @@ if [ "$ASSETS_PRECOMPILE" -eq 1 ]; then
chown -R web:web $APP_PATH
fi
cd $APP_PATH
bundle exec rake db:migrate
bundle exec puma -C config/puma.rb
bash

6
script/dump_db.sh Normal file
View file

@ -0,0 +1,6 @@
#!/bin/bash
# ENSL_DB_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ensl_db)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
docker-compose exec db "mysqldump --opt -u $MYSQL_USER -p $MYSQL_PASSWORD $MYSQL_DATABASE" > $DIR/db/initdb.d/ensl.org.`date +%F`.sql