Skip to content

Commit 0350b06

Browse files
Chapter 17: Deploy command (17a)
1 parent 19424c7 commit 0350b06

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

flasky.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import sys
1010
import click
11-
from flask_migrate import Migrate
11+
from flask_migrate import Migrate, upgrade
1212
from app import create_app, db
1313
from app.models import User, Follow, Role, Permission, Post, Comment
1414

@@ -61,4 +61,17 @@ def profile(length, profile_dir):
6161
from werkzeug.contrib.profiler import ProfilerMiddleware
6262
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length],
6363
profile_dir=profile_dir)
64-
app.run(debug=False)
64+
app.run()
65+
66+
67+
@app.cli.command()
68+
def deploy():
69+
"""Run deployment tasks."""
70+
# migrate database to latest revision
71+
upgrade()
72+
73+
# create or update user roles
74+
Role.insert_roles()
75+
76+
# ensure all users are following themselves
77+
User.add_self_follows()

0 commit comments

Comments
 (0)