Fixed -- Used RENAME COLUMN on MariaDB 10.5.2+.
@@ -13,8 +13,6 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
# No 'CASCADE' which works as a no-op in MySQL but is undocumented
sql_delete_column = "ALTER TABLE %(table)s DROP COLUMN %(column)s"
- sql_rename_column = "ALTER TABLE %(table)s CHANGE %(old_column)s %(new_column)s %(type)s"
-
sql_delete_unique = "ALTER TABLE %(table)s DROP INDEX %(name)s"
sql_create_column_inline_fk = (
', ADD CONSTRAINT %(name)s FOREIGN KEY (%(column)s) '
@@ -38,6 +36,12 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
return 'ALTER TABLE %(table)s DROP CONSTRAINT IF EXISTS %(name)s'
return 'ALTER TABLE %(table)s DROP CHECK %(name)s'
+ @property
+ def sql_rename_column(self):
+ if self.connection.mysql_is_mariadb and self.connection.mysql_version >= (10, 5, 2):
+ return super().sql_rename_column
+ return 'ALTER TABLE %(table)s CHANGE %(old_column)s %(new_column)s %(type)s'
+
def quote_value(self, value):
self.connection.ensure_connection()
if isinstance(value, str):
