diff --git a/ui/medashare/alembic.ini b/ui/medashare/alembic.ini index 3c1448d..c25b5e2 100644 --- a/ui/medashare/alembic.ini +++ b/ui/medashare/alembic.ini @@ -55,7 +55,7 @@ version_path_separator = os # Use os.pathsep. Default configuration used for ne # are written from script.py.mako # output_encoding = utf-8 -sqlalchemy.url = sqlite+pysqlite:///:memory: +sqlalchemy.url = sqlite+pysqlite:///autogen.db.sqlite3 [post_write_hooks] diff --git a/ui/medashare/alembic/README b/ui/medashare/alembic/README index 31b42d6..e05fd38 100644 --- a/ui/medashare/alembic/README +++ b/ui/medashare/alembic/README @@ -3,9 +3,9 @@ New Version To create a revision, update the ORM in medashare/orm.py. -Then run: +Then in the medashare directory, run: ``` -alembic revision --autogenerate -m 'what you did' +./autogen.sh "message of what you did" ``` This will create a version file. Edit the version file to support the diff --git a/ui/medashare/autogen.sh b/ui/medashare/autogen.sh new file mode 100755 index 0000000..e62d488 --- /dev/null +++ b/ui/medashare/autogen.sh @@ -0,0 +1,22 @@ +# +# Script to auto generate any orm changes. +# + +if [ -z "$*" ]; then + echo "Provide the upgrade message as an argument." + exit 1 +fi + +set -e + +# Make sure we start clean +rm -f autogen.db.sqlite3 + +# Upgrade the database to head +alembic upgrade head + +# Autogenerate the migrations +alembic revision --autogenerate -m "$*" + +# Clean up +rm -f autogen.db.sqlite3