Fixed two problems when using under windows (#286)
* fix: Fixed an issue where an error would occur when using aerich in windows if the profile contained Chinese characters * fix: Automatically delete the empty migration directory of the app if the init-db operation fails * feat: generate migration file in empty directory instead of abort with warning * tests: fix test fail in ci --------- Co-authored-by: Waket Zheng <waketzheng@gmail.com>
This commit is contained in:
@@ -133,7 +133,12 @@ class Command:
|
||||
location = self.location
|
||||
app = self.app
|
||||
dirname = Path(location, app)
|
||||
dirname.mkdir(parents=True)
|
||||
if not dirname.exists():
|
||||
dirname.mkdir(parents=True)
|
||||
else:
|
||||
# If directory is empty, go ahead, otherwise raise FileExistsError
|
||||
for unexpected_file in dirname.glob("*"):
|
||||
raise FileExistsError(str(unexpected_file))
|
||||
|
||||
await Tortoise.init(config=self.tortoise_config)
|
||||
connection = get_app_connection(self.tortoise_config, app)
|
||||
|
||||
@@ -40,7 +40,7 @@ async def cli(ctx: Context, config, app) -> None:
|
||||
raise UsageError(
|
||||
"You need to run `aerich init` first to create the config file.", ctx=ctx
|
||||
)
|
||||
content = config_path.read_text()
|
||||
content = config_path.read_text("utf-8")
|
||||
doc: dict = tomlkit.parse(content)
|
||||
try:
|
||||
tool = cast(Dict[str, str], doc["tool"]["aerich"])
|
||||
|
||||
Reference in New Issue
Block a user