File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -298,8 +298,10 @@ async def startup_event():
298298 from .database .core import ( # make_admin_by_identity,
299299 REQUIRED_REVISION ,
300300 UninitializedDatabase ,
301+ DatabaseUpgradeNeeded ,
301302 check_database ,
302303 initialize_database ,
304+ upgrade ,
303305 )
304306
305307 connect_args = {}
@@ -317,6 +319,12 @@ async def startup_event():
317319 )
318320 initialize_database (engine )
319321 logger .info ("Database initialized." )
322+ except DatabaseUpgradeNeeded :
323+ logger .info (
324+ f"Database at { redacted_url } is out of date. Upgrading to { REQUIRED_REVISION } ..."
325+ )
326+ upgrade (engine , REQUIRED_REVISION )
327+ logger .info ("Database upgraded." )
320328 else :
321329 logger .info (f"Connected to existing database at { redacted_url } ." )
322330 # SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
You can’t perform that action at this time.
0 commit comments