seed roles in seed_db
This commit is contained in:
parent
2aca3bee15
commit
c35f622d24
1 changed files with 6 additions and 16 deletions
|
@ -4,9 +4,9 @@ import os
|
|||
|
||||
from flask.cli import FlaskGroup
|
||||
from app import app, db
|
||||
from models import User
|
||||
from models import Role, User
|
||||
|
||||
from flask_migrate import Migrate
|
||||
from flask_migrate import Migrate, upgrade
|
||||
|
||||
cli = FlaskGroup(app)
|
||||
|
||||
|
@ -19,25 +19,15 @@ def create_db():
|
|||
db.create_all()
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@cli.command("seed_db")
|
||||
def seed_db():
|
||||
db.session.add(User(email="daniel@deflax.net"))
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@cli.command("upgrade_db")
|
||||
def upgrade_db():
|
||||
"""Run deployment tasks."""
|
||||
from flask_migrate import upgrade
|
||||
from app.models import Role, User
|
||||
|
||||
# migrate database to latest revision
|
||||
upgrade()
|
||||
|
||||
# create user roles
|
||||
Role.insert_roles()
|
||||
|
||||
@cli.command("upgrade_db")
|
||||
def upgrade_db():
|
||||
# migrate database to latest revision
|
||||
upgrade()
|
||||
|
||||
@cli.command("restore_db")
|
||||
def restore_db(restore_file):
|
||||
|
|
Loading…
Reference in a new issue