Skip to content

Commit

Permalink
Remove the use of before_first_request
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli authored and jeffwidman committed Nov 16, 2023
1 parent f959951 commit 678c38e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions example/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@
db = SQLAlchemy(app)
toolbar = DebugToolbarExtension(app)

with app.app_context():
db.create_all()


class ExampleModel(db.Model):
__tablename__ = 'examples'
value = db.Column(db.String(100), primary_key=True)


@app.before_first_request
def setup():
db.create_all()


@app.route('/')
def index():
app.logger.info("Hello there")
Expand Down
8 changes: 3 additions & 5 deletions test/basic_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@
toolbar = DebugToolbarExtension(app)
db = SQLAlchemy(app)

with app.app_context():
db.create_all()


class Foo(db.Model):
__tablename__ = 'foo'
id = db.Column(db.Integer, primary_key=True)


@app.before_first_request
def setup():
db.create_all()


@app.route('/')
def index():
Foo.query.filter_by(id=1).all()
Expand Down

0 comments on commit 678c38e

Please sign in to comment.