|
@@ -18,6 +18,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
|
|
"REFERENCES %(to_table)s (%(to_column)s) DEFERRABLE INITIALLY DEFERRED"
|
|
|
)
|
|
|
sql_create_column_inline_fk = sql_create_inline_fk
|
|
|
+ sql_delete_column = "ALTER TABLE %(table)s DROP COLUMN %(column)s"
|
|
|
sql_create_unique = "CREATE UNIQUE INDEX %(name)s ON %(table)s (%(columns)s)"
|
|
|
sql_delete_unique = "DROP INDEX %(name)s"
|
|
|
|
|
@@ -400,6 +401,15 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
|
|
if field.remote_field.through._meta.auto_created:
|
|
|
self.delete_model(field.remote_field.through)
|
|
|
# For explicit "through" M2M fields, do nothing
|
|
|
+ elif (
|
|
|
+ self.connection.features.can_alter_table_drop_column
|
|
|
+ # Primary keys, unique fields, and foreign keys are not
|
|
|
+ # supported in ALTER TABLE DROP COLUMN.
|
|
|
+ and not field.primary_key
|
|
|
+ and not field.unique
|
|
|
+ and not (field.remote_field and field.db_constraint)
|
|
|
+ ):
|
|
|
+ super().remove_field(model, field)
|
|
|
# For everything else, remake.
|
|
|
else:
|
|
|
# It might not actually have a column behind it
|