Skip to content

Commit

Permalink
Chapter 17: Deploy command (17a)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Nov 11, 2022
1 parent 44ade21 commit 5d501f6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions flasky.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import sys
import click
from flask_migrate import Migrate
from flask_migrate import Migrate, upgrade
from app import create_app, db
from app.models import User, Follow, Role, Permission, Post, Comment

Expand Down Expand Up @@ -61,4 +61,17 @@ def profile(length, profile_dir):
from werkzeug.contrib.profiler import ProfilerMiddleware
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length],
profile_dir=profile_dir)
app.run(debug=False)
app.run()


@app.cli.command()
def deploy():
"""Run deployment tasks."""
# migrate database to latest revision
upgrade()

# create or update user roles
Role.insert_roles()

# ensure all users are following themselves
User.add_self_follows()

0 comments on commit 5d501f6

Please sign in to comment.