Opened 7 years ago
Last modified 7 years ago
#28832 closed Bug
django migrations to PostgreSQL not handling order_with_respect_to removals — at Version 2
Reported by: | AJ | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.11 |
Severity: | Normal | Keywords: | order_with_respect_to PostgreSQL makemigrations |
Cc: | talkingtoaj@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
If you change the Meta fields on a model to remove an order_with_respect_to tag, it creates a command in the new migration file like thus:
migrations.AlterOrderWithRespectTo( name='entry', order_with_respect_to=None, ),
and everything works hunky-dory for SQLite. However... push your new code and migration files to a PostgreSQL server, like Heroku, run your migration file and ...
ERROR 2017-11-22 16:51:18,081 exception 8 140423074580224 Internal Server Error: DETAIL: Failing row contains (276, , 2017-11-22, U, 9, 1, null, ).
This little friend starts filling your log files. What does it mean? Well, a little exploration of the database tables show that the second last field that django is trying to assign null value to is the _order field.
_order field I'm presuming is only used by the order_with_respect_to tag. It doesn't seem to be created when an order = [ ' score ' ]
command is used.
So it seems somewhere in the process it realises the _order field isn't needed, is assigning a null value to that column which clashes with a no null constraint. All when it should have simply deleted the _order field column after the migration was run.
An incompatibility bug between django and PostgreSQL perhaps?
Insights anyone?
Change History (2)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Component: | Database layer (models, ORM) → Migrations |
---|---|
Description: | modified (diff) |
Hi, I can't reproduce the problem. Can you provide a minimal sample project that demonstrates the issue?