为initdb添加中文注释

This commit is contained in:
carry 2025-01-21 13:30:33 +08:00
parent 7b7828daa0
commit 1c82ab47dd

View File

@ -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']),