Merge commit '026c837b919ab4380e8a6e6c052364bbf9bbe8a3' as 'core'
This commit is contained in:
18
core/scripts/init_db.py
Normal file
18
core/scripts/init_db.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""数据库初始化 - 创建所有表"""
|
||||
import asyncio
|
||||
import sys
|
||||
sys.path.insert(0, "../backend")
|
||||
|
||||
from app.core.database import engine, Base
|
||||
from app.models import * # noqa: F401, F403
|
||||
|
||||
|
||||
async def init():
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
print("All tables created successfully!")
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(init())
|
||||
Reference in New Issue
Block a user