Refs #31411 -- 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+.
This commit is contained in:
Mariusz Felisiak 2020-04-09 11:16:28 +02:00 committed by GitHub
parent 8b7b19f6c9
commit 9cab261427
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -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'