﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28832	django migrations to PostgreSQL not handling order_with_respect_to removals	AJ	nobody	"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? "	Bug	new	Database layer (models, ORM)	1.11	Normal		order_with_respect_to PostgreSQL makemigrations	talkingtoaj@…	Unreviewed	0	0	0	0	0	0
