diff --git a/services/init_db.py b/services/init_db.py index d285adb..23c8125 100644 --- a/services/init_db.py +++ b/services/init_db.py @@ -5,17 +5,17 @@ from config import SYSTEM_ADMIN_CONFIG from services.auth import get_password_hash async def init_db(engine: AsyncEngine): - """Initialize database""" + """初始化数据库""" async with engine.begin() as conn: - # Create all tables + # 创建所有表 await conn.run_sync(Base.metadata.create_all) - # Check if system admin exists + # 检查系统管理员是否存在 result = await conn.execute( select(User).where(User.role == UserRole.SYSTEM_ADMIN) ) if not result.scalars().first(): - # Create default system admin + # 创建默认系统管理员 admin = User( username=SYSTEM_ADMIN_CONFIG['username'], password=get_password_hash(SYSTEM_ADMIN_CONFIG['password']),