为initdb添加中文注释
This commit is contained in:
parent
7b7828daa0
commit
1c82ab47dd
@ -5,17 +5,17 @@ from config import SYSTEM_ADMIN_CONFIG
|
|||||||
from services.auth import get_password_hash
|
from services.auth import get_password_hash
|
||||||
|
|
||||||
async def init_db(engine: AsyncEngine):
|
async def init_db(engine: AsyncEngine):
|
||||||
"""Initialize database"""
|
"""初始化数据库"""
|
||||||
async with engine.begin() as conn:
|
async with engine.begin() as conn:
|
||||||
# Create all tables
|
# 创建所有表
|
||||||
await conn.run_sync(Base.metadata.create_all)
|
await conn.run_sync(Base.metadata.create_all)
|
||||||
|
|
||||||
# Check if system admin exists
|
# 检查系统管理员是否存在
|
||||||
result = await conn.execute(
|
result = await conn.execute(
|
||||||
select(User).where(User.role == UserRole.SYSTEM_ADMIN)
|
select(User).where(User.role == UserRole.SYSTEM_ADMIN)
|
||||||
)
|
)
|
||||||
if not result.scalars().first():
|
if not result.scalars().first():
|
||||||
# Create default system admin
|
# 创建默认系统管理员
|
||||||
admin = User(
|
admin = User(
|
||||||
username=SYSTEM_ADMIN_CONFIG['username'],
|
username=SYSTEM_ADMIN_CONFIG['username'],
|
||||||
password=get_password_hash(SYSTEM_ADMIN_CONFIG['password']),
|
password=get_password_hash(SYSTEM_ADMIN_CONFIG['password']),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user