File tree Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Original file line number Diff line number Diff line change 6
6
7
7
from . import auth
8
8
from . import jwt
9
- from .models import db
9
+ from .models import init_app as db_init_app
10
10
from . import blueprints
11
11
12
12
@@ -30,12 +30,7 @@ def create_app():
30
30
)
31
31
32
32
# Attach database
33
- db .init_app (app )
34
-
35
- # Migrate database
36
- # FIXME: move db creation stuff into a separate, trackable migration framework
37
- with app .app_context ():
38
- db .create_all ()
33
+ db_init_app (app )
39
34
40
35
# Add oauth interface
41
36
auth .init_app (app )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import click
1
2
from flask import g , current_app
3
+ from flask .cli import with_appcontext
2
4
from flask_sqlalchemy import SQLAlchemy
3
5
from werkzeug .local import LocalProxy
4
6
from werkzeug .contrib .cache import FileSystemCache
7
9
db = SQLAlchemy ()
8
10
9
11
12
+ def init_db ():
13
+ db .create_all ()
14
+
15
+
16
+ @click .command ("init-db" )
17
+ @with_appcontext
18
+ def init_db_command ():
19
+ init_db ()
20
+ click .echo ("Initialized the database." )
21
+
22
+
23
+ def init_app (app ):
24
+ app .cli .add_command (init_db_command )
25
+ db .init_app (app )
26
+
27
+
10
28
class User (db .Model ):
11
29
user_id = db .Column (db .Integer , primary_key = True )
12
30
You can’t perform that action at this time.
0 commit comments