Skip to content

Commit

Permalink
db: auto setup on initial runs
Browse files Browse the repository at this point in the history
  • Loading branch information
div72 committed Jul 28, 2022
1 parent e91d9f3 commit a9b38c2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions formie/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

import sqlalchemy
from flask import redirect, render_template, url_for, Flask

from formie import auth, forms, models
Expand All @@ -21,6 +22,11 @@ def create_app() -> Flask:
app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1
)

with app.app_context():
try:
models.Form.query.all()
except sqlalchemy.exc.OperationalError:
models.db.create_all()

@app.route("/")
def index():
Expand Down

0 comments on commit a9b38c2

Please sign in to comment.