From 63c87f10e769195bda5fc07b1b41cb3bd195c515 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Sun, 10 Jan 2016 22:16:26 +0000 Subject: [PATCH] Needed own file for db scripts. Need to compartmentalise running the app and the db upgrades into differing scripts. --- db.py | 19 +++++++++++++++++++ scripts/aws_install_dependencies.sh | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db.py diff --git a/db.py b/db.py new file mode 100644 index 000000000..40ed2511c --- /dev/null +++ b/db.py @@ -0,0 +1,19 @@ +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") + +application = create_app(os.getenv('NOTIFICATIONS_ADMIN_ENVIRONMENT') or 'live') + +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) diff --git a/scripts/aws_install_dependencies.sh b/scripts/aws_install_dependencies.sh index 2fa7312ce..e36fae522 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 wsgi.py db upgrade +python3 db.py db upgrade