#28832: django migrations to PostgreSQL not handling order_with_respect_to 
removals
-------------------------------------+-------------------------------------
     Reporter:  AJ                   |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  1.11
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
  order_with_respect_to PostgreSQL   |  Unreviewed
  makemigrations                     |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * component:  Database layer (models, ORM) => Migrations


Old description:

> 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 a
>
>     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?

New description:

 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?

--

Comment:

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

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28832#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.5b64cd85bc76fc711108c298c91d0994%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to