From c60c1610f0dfdb4a8a38ecaf1af49a846d5de2c3 Mon Sep 17 00:00:00 2001 From: long2ice Date: Sun, 12 Dec 2021 22:11:51 +0800 Subject: [PATCH] Fix `pyproject.toml` not existing error. (#217) --- CHANGELOG.md | 4 ++++ aerich/cli.py | 10 ++++++---- aerich/version.py | 2 +- pyproject.toml | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f94f27f..a26a8ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.6 +### 0.6.1 + +- Fix `pyproject.toml` not existing error. (#217) + ### 0.6.0 - Change default config file from `aerich.ini` to `pyproject.toml`. (#197) diff --git a/aerich/cli.py b/aerich/cli.py index 458a923..c3856b6 100644 --- a/aerich/cli.py +++ b/aerich/cli.py @@ -193,10 +193,12 @@ async def init(ctx: Context, tortoise_orm, location, src_folder): # check that we can find the configuration, if not we can fail before the config file gets created add_src_path(src_folder) get_tortoise_config(ctx, tortoise_orm) - - with open(config_file, "r") as f: - content = f.read() - doc = tomlkit.parse(content) + if Path(config_file).exists(): + with open(config_file, "r") as f: + content = f.read() + doc = tomlkit.parse(content) + else: + doc = tomlkit.parse("[tool.aerich]") table = tomlkit.table() table["tortoise_orm"] = tortoise_orm table["location"] = location diff --git a/aerich/version.py b/aerich/version.py index 906d362..43c4ab0 100644 --- a/aerich/version.py +++ b/aerich/version.py @@ -1 +1 @@ -__version__ = "0.6.0" +__version__ = "0.6.1" diff --git a/pyproject.toml b/pyproject.toml index 2e99c7d..e80cbd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aerich" -version = "0.6.0" +version = "0.6.1" description = "A database migrations tool for Tortoise ORM." authors = ["long2ice "] license = "Apache-2.0"