Refs -- Used RENAME COLUMN on MySQL 8.0.4+.
MySQL 8.0.3 added support for this syntax but also imposed a
restriction against ALTER TABLE RENAME on tables in a foreign key
relationship if a LOCK TABLES was active which has been lifted in MySQL
8.0.4+.
@@ -38,7 +38,12 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
@property
def sql_rename_column(self):
- if self.connection.mysql_is_mariadb and self.connection.mysql_version >= (10, 5, 2):
+ # MariaDB >= 10.5.2 and MySQL >= 8.0.4 support an
+ # "ALTER TABLE ... RENAME COLUMN" statement.
+ if self.connection.mysql_is_mariadb:
+ if self.connection.mysql_version >= (10, 5, 2):
+ return super().sql_rename_column
+ elif self.connection.mysql_version >= (8, 0, 4):
return super().sql_rename_column
return 'ALTER TABLE %(table)s CHANGE %(old_column)s %(new_column)s %(type)s'
