From c7dddc01d6ca8d8d89f84d26123ecb021aa2a108 Mon Sep 17 00:00:00 2001 From: Adam Chainz Date: Sat, 5 Nov 2016 22:23:57 +0100 Subject: [PATCH] Fixed #27441 -- Improved SQL for 'DROP COLUMN' on MySQL 'CASCADE' is an undocumented no-op in MySQL, so to avoid confusion Django no longer outputs it. --- django/db/backends/mysql/schema.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/django/db/backends/mysql/schema.py b/django/db/backends/mysql/schema.py index 4a61807234..f89088ef5b 100644 --- a/django/db/backends/mysql/schema.py +++ b/django/db/backends/mysql/schema.py @@ -9,6 +9,10 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): sql_alter_column_null = "MODIFY %(column)s %(type)s NULL" sql_alter_column_not_null = "MODIFY %(column)s %(type)s NOT NULL" sql_alter_column_type = "MODIFY %(column)s %(type)s" + + # 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"