Develop shell command for instantiating all DB tables fast, import all models

This commit is contained in:
Xevion
2022-03-27 09:44:54 -05:00
parent 5ebbbd1b03
commit ced2f975ae
3 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -25,7 +25,7 @@ def create_app():
login_manager.login_view = 'auth.login'
login_manager.init_app(app)
from .models import User
from .models import User, Post, Comment
@login_manager.user_loader
def load_user(user_id):
@@ -82,4 +82,8 @@ def create_app():
print(f'Committing {len(users)} users into DB.')
db.session.commit()
@app.cli.command("create_all")
def db_create_all() -> None:
db.create_all(app=app)
return app