Fix empty items
This commit is contained in:
parent
4e917495a0
commit
ee6cc20c7d
@ -125,7 +125,7 @@ async def upgrade(ctx: Context):
|
|||||||
click.secho(f"Success upgrade {version_file}", fg=Color.green)
|
click.secho(f"Success upgrade {version_file}", fg=Color.green)
|
||||||
migrated = True
|
migrated = True
|
||||||
if not migrated:
|
if not migrated:
|
||||||
click.secho("No items to be migrated", fg=Color.yellow)
|
click.secho("No upgrade items found", fg=Color.yellow)
|
||||||
|
|
||||||
|
|
||||||
@cli.command(help="Downgrade to specified version.")
|
@cli.command(help="Downgrade to specified version.")
|
||||||
@ -170,7 +170,8 @@ async def downgrade(ctx: Context, version: int, delete: bool):
|
|||||||
content = get_version_content_from_file(file_path)
|
content = get_version_content_from_file(file_path)
|
||||||
downgrade_query_list = content.get("downgrade")
|
downgrade_query_list = content.get("downgrade")
|
||||||
if not downgrade_query_list:
|
if not downgrade_query_list:
|
||||||
return click.secho("No downgrade items found", fg=Color.yellow)
|
click.secho("No downgrade items found", fg=Color.yellow)
|
||||||
|
return
|
||||||
for downgrade_query in downgrade_query_list:
|
for downgrade_query in downgrade_query_list:
|
||||||
await conn.execute_query(downgrade_query)
|
await conn.execute_query(downgrade_query)
|
||||||
await version.delete()
|
await version.delete()
|
||||||
|
@ -71,7 +71,10 @@ def get_version_content_from_file(version_file: str) -> Dict:
|
|||||||
second = len(content) - 1
|
second = len(content) - 1
|
||||||
upgrade_content = content[first + len(_UPGRADE) : second].strip() # noqa:E203
|
upgrade_content = content[first + len(_UPGRADE) : second].strip() # noqa:E203
|
||||||
downgrade_content = content[second + len(_DOWNGRADE) :].strip() # noqa:E203
|
downgrade_content = content[second + len(_DOWNGRADE) :].strip() # noqa:E203
|
||||||
ret = {"upgrade": upgrade_content.split(";\n"), "downgrade": downgrade_content.split(";\n")}
|
ret = {
|
||||||
|
"upgrade": list(filter(lambda x: x or False, upgrade_content.split(";\n"))),
|
||||||
|
"downgrade": list(filter(lambda x: x or False, downgrade_content.split(";\n"))),
|
||||||
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user