Ticket #337 (closed defect: worksforme)
Fails to Alter Table when also adding a geometry
| Reported by: | barnaby@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.7 |
| Component: | migrations | Version: | 0.6.2 |
| Keywords: | geoDjango, | Cc: |
Description
Migration cannot alter table in regular way while adding geography field. It falsely claims that it ran the ALTER TABLE command for the non-geographic field, but the table is not altered to include it, only the geographic field.
How to duplicate this bug:
1) add 3 fields:
state = models.CharField?(_('State'), max_length=11)
point = models.PointField?(null=True)
objects = models.GeoManager?()
(P.S. don't forget to change import statement to "from django.contrib.gis.db import models")
3) run ./manage.py startmigration and observe which commands it claims to have ran, it includes an ALTER TABLE command for the "state" column
4) go into database and inspect which columns were added, and notice that only the geography was added, the state column was not actually added
psql myDB
\d myModelsTable
5) just to be sure, roll back the migration (may involve manually altering the table so that backwards() works) and in its place create 2 separate migrations, one for the geographic field, and one for the CharField? (e.g. the "state" column). They work individually, but not together.
Attachments
Change History
Changed 3 years ago by barnaby@…
- Attachment commandline_history.txt added
comment:1 Changed 3 years ago by andrew
- Status changed from new to assigned
- Milestone set to 0.7
Alright, I'll try and replicate and fix this locally.

Commandline History of how I discovered bug #337