Make parent directories as needed
This commit is contained in:
		| @@ -156,7 +156,9 @@ async def downgrade(ctx: Context, version: int, delete: bool): | |||||||
|     if version == -1: |     if version == -1: | ||||||
|         specified_version = await Migrate.get_last_version() |         specified_version = await Migrate.get_last_version() | ||||||
|     else: |     else: | ||||||
|         specified_version = await Aerich.filter(app=app, version__startswith=f"{version}_").first() |         specified_version = await Aerich.filter( | ||||||
|  |             app=app, version__startswith=f"{version}_" | ||||||
|  |         ).first() | ||||||
|     if not specified_version: |     if not specified_version: | ||||||
|         return click.secho("No specified version found", fg=Color.yellow) |         return click.secho("No specified version found", fg=Color.yellow) | ||||||
|     if version == -1: |     if version == -1: | ||||||
| @@ -238,8 +240,7 @@ async def init( | |||||||
|     with open(config_file, "w", encoding="utf-8") as f: |     with open(config_file, "w", encoding="utf-8") as f: | ||||||
|         parser.write(f) |         parser.write(f) | ||||||
|  |  | ||||||
|     if not Path(location).is_dir(): |     Path(location).mkdir(parents=True, exist_ok=True) | ||||||
|         os.mkdir(location) |  | ||||||
|  |  | ||||||
|     click.secho(f"Success create migrate location {location}", fg=Color.green) |     click.secho(f"Success create migrate location {location}", fg=Color.green) | ||||||
|     click.secho(f"Success generate config file {config_file}", fg=Color.green) |     click.secho(f"Success generate config file {config_file}", fg=Color.green) | ||||||
| @@ -261,10 +262,10 @@ async def init_db(ctx: Context, safe): | |||||||
|     app = ctx.obj["app"] |     app = ctx.obj["app"] | ||||||
|  |  | ||||||
|     dirname = Path(location, app) |     dirname = Path(location, app) | ||||||
|     if not dirname.is_dir(): |     try: | ||||||
|         os.mkdir(dirname) |         dirname.mkdir(parents=True) | ||||||
|         click.secho(f"Success create app migrate location {dirname}", fg=Color.green) |         click.secho(f"Success create app migrate location {dirname}", fg=Color.green) | ||||||
|     else: |     except FileExistsError: | ||||||
|         return click.secho( |         return click.secho( | ||||||
|             f"Inited {app} already, or delete {dirname} and try again.", fg=Color.yellow |             f"Inited {app} already, or delete {dirname} and try again.", fg=Color.yellow | ||||||
|         ) |         ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user