Fix checking if app exists before inserting into DB
This commit is contained in:
parent
4c6a9bc8c9
commit
812fc41c6e
1 changed files with 7 additions and 5 deletions
|
@ -57,13 +57,15 @@ def create_app(slug, name):
|
||||||
obj.name = name
|
obj.name = name
|
||||||
obj.slug = slug
|
obj.slug = slug
|
||||||
|
|
||||||
app = db.session.query(App).filter_by(slug=slug).first()
|
app_obj = App.query.filter_by(slug=slug).first()
|
||||||
|
|
||||||
|
if app_obj:
|
||||||
|
current_app.logger.info(f"App definition: {name} ({slug}) already exists in database")
|
||||||
|
return
|
||||||
|
|
||||||
if app is not None:
|
|
||||||
db.session.add(obj)
|
db.session.add(obj)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
else:
|
current_app.logger.info(f"App definition: {name} ({slug}) created")
|
||||||
current_app.logger.info(f"App definition: {name} ({slug}) already exists in database")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue