Commit 425c1939ceb8c9f8b12094610c51686b60f6e789

Authored by hitier
1 parent 716b68ce

Move migrate init to upper wrapper

Showing 2 changed files with 15 additions and 5 deletions   Show diff stats
app/__init__.py
... ... @@ -3,11 +3,8 @@ import sys
3 3  
4 4 from flask import Flask
5 5  
6   -from flask_migrate import Migrate
7   -
8 6 from app.models import db
9 7  
10   -migrate = Migrate()
11 8  
12 9 # Please, set a config file on top project dir
13 10 # find example in ressources/pdc_config.py
... ... @@ -50,8 +47,6 @@ def create_app(config_class=None):
50 47  
51 48 db.init_app(app)
52 49  
53   - migrate.init_app(app, db)
54   -
55 50 # Get and activate blueprints
56 51 #
57 52 from .main import bp as main_bp
... ...
pdc_web.py
... ... @@ -19,3 +19,18 @@ pdc_app = create_app()
19 19 # see app/cli/__init__.py for more details.
20 20 #
21 21 pdc_app.register_blueprint(cli_bp)
  22 +
  23 +
  24 +#
  25 +# Allow db migrations
  26 +#
  27 +# for help run
  28 +# flask db
  29 +# or just
  30 +# flask upgrade
  31 +#
  32 +from app.models import db
  33 +from flask_migrate import Migrate
  34 +migrate = Migrate()
  35 +migrate.init_app(pdc_app, db)
  36 +
... ...