1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Merge remote-tracking branch 'upstream/master'

fix #5
This commit is contained in:
Jocelyn Delande 2016-07-10 17:19:41 +02:00
commit ad91b11a92

View file

@ -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
"""
@ -48,6 +57,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()