﻿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
22451	Migrations do not work with GeoDjango	scibi	Claude Paroz	"Hi,

I had a model:
{{{#!python
from django.contrib.gis.db import models
from django.utils.translation import ugettext_lazy as _

class RoadFragment(models.Model):
    road = models.ForeignKey(Road, verbose_name=_(""Road""),
            on_delete=models.PROTECT)
    name = models.CharField(_(""Name""), max_length=255)
    description = models.TextField(_(""Description""), blank=True)
    beginning_location = models.PointField(verbose_name=_(""Beginning location""),
            blank=True, null=True)
    beginning_node = models.IntegerField(_(""Beginning node""), blank=True, null=True)
    end_node = models.IntegerField(_(""End node""), blank=True, null=True)
    end_location = models.PointField(verbose_name=_(""Beginning location""),
            blank=True, null=True)

    objects = models.GeoManager()

}}}

I removed `end_location` field and added 3 other fields:

{{{#!python
from django.contrib.gis.db import models
from django.utils.translation import ugettext_lazy as _

class RoadFragment(models.Model):
    road = models.ForeignKey(Road, verbose_name=_(""Road""),
            on_delete=models.PROTECT)
    name = models.CharField(_(""Name""), max_length=255)
    description = models.TextField(_(""Description""), blank=True)
    beginning_location = models.PointField(verbose_name=_(""Beginning location""),
            blank=True, null=True)
    beginning_node = models.IntegerField(_(""Beginning node""), blank=True, null=True)
    end_node = models.IntegerField(_(""End node""), blank=True, null=True)
    check_path = models.LineStringField(_(""Check path""), blank=True, null=True)
    check_result = models.BooleanField(_(""Check result""), default=False)
    check_time = models.DateTimeField(_(""Check time""), blank=True, null=True)


    objects = models.GeoManager()

}}}

I've run `makemigrations` command which generated attached migration file.

{{{#!sh
$ ./manage.py makemigrations
Migrations for 'roads':
  0003_auto_20140416_0000.py:
    - Add field check_time to roadfragment
    - Add field check_path to roadfragment
    - Add field check_result to roadfragment
    - Remove field end_location from roadfragment
}}}

Unfortunately `migrate` command doesn't create check_path column. There is no error nor warning:

{{{#!sh
$ ./manage.py migrate roads
Operations to perform:
  Apply all migrations: roads
Running migrations:
  Applying roads.0003_auto_20140416_0000... OK
}}}

Before migration table looks like this (PostgreSQL 9.1, sorry for Polish headers):
{{{
# \d roads_roadfragment
                                       Tabela ""public.roads_roadfragment""
      Kolumna       |          Typ           |                           Modyfikatory                            
--------------------+------------------------+-------------------------------------------------------------------
 id                 | integer                | niepusty domyślnie nextval('roads_roadfragment_id_seq'::regclass)
 road_id            | integer                | niepusty
 name               | character varying(255) | niepusty
 description        | text                   | niepusty
 beginning_node     | integer                | 
 end_node           | integer                | 
 beginning_location | geometry               | 
 end_location       | geometry               | 
}}}

After migration it looks like this:

{{{
# \d roads_roadfragment
                                        Tabela ""public.roads_roadfragment""
      Kolumna       |           Typ            |                           Modyfikatory                            
--------------------+--------------------------+-------------------------------------------------------------------
 id                 | integer                  | niepusty domyślnie nextval('roads_roadfragment_id_seq'::regclass)
 road_id            | integer                  | niepusty
 name               | character varying(255)   | niepusty
 description        | text                     | niepusty
 beginning_node     | integer                  | 
 end_node           | integer                  | 
 beginning_location | geometry                 | 
 end_location       | geometry                 | 
 check_time         | timestamp with time zone | 
 check_result       | boolean                  | niepusty
}}}

As you can see `end_location` was not removed and `check_path` was not added...
Splitting operation into multiple migrations doesn't work too (I've tried just removing `end_location` - it wasn't removed)."	Bug	closed	Migrations	1.7-beta-1	Release blocker	fixed		scibi	Accepted	0	0	0	0	0	0
