diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fd0caa6..367ce4f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ ChangeLog 0.2.1 ----- - Fix bug in windows. +- Enhance PostgreSQL support. 0.2.0 ----- diff --git a/aerich/ddl/postgres/__init__.py b/aerich/ddl/postgres/__init__.py index 88b2de2..1bac896 100644 --- a/aerich/ddl/postgres/__init__.py +++ b/aerich/ddl/postgres/__init__.py @@ -1,3 +1,6 @@ +from typing import Type + +from tortoise import Model from tortoise.backends.asyncpg.schema_generator import AsyncpgSchemaGenerator from tortoise.fields import Field diff --git a/tests/test_ddl.py b/tests/test_ddl.py index b07ba1a..999b8e8 100644 --- a/tests/test_ddl.py +++ b/tests/test_ddl.py @@ -73,7 +73,10 @@ def test_modify_column(): ret = Migrate.ddl.modify_column(User, User._meta.fields_map.get("is_active")) if isinstance(Migrate.ddl, MysqlDDL): - assert ret == "ALTER TABLE `user` MODIFY COLUMN `is_active` BOOL NOT NULL" + assert ( + ret + == "ALTER TABLE `user` MODIFY COLUMN `is_active` BOOL NOT NULL COMMENT 'Is Active' DEFAULT 1" + ) elif isinstance(Migrate.ddl, PostgresDDL): assert ret == 'ALTER TABLE "user" ALTER COLUMN "is_active" TYPE BOOL' else: @@ -88,7 +91,7 @@ def test_alter_column_default(): if isinstance(Migrate.ddl, PostgresDDL): assert ret == 'ALTER TABLE "category" ALTER COLUMN "name" DROP DEFAULT' else: - assert ret == None + assert ret is None ret = Migrate.ddl.alter_column_default(Category, Category._meta.fields_map.get("created_at")) if isinstance(Migrate.ddl, PostgresDDL): @@ -96,13 +99,13 @@ def test_alter_column_default(): ret == 'ALTER TABLE "category" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP' ) else: - assert ret == None + assert ret is None ret = Migrate.ddl.alter_column_default(User, User._meta.fields_map.get("avatar")) if isinstance(Migrate.ddl, PostgresDDL): assert ret == 'ALTER TABLE "user" ALTER COLUMN "avatar" SET DEFAULT \'\'' else: - assert ret == None + assert ret is None def test_alter_column_null(): @@ -110,7 +113,7 @@ def test_alter_column_null(): if isinstance(Migrate.ddl, PostgresDDL): assert ret == 'ALTER TABLE "category" ALTER COLUMN "name" SET NOT NULL' else: - assert ret == None + assert ret is None def test_set_comment(): @@ -118,13 +121,13 @@ def test_set_comment(): if isinstance(Migrate.ddl, PostgresDDL): assert ret == 'COMMENT ON COLUMN "category"."name" IS NULL' else: - assert ret == None + assert ret is None ret = Migrate.ddl.set_comment(Category, Category._meta.fields_map.get("user")) if isinstance(Migrate.ddl, PostgresDDL): assert ret == 'COMMENT ON COLUMN "category"."user" IS \'User\'' else: - assert ret == None + assert ret is None def test_drop_column():