Skip to content

Commit

Permalink
- Fix syntax error with python3.8.10. (#265)
Browse files Browse the repository at this point in the history
- Fix sql generate error. (#263)
  • Loading branch information
long2ice committed Sep 26, 2022
1 parent 9da9982 commit 28d19a4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 0.7

### 0.7.1rc2

- Fix syntax error with python3.8.10. (#265)
- Fix sql generate error. (#263)

### 0.7.1rc1

- Fix postgres sql error (#263)
Expand Down
25 changes: 11 additions & 14 deletions aerich/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,17 @@
from aerich.models import MAX_VERSION_LENGTH, Aerich
from aerich.utils import get_app_connection, get_models_describe, is_default_function

MIGRATE_TEMPLATE = """from typing import List
MIGRATE_TEMPLATE = """from tortoise import BaseDBAsyncClient
from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> str:
return \"\"\"
{upgrade_sql}\"\"\"
async def upgrade(db: BaseDBAsyncClient) -> List[str]:
return [
{upgrade_sql}
]
async def downgrade(db: BaseDBAsyncClient) -> List[str]:
return [
{downgrade_sql}
]
async def downgrade(db: BaseDBAsyncClient) -> str:
return \"\"\"
{downgrade_sql}\"\"\"
"""


Expand All @@ -52,7 +48,7 @@ class Migrate:
_db_version: Optional[str] = None

@classmethod
def get_all_version_files(cls) -> list[str]:
def get_all_version_files(cls) -> List[str]:
return sorted(
filter(lambda x: x.endswith("py"), os.listdir(cls.migrate_location)),
key=lambda x: int(x.split("_")[0]),
Expand Down Expand Up @@ -125,9 +121,10 @@ async def _generate_diff_py(cls, name):

version_file = Path(cls.migrate_location, version)
content = MIGRATE_TEMPLATE.format(
upgrade_sql=",\n ".join(map(lambda x: f"'{x}'", cls.upgrade_operators)),
downgrade_sql=",\n ".join(map(lambda x: f"'{x}'", cls.downgrade_operators)),
upgrade_sql=";\n ".join(cls.upgrade_operators) + ";",
downgrade_sql=";\n ".join(cls.downgrade_operators) + ";",
)

with open(version_file, "w", encoding="utf-8") as f:
f.write(content)
return version
Expand Down
2 changes: 1 addition & 1 deletion aerich/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.1rc1"
__version__ = "0.7.1rc2"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aerich"
version = "0.7.1rc1"
version = "0.7.1rc2"
description = "A database migrations tool for Tortoise ORM."
authors = ["long2ice <long2ice@gmail.com>"]
license = "Apache-2.0"
Expand Down
2 changes: 0 additions & 2 deletions tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class User(Model):
last_login = fields.DatetimeField(description="Last Login", default=datetime.datetime.now)
is_active = fields.BooleanField(default=True, description="Is Active")
is_superuser = fields.BooleanField(default=False, description="Is SuperUser")
intro = fields.TextField(default="")
longitude = fields.DecimalField(max_digits=10, decimal_places=8)


class Email(Model):
Expand Down

0 comments on commit 28d19a4

Please sign in to comment.