We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 18fdc01 commit 318fdabCopy full SHA for 318fdab
1 file changed
src/core/init_app.py
@@ -1,4 +1,3 @@
1
-import shutil
2
from functools import partial
3
4
from aerich import Command
@@ -220,12 +219,12 @@ async def init_db():
220
219
await command.init()
221
try:
222
await command.migrate(no_input=True)
223
- except AttributeError:
224
- logger.warning(
225
- "unable to retrieve model history from database, model history will be created from scratch"
226
- )
227
- shutil.rmtree("migrations")
228
- await command.init_db(safe=True)
+ except AttributeError as e:
+ logger.error(f"数据库迁移失败: {e}")
+ logger.warning("请手动检查数据库和migrations状态")
+ # 不再自动删除migrations文件夹,避免意外丢失迁移历史
+ # 如需重置migrations,请手动执行:rm -rf migrations && uv run aerich init-db
+ raise RuntimeError("数据库迁移失败,请检查数据库连接和migrations状态") from e
229
230
await command.upgrade(run_in_transaction=True)
231
0 commit comments