Changes between Version 1 and Version 2 of Ticket #28832


Ignore:
Timestamp:
Nov 22, 2017, 2:13:05 PM (6 years ago)
Author:
Tim Graham
Comment:

Hi, I can't reproduce the problem. Can you provide a minimal sample project that demonstrates the issue?

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28832

    • Property Component Database layer (models, ORM)Migrations
  • Ticket #28832 – Description

    v1 v2  
    11If 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{{{
    33        migrations.AlterOrderWithRespectTo(
    44            name='entry',
    55            order_with_respect_to=None,
    66        ),
    7 
     7}}}
    88and 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{{{
    1010    ERROR 2017-11-22 16:51:18,081 exception 8 140423074580224 Internal Server Error:
    1111    DETAIL:  Failing row contains (276, , 2017-11-22, U, 9, 1, null, ).
    12 
     12}}}
    1313This 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.
    1414
    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.
    1916
    2017So 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.
Back to Top