This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/migrations/generate-schema-migration.sh

21 lines
No EOL
725 B
Bash
Executable file

set -e
# Run a MySQL database on port 3306 inside of Docker.
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql
# Sleep for 5s to get MySQL get started.
echo 'Sleeping for 5...'
sleep 5
# Add the database to mysql.
docker run --link mysql:mysql mysql sh -c 'echo "create database genschema" | mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -ppassword'
# Generate a SQLite database with the schema as defined by the existing alembic model.
GENMIGRATE=true PYTHONPATH=. alembic upgrade head
# Generate the migration to the current model.
GENMIGRATE=true PYTHONPATH=. alembic revision --autogenerate -m "$@"
# Kill the MySQL instance.
docker kill mysql
docker rm mysql