fix: NonExistentKey when running aerich init without [tool] section in config file (#381)

* fix: NonExistentKey when running `aerich init` without `[tool]` section in config file

* docs: update changelog
This commit is contained in:
Waket Zheng
2024-12-11 13:26:18 +08:00
committed by GitHub
parent 3d840395f1
commit 5572876714
3 changed files with 11 additions and 1 deletions

View File

@@ -190,7 +190,10 @@ async def init(ctx: Context, tortoise_orm, location, src_folder) -> None:
table["tortoise_orm"] = tortoise_orm
table["location"] = location
table["src_folder"] = src_folder
doc["tool"]["aerich"] = table
try:
doc["tool"]["aerich"] = table
except KeyError:
doc["tool"] = {"aerich": table}
config_path.write_text(tomlkit.dumps(doc))