Skip to content

Commit

Permalink
Merge pull request #180 from aiondemand/bugfix/create_triggers_once
Browse files Browse the repository at this point in the history
Making sure the deletion triggers are created once
  • Loading branch information
josvandervelde authored Nov 9, 2023
2 parents 9a3834c + 1e96b86 commit a6bebc9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def create_app() -> FastAPI:
},
)
engine = sqlmodel_engine(args.rebuild_db)
add_delete_triggers(AIoDConcept)
with engine.connect() as connection:
AIoDConcept.metadata.create_all(connection, checkfirst=True)
connection.commit()
Expand All @@ -102,6 +101,11 @@ def create_app() -> FastAPI:
session.add_all([Platform(name=name) for name in PlatformName])
session.commit()

# this is a bit of a hack: instead of checking whether the triggers exist, we check
# whether platforms are already present. If platforms were not present, the db is
# empty, and so the triggers should still be added.
add_delete_triggers(AIoDConcept)

add_routes(app, engine, url_prefix=args.url_prefix)
return app

Expand Down

0 comments on commit a6bebc9

Please sign in to comment.