seed roles in seed_db

This commit is contained in:
deflax 2024-04-01 20:00:56 +03:00
parent 2aca3bee15
commit c35f622d24

View file

@ -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):