From 1c82ab47ddd0ae58816e807a30fac7329d5431be Mon Sep 17 00:00:00 2001 From: carry <2641257231@qq.com> Date: Tue, 21 Jan 2025 13:30:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BAinitdb=E6=B7=BB=E5=8A=A0=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/init_db.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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']),