Skip to content
This repository has been archived by the owner on Jan 25, 2020. It is now read-only.

Commit

Permalink
issue #55: database schema is created, if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
liraisokay committed Sep 1, 2019
1 parent 0f48e9c commit cadade3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,14 @@ def get_link(self):

def get_random_jokes_from_db(number=1):
return Joke.query.order_by(sqlalchemy.func.random()).limit(number)


def check_database_schema_existence():
try:
test_user_id = 1
User.query.get(test_user_id)
except sqlalchemy.exc.OperationalError:
db.create_all()


check_database_schema_existence()

0 comments on commit cadade3

Please sign in to comment.