reformatted with black
This commit is contained in:
parent
8e783e031e
commit
185514f711
@ -48,7 +48,11 @@ def coro(f):
|
||||
@click.group(context_settings={"help_option_names": ["-h", "--help"]})
|
||||
@click.version_option(__version__, "-V", "--version")
|
||||
@click.option(
|
||||
"-c", "--config", default="aerich.ini", show_default=True, help="Config file.",
|
||||
"-c",
|
||||
"--config",
|
||||
default="aerich.ini",
|
||||
show_default=True,
|
||||
help="Config file.",
|
||||
)
|
||||
@click.option("--app", required=False, help="Tortoise-ORM app name.")
|
||||
@click.option(
|
||||
@ -121,7 +125,9 @@ async def upgrade(ctx: Context):
|
||||
for upgrade_query in upgrade_query_list:
|
||||
await conn.execute_script(upgrade_query)
|
||||
await Aerich.create(
|
||||
version=version_file, app=app, content=get_models_describe(app),
|
||||
version=version_file,
|
||||
app=app,
|
||||
content=get_models_describe(app),
|
||||
)
|
||||
click.secho(f"Success upgrade {version_file}", fg=Color.green)
|
||||
migrated = True
|
||||
@ -215,17 +221,21 @@ 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.option(
|
||||
"-s",
|
||||
"--src_folder", default=".", show_default=False, help="Folder of the source, relative to the project root."
|
||||
"--src_folder",
|
||||
default=".",
|
||||
show_default=False,
|
||||
help="Folder of the source, relative to the project root.",
|
||||
)
|
||||
@click.pass_context
|
||||
@coro
|
||||
async def init(
|
||||
ctx: Context, tortoise_orm, location, src_folder
|
||||
):
|
||||
async def init(ctx: Context, tortoise_orm, location, src_folder):
|
||||
config_file = ctx.obj["config_file"]
|
||||
name = ctx.obj["name"]
|
||||
if Path(config_file).exists():
|
||||
@ -234,8 +244,8 @@ async def init(
|
||||
if os.path.isabs(src_folder):
|
||||
src_folder = os.path.relpath(os.getcwd(), src_folder)
|
||||
# Add ./ so it's clear that this is relative path
|
||||
if not src_folder.startswith('./'):
|
||||
src_folder = './' + src_folder
|
||||
if not src_folder.startswith("./"):
|
||||
src_folder = "./" + 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)
|
||||
@ -287,7 +297,9 @@ async def init_db(ctx: Context, safe):
|
||||
|
||||
version = await Migrate.generate_version()
|
||||
await Aerich.create(
|
||||
version=version, app=app, content=get_models_describe(app),
|
||||
version=version,
|
||||
app=app,
|
||||
content=get_models_describe(app),
|
||||
)
|
||||
content = {
|
||||
"upgrade": [schema],
|
||||
@ -298,7 +310,11 @@ async def init_db(ctx: Context, safe):
|
||||
|
||||
@cli.command(help="Introspects the database tables to standard output as TortoiseORM model.")
|
||||
@click.option(
|
||||
"-t", "--table", help="Which tables to inspect.", multiple=True, required=False,
|
||||
"-t",
|
||||
"--table",
|
||||
help="Which tables to inspect.",
|
||||
multiple=True,
|
||||
required=False,
|
||||
)
|
||||
@click.pass_context
|
||||
@coro
|
||||
|
@ -36,7 +36,8 @@ def get_app_connection_name(config, app_name: str) -> str:
|
||||
if app:
|
||||
return app.get("default_connection", "default")
|
||||
raise BadOptionUsage(
|
||||
option_name="--app", message=f'Can\'t get app named "{app_name}"',
|
||||
option_name="--app",
|
||||
message=f'Can\'t get app named "{app_name}"',
|
||||
)
|
||||
|
||||
|
||||
@ -64,7 +65,7 @@ def get_tortoise_config(ctx: Context, tortoise_orm: str) -> dict:
|
||||
try:
|
||||
config_module = importlib.import_module(config_path)
|
||||
except ModuleNotFoundError as e:
|
||||
raise ClickException(f'Error while importing configuration module: {e}') from None
|
||||
raise ClickException(f"Error while importing configuration module: {e}") from None
|
||||
|
||||
config = getattr(config_module, tortoise_config, None)
|
||||
if not config:
|
||||
|
Loading…
x
Reference in New Issue
Block a user