migration.sh: default DOCKER_IP to localhost
This commit is contained in:
parent
6716a2562b
commit
e05bc8bf7d
1 changed files with 7 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
DOCKER_IP=`echo $DOCKER_HOST | sed 's/tcp:\/\///' | sed 's/:.*//'`
|
PARSED_DOCKER_HOST=`echo $DOCKER_HOST | sed 's/tcp:\/\///' | sed 's/:.*//'`
|
||||||
|
DOCKER_IP="${PARSED_DOCKER_HOST:-127.0.0.1}"
|
||||||
MYSQL_CONFIG_OVERRIDE="{\"DB_URI\":\"mysql+pymysql://root:password@$DOCKER_IP/genschema\"}"
|
MYSQL_CONFIG_OVERRIDE="{\"DB_URI\":\"mysql+pymysql://root:password@$DOCKER_IP/genschema\"}"
|
||||||
PERCONA_CONFIG_OVERRIDE="{\"DB_URI\":\"mysql+pymysql://root:password@$DOCKER_IP/genschema\"}"
|
PERCONA_CONFIG_OVERRIDE="{\"DB_URI\":\"mysql+pymysql://root:password@$DOCKER_IP/genschema\"}"
|
||||||
PGSQL_CONFIG_OVERRIDE="{\"DB_URI\":\"postgresql://postgres@$DOCKER_IP/genschema\"}"
|
PGSQL_CONFIG_OVERRIDE="{\"DB_URI\":\"postgresql://postgres@$DOCKER_IP/genschema\"}"
|
||||||
|
@ -74,18 +75,21 @@ down_postgres() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gen_migrate() {
|
gen_migrate() {
|
||||||
# Generate a SQLite database with the schema as defined by the existing alembic model.
|
# Generate a database with the schema as defined by the existing alembic model.
|
||||||
QUAY_OVERRIDE_CONFIG=$1 PYTHONPATH=. alembic upgrade head
|
QUAY_OVERRIDE_CONFIG=$1 PYTHONPATH=. alembic upgrade head
|
||||||
|
|
||||||
|
|
||||||
# Generate the migration to the current model.
|
# Generate the migration to the current model.
|
||||||
QUAY_OVERRIDE_CONFIG=$1 PYTHONPATH=. alembic revision --autogenerate -m "$2"
|
QUAY_OVERRIDE_CONFIG=$1 PYTHONPATH=. alembic revision --autogenerate -m "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_migrate() {
|
test_migrate() {
|
||||||
# Generate a SQLite database with the schema as defined by the existing alembic model.
|
# Generate a database with the schema as defined by the existing alembic model.
|
||||||
|
echo '> Running upgrade'
|
||||||
QUAY_OVERRIDE_CONFIG=$1 PYTHONPATH=. alembic upgrade head
|
QUAY_OVERRIDE_CONFIG=$1 PYTHONPATH=. alembic upgrade head
|
||||||
|
|
||||||
# Downgrade to verify it works in both directions.
|
# Downgrade to verify it works in both directions.
|
||||||
|
echo '> Running downgrade'
|
||||||
COUNT=`ls data/migrations/versions/*.py | wc -l | tr -d ' '`
|
COUNT=`ls data/migrations/versions/*.py | wc -l | tr -d ' '`
|
||||||
QUAY_OVERRIDE_CONFIG=$1 PYTHONPATH=. alembic downgrade "-$COUNT"
|
QUAY_OVERRIDE_CONFIG=$1 PYTHONPATH=. alembic downgrade "-$COUNT"
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue