diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2016-06-28 01:01:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-28 01:01:15 +0200 |
| commit | 6bcf5e3aa234b7796cc5b9ec652acd4c71a56724 (patch) | |
| tree | cacffcd3650960168a8d6921284ebe8eee48a652 /budget | |
| parent | 5084cafe6bcd266bd1e676fc6921a7dba3c48a57 (diff) | |
| parent | a5579220e005d50f00cce11b4ebb97429fe9c16f (diff) | |
| download | ihatemoney-mirror-6bcf5e3aa234b7796cc5b9ec652acd4c71a56724.zip ihatemoney-mirror-6bcf5e3aa234b7796cc5b9ec652acd4c71a56724.tar.gz ihatemoney-mirror-6bcf5e3aa234b7796cc5b9ec652acd4c71a56724.tar.bz2 | |
Merge pull request #144 from JocelynDelalande/fix-migrations-upgrade-path
Fix migrations upgrade path for MySQL
Diffstat (limited to 'budget')
| -rw-r--r-- | budget/run.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/budget/run.py b/budget/run.py index 807ad12..8f29f35 100644 --- a/budget/run.py +++ b/budget/run.py @@ -3,7 +3,7 @@ import warnings from flask import Flask, g, request, session from flask.ext.babel import Babel -from flask.ext.migrate import Migrate, upgrade +from flask.ext.migrate import Migrate, upgrade, stamp from raven.contrib.flask import Sentry from web import main, db, mail @@ -15,6 +15,15 @@ from utils import minimal_round app = Flask(__name__) +def pre_alembic_db(): + """ Checks if we are migrating from a pre-alembic ihatemoney + """ + con = db.engine.connect() + tables_exist = db.engine.dialect.has_table(con, 'project') + alembic_setup = db.engine.dialect.has_table(con, 'alembic_version') + return tables_exist and not alembic_setup + + def configure(): """ A way to (re)configure the app, specially reset the settings """ @@ -49,6 +58,11 @@ db.app = app # db migrations migrate = Migrate(app, db) +if pre_alembic_db(): + with app.app_context(): + # fake the first migration + stamp(revision='b9a10d5d63ce') + # auto-execute migrations on runtime with app.app_context(): upgrade() |
