From 6fea75db2b4c66dbaa71cba0ec33432656efd333 Mon Sep 17 00:00:00 2001 From: Waket Zheng Date: Sat, 15 Aug 2026 00:30:09 +0800 Subject: [PATCH 1/3] fix: python type changed when upgrading tortoise to v1 --- aerich/migrate.py | 12 +++++++++++- uv.lock | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/aerich/migrate.py b/aerich/migrate.py index 28ae3a9..4fbe80a 100644 --- a/aerich/migrate.py +++ b/aerich/migrate.py @@ -23,6 +23,7 @@ from aerich.coder import load_index from aerich.ddl import BaseDDL from aerich.enums import Color +from aerich.exceptions import NotSupportError from aerich.models import MAX_VERSION_LENGTH, Aerich from aerich.utils import ( decompress_dict, @@ -1022,11 +1023,20 @@ def _handle_field_changes( elif option == "description": # change comment cls._add_operator(cls._set_comment(model, new_data_field), upgrade) + elif option == "python-type": + # When upgrade tortoise-orm from 0.x to 1.x + # JSONField[Union[dict, list]] -> JSONField[dict | list] + continue else: if modified or (action != "change" and old_new == [("db_default", "__NOT_SET__")]): continue # modify column - cls._add_operator(cls._modify_field(model, new_data_field), upgrade) + try: + sql = cls._modify_field(model, new_data_field) + except NotSupportError: + click.echo(f"{model = }; {field_name = }; {change = }") + raise + cls._add_operator(sql, upgrade) modified = True @classmethod diff --git a/uv.lock b/uv.lock index 6843f88..08e2105 100644 --- a/uv.lock +++ b/uv.lock @@ -1541,7 +1541,7 @@ wheels = [ [[package]] name = "tortoise-orm" -version = "1.1.7" +version = "1.1.8" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "aiosqlite" }, @@ -1551,9 +1551,9 @@ dependencies = [ { name = "tomlkit", marker = "python_full_version < '3.11'" }, { name = "typing-extensions", marker = "python_full_version < '3.11'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/1d/55/e75d3ae0dd2c96cf961bf068f465fb62ec481d802beb65f406620bfd40a0/tortoise_orm-1.1.7.tar.gz", hash = "sha256:a0f0f27f9c92547739f0a3f0862c257ab64d8baadbc0e548cbcfa2d70bcbe275", size = 387489, upload-time = "2026-03-21T20:03:29.087Z" } +sdist = { url = "https://files.pythonhosted.org/packages/10/8c/059f284ed7a08e9cf3a45973e2b9d013a8f242fbb1051a06c3d60c638920/tortoise_orm-1.1.8.tar.gz", hash = "sha256:09e27be9db148824dacea470d01018ab571676f94aa5428a05bcaec44c413ec7", size = 398141, upload-time = "2026-08-10T10:46:46.452Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/bf/9b/e7e5b4f4e9433b9d9c389afc62ea0ed2597626842dc0f76dd7b54eb32cdd/tortoise_orm-1.1.7-py3-none-any.whl", hash = "sha256:b640b786905891cc120aa16d1a7af18cd54b111a812f9b1c1d1c7b294d62949d", size = 272437, upload-time = "2026-03-21T20:03:27.539Z" }, + { url = "https://files.pythonhosted.org/packages/8a/52/5508cea1339bf9de5016a1ace71e2cca51faf07c54cf54dc3d3ce25e07e1/tortoise_orm-1.1.8-py3-none-any.whl", hash = "sha256:3f771365c54297543b3b2b7fab4ecb03e89de0a68a41328d2e171c043e08e911", size = 278732, upload-time = "2026-08-10T10:46:44.795Z" }, ] [package.optional-dependencies] From 049f33c395c249fb9770cc8a76cc0a8ecd0152bd Mon Sep 17 00:00:00 2001 From: Waket Zheng Date: Sun, 16 Aug 2026 16:35:45 +0800 Subject: [PATCH 2/3] ci: add tortoise upgrading test --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc3a8b0..8419ac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,15 @@ jobs: - name: Run tests for sqlite run: just test_sqlite + - name: Verify tortoise upgrading for sqlite migrations + if: matrix.tortoise-orm == 'tortoise025' + run: | + TEST_DB=sqlite://db.sqlite3 aerich init-db + TEST_DB=sqlite://db.sqlite3 aerich migrate + TEST_DB=sqlite://db.sqlite3 aerich upgrade + uv pip install --upgrade "tortoise-orm>=1.1" + TEST_DB=sqlite://db.sqlite3 aerich migrate + TEST_DB=sqlite://db.sqlite3 aerich upgrade - name: Show test coverage run: just report From fa7a98fa73fa53d2cba13e06d2b28d2624b6f549 Mon Sep 17 00:00:00 2001 From: Waket Zheng Date: Sun, 16 Aug 2026 17:06:20 +0800 Subject: [PATCH 3/3] chore: bump version to dev2 --- aerich/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerich/version.py b/aerich/version.py index 1527635..70fa20f 100644 --- a/aerich/version.py +++ b/aerich/version.py @@ -1 +1 @@ -__version__ = "0.10.1.dev1" +__version__ = "0.10.1.dev2"