This commit is contained in:
2026-03-25 23:59:29 +08:00
parent 7964ce1033
commit 23e5df0364
46 changed files with 4168 additions and 254 deletions
+4 -3
View File
@@ -118,7 +118,7 @@ async def create_admin_user(session):
logger.info(f"创建了管理员账户: {settings.ADMIN_USERNAME}")
async def init_database():
async def init_database(keep_connected: bool = True):
"""初始化数据库"""
try:
await db_manager.connect()
@@ -155,7 +155,8 @@ async def init_database():
print(f"数据库初始化失败: {e}")
return False
finally:
await db_manager.disconnect()
if not keep_connected:
await db_manager.disconnect()
async def ensure_schema_updates():
@@ -184,4 +185,4 @@ async def ensure_schema_updates():
if __name__ == "__main__":
asyncio.run(init_database())
asyncio.run(init_database(keep_connected=False))