add check if the app exists in DB before creating it

This commit is contained in:
Davor 2022-06-21 14:54:01 +02:00
parent c88d7ebc08
commit 4c6a9bc8c9

View file

@ -57,8 +57,14 @@ def create_app(slug, name):
obj.name = name
obj.slug = slug
db.session.add(obj)
db.session.commit()
app = db.session.query(App).filter_by(slug=slug).first()
if app is not None:
db.session.add(obj)
db.session.commit()
else:
current_app.logger.info(f"App definition: {name} ({slug}) already exists in database")
@app_cli.command("list")