Changes between Version 1 and Version 2 of Ticket #28832
- Timestamp:
- Nov 22, 2017, 2:13:05 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28832
- Property Component Database layer (models, ORM) → Migrations
-
Ticket #28832 – Description
v1 v2 1 1 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: 2 2 {{{ 3 3 migrations.AlterOrderWithRespectTo( 4 4 name='entry', 5 5 order_with_respect_to=None, 6 6 ), 7 7 }}} 8 8 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 ... 9 9 {{{ 10 10 ERROR 2017-11-22 16:51:18,081 exception 8 140423074580224 Internal Server Error: 11 11 DETAIL: Failing row contains (276, , 2017-11-22, U, 9, 1, null, ). 12 12 }}} 13 13 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. 14 14 15 _order field I'm presuming is only used by the order_with_respect_to tag. It doesn't seem to be created when a 16 17 order = [ ' score ' ] 18 command is used. 15 _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. 19 16 20 17 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.