Wrap migration initialization into a function
@@ -9,23 +9,26 @@ log = logging.getLogger(__name__)
def create_app():
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = DB.SQLALCHEMY_DATABASE_URI
- app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
+ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
db.init_app(app)
return app
-db = flask_sqlalchemy.SQLAlchemy()
-flask_app = create_app()
-
-
-# TODO Refactor
+def init_migrations(app):
from flask_migrate import Migrate
from tensorhive.models.User import User
from tensorhive.models.Reservation import Reservation
-from tensorhive.models.RevokedToken import RevokedToken
from tensorhive.models.Role import Role
-migrate = Migrate(flask_app, db)
+ from tensorhive.models.RevokedToken import RevokedToken
+ Migrate(app, db)
+
+
+db = flask_sqlalchemy.SQLAlchemy()
+flask_app = create_app()
+migrate = init_migrations(flask_app)
+
+# TODO Refactor, delete things we dont't need. Prepare tests first!
def init_db() -> None:
'''Creates the database, tables (if they does not exist)'''
# Import all modules that define models so that
