Fix postgre alter null. (#142)
This commit is contained in:
@@ -1 +1 @@
|
||||
__version__ = "0.5.2"
|
||||
__version__ = "0.5.3"
|
||||
|
||||
@@ -227,10 +227,10 @@ class BaseDDL:
|
||||
)
|
||||
|
||||
def alter_column_null(self, model: "Type[Model]", field_describe: dict):
|
||||
raise NotImplementedError
|
||||
return self.modify_column(model, field_describe)
|
||||
|
||||
def set_comment(self, model: "Type[Model]", field_describe: dict):
|
||||
raise NotImplementedError
|
||||
return self.modify_column(model, field_describe)
|
||||
|
||||
def rename_table(self, model: "Type[Model]", old_table_name: str, new_table_name: str):
|
||||
db_table = model._meta.db_table
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
from typing import Type
|
||||
|
||||
from tortoise import Model
|
||||
from tortoise.backends.mysql.schema_generator import MySQLSchemaGenerator
|
||||
|
||||
from aerich.ddl import BaseDDL
|
||||
from aerich.exceptions import NotSupportError
|
||||
|
||||
|
||||
class MysqlDDL(BaseDDL):
|
||||
@@ -29,9 +25,3 @@ class MysqlDDL(BaseDDL):
|
||||
_M2M_TABLE_TEMPLATE = "CREATE TABLE `{table_name}` (`{backward_key}` {backward_type} NOT NULL REFERENCES `{backward_table}` (`{backward_field}`) ON DELETE CASCADE,`{forward_key}` {forward_type} NOT NULL REFERENCES `{forward_table}` (`{forward_field}`) ON DELETE CASCADE){extra}{comment}"
|
||||
_MODIFY_COLUMN_TEMPLATE = "ALTER TABLE `{table_name}` MODIFY COLUMN {column}"
|
||||
_RENAME_TABLE_TEMPLATE = "ALTER TABLE `{old_table_name}` RENAME TO `{new_table_name}`"
|
||||
|
||||
def alter_column_null(self, model: "Type[Model]", field_describe: dict):
|
||||
raise NotSupportError("Alter column null is unsupported in MySQL.")
|
||||
|
||||
def set_comment(self, model: "Type[Model]", field_describe: dict):
|
||||
raise NotSupportError("Alter column comment is unsupported in MySQL.")
|
||||
|
||||
@@ -399,6 +399,9 @@ class Migrate:
|
||||
elif option == "unique":
|
||||
# because indexed include it
|
||||
pass
|
||||
elif option == "nullable":
|
||||
# change nullable
|
||||
cls._add_operator(cls._alter_null(model, new_data_field), upgrade)
|
||||
else:
|
||||
# modify column
|
||||
cls._add_operator(
|
||||
|
||||
Reference in New Issue
Block a user