mirror of
https://github.com/django/django.git
synced 2025-10-30 09:06:13 +00:00
Fixed #24595 -- Prevented loss of null info in MySQL field alteration
Thanks Simon Percivall for the report, and Simon Charette and Tim Graham for the reviews.
This commit is contained in:
@@ -61,3 +61,11 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
||||
# index creation for FKs (index automatically created by MySQL)
|
||||
field.db_index = False
|
||||
return super(DatabaseSchemaEditor, self)._model_indexes_sql(model)
|
||||
|
||||
def _alter_column_type_sql(self, table, old_field, new_field, new_type):
|
||||
# Keep null property of old field, if it has changed, it will be handled separately
|
||||
if old_field.null:
|
||||
new_type += " NULL"
|
||||
else:
|
||||
new_type += " NOT NULL"
|
||||
return super(DatabaseSchemaEditor, self)._alter_column_type_sql(table, old_field, new_field, new_type)
|
||||
|
||||
Reference in New Issue
Block a user