diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..b786a6d Binary files /dev/null and b/.DS_Store differ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..32c4982 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.pythonPath": "venv/bin/python", + "python.formatting.provider": "black" +} \ No newline at end of file diff --git a/aerich/cli.py b/aerich/cli.py index eb14768..490af35 100644 --- a/aerich/cli.py +++ b/aerich/cli.py @@ -117,6 +117,11 @@ async def upgrade(ctx: Context): click.secho("No migrate items", fg=Color.yellow) +def abort_if_false(ctx, param, value): + if not value: + ctx.abort() + + @cli.command(help="Downgrade to specified version.") @click.option( "-v", @@ -127,6 +132,9 @@ async def upgrade(ctx: Context): help="Specified version, default to last.", ) @click.pass_context +@click.confirmation_option( + prompt="Downgrade is dangerous, which maybe lose your data, are you sure?", +) @coro async def downgrade(ctx: Context, version: int): app = ctx.obj["app"] @@ -191,7 +199,7 @@ async def history(ctx: Context): help="Tortoise-ORM config module dict variable, like settings.TORTOISE_ORM.", ) @click.option( - "--location", default="./migrations", show_default=True, help="Migrate store location." + "--location", default="./migrations", show_default=True, help="Migrate store location.", ) @click.pass_context @coro @@ -247,7 +255,7 @@ async def init_db(ctx: Context, safe): version = await Migrate.generate_version() await Aerich.create( - version=version, app=app, content=Migrate.get_models_content(config, app, location) + version=version, app=app, content=Migrate.get_models_content(config, app, location), ) with open(os.path.join(dirname, version), "w", encoding="utf-8") as f: content = {