tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
804 stars 90 forks source link

`make test_postgres` failed with `tortoise-orm>=0.21` #344

Closed waketzheng closed 4 weeks ago

waketzheng commented 1 month ago

How to reproduce

poetry run pip install 'tortoise-orm>=0.21'
poetry run make test_postgres

Error detail

...
>           assert not set(Migrate.upgrade_operators).symmetric_difference(expected_upgrade_operators)
E           assert not {'ALTER TABLE "category" ALTER COLUMN "user_id" TYPE INT USING "user_id"::INT'}
E            +  where {'ALTER TABLE "category" ALTER COLUMN "user_id" TYPE INT USING "user_id"::INT'} = <built-in method symmetric_difference of set object at 0x10e146a80>({'ALTER TABLE "category" ALTER COLUMN "created_at" TYPE TIMESTAMPTZ USING "created_at"::TIMESTAMPTZ', 'ALTER TABLE "category" ALTER COLUMN "name" DROP NOT NULL', 'ALTER TABLE "category" ALTER COLUMN "slug" TYPE VARCHAR(100) USING "slug"::VARCHAR(100)', 'ALTER TABLE "config" ADD "user_id" INT NOT NULL', 'ALTER TABLE "config" ADD CONSTRAINT "fk_config_user_17daa970" FOREIGN KEY ("user_id") REFERENCES "user" ("id") ON DELETE CASCADE', 'ALTER TABLE "config" ALTER COLUMN "status" DROP DEFAULT', ...})
...

Why

tortoise-orm changes IntField constraints to {"ge": -2147483648,"le": 2147483647}

I will try to make a PR later