From 60f66018450b48880f1ca3ba9cdf7b8305092a87 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Sun, 10 Jan 2016 21:53:41 +0000 Subject: [PATCH] Copy the db upgrade command into WSGI script. In there currently as wsgi has the credstash which we don't won't to apply in non-awe environments. This will need a refactor to better handle code duplication. --- scripts/aws_install_dependencies.sh | 2 +- wsgi.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/aws_install_dependencies.sh b/scripts/aws_install_dependencies.sh index c95b64aab..2fa7312ce 100755 --- a/scripts/aws_install_dependencies.sh +++ b/scripts/aws_install_dependencies.sh @@ -4,4 +4,4 @@ echo "Install dependencies" cd /home/ubuntu/notifications-admin; export FLASK_CONFIG=/home/ubuntu/config.cfg pip3 install -r /home/ubuntu/notifications-admin/requirements.txt -python3 app.py db upgrade +python3 wsgi.py db upgrade diff --git a/wsgi.py b/wsgi.py index 9aea43f28..f394112fe 100644 --- a/wsgi.py +++ b/wsgi.py @@ -1,6 +1,9 @@ from app import create_app import os from credstash import getAllSecrets +from flask.ext.script import Manager, Server +from flask_migrate import Migrate, MigrateCommand +from app import create_app, db secrets = getAllSecrets(region="eu-west-1") @@ -10,5 +13,10 @@ for key in application.config.keys(): if key in secrets: application.config[key] = secrets[key] + +manager = Manager(application) +migrate = Migrate(application, db) +manager.add_command('db', MigrateCommand) + if __name__ == "__main__": application.run()