Skip to content

Commit

Permalink
Fix empty items
Browse files Browse the repository at this point in the history
  • Loading branch information
long2ice committed Nov 30, 2020
1 parent 4e91749 commit ee6cc20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions aerich/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def upgrade(ctx: Context):
click.secho(f"Success upgrade {version_file}", fg=Color.green)
migrated = True
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.")
Expand Down Expand Up @@ -170,7 +170,8 @@ async def downgrade(ctx: Context, version: int, delete: bool):
content = get_version_content_from_file(file_path)
downgrade_query_list = content.get("downgrade")
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:
await conn.execute_query(downgrade_query)
await version.delete()
Expand Down
5 changes: 4 additions & 1 deletion aerich/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def get_version_content_from_file(version_file: str) -> Dict:
second = len(content) - 1
upgrade_content = content[first + len(_UPGRADE) : second].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


Expand Down

0 comments on commit ee6cc20

Please sign in to comment.