Changes between Initial Version and Version 1 of Ticket #31686


Ignore:
Timestamp:
Jun 10, 2020, 9:09:17 PM (4 years ago)
Author:
Rik
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31686 – Description

    initial v1  
    33Data migrations don't fix this, they update existing rows, you still have the problem if the old version of the code tries to add a new row to the table with the new schema. To make the new table schema backwards compatible we need to set a default value on the new column. Or it should allow `NULL` values of course, but this is not always what you want.
    44
    5 I have found the location in the code where this should be fixed. This line in the code sets `drop=True` which drops the default value from a column. This seems to happen if the column type support default values and if there is a default value set on the model. So Django always gets rid of the default value in the database.
     5I have found the location in the code where this should be fixed. This line in the code sets `drop=True` which drops the default value from a column. This seems to happen if the column type support default values and if there is a default value set on the model. So Django always gets rid of the default value in the database:
     6
     7https://github.com/django/django/blob/678c8dfee458cda77fce0d1c127f1939dc134584/django/db/backends/base/schema.py#L489
    68
    79It would be great if we can add a database settings where you can tell Django to also set the default in the database. Something like:
Back to Top