Opened 5 months ago
Closed 5 months ago
#35624 closed Bug (invalid)
Django doesn't properly migrate IntegerField(default=0)
Reported by: | bedbad | Owned by: | |
---|---|---|---|
Component: | Uncategorized | Version: | 5.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Steps To Reproduce:
- Create a model
class AModel(models.Model): afield = models.IntegerField()
- Migrate AModel into the schema
- Change AMode:
class AModel(models.Model): afield = models.IntegerField(default=0)
- Observe the sql form of migration:
python manage.py sqlmigrate app 0003
It will look like this:
UPDATE `app_amodel` SET `afield` = 0 WHERE `afield` IS NULL; ALTER TABLE `app_amodel` MODIFY `afield` integer NOT NULL;
Expected Behaviour:
UPDATE `app_amodel` SET `afield` = 0 WHERE `afield` IS NULL; ALTER TABLE `app_amodel` MODIFY `afield` integer NOT NULL DEFAULT 0;
Note:
See TracTickets
for help on using tickets.
Please refer to the documentation about
db_default
.TicketClosingReasons/UseSupportChannels