diff --git a/cliapp/cliapp/cli.py b/cliapp/cliapp/cli.py index cd24595..9c16f09 100644 --- a/cliapp/cliapp/cli.py +++ b/cliapp/cliapp/cli.py @@ -57,13 +57,15 @@ def create_app(slug, name): obj.name = name obj.slug = slug - app = db.session.query(App).filter_by(slug=slug).first() + app_obj = App.query.filter_by(slug=slug).first() - if app is not None: - db.session.add(obj) - db.session.commit() - else: + if app_obj: current_app.logger.info(f"App definition: {name} ({slug}) already exists in database") + return + + db.session.add(obj) + db.session.commit() + current_app.logger.info(f"App definition: {name} ({slug}) created")