* a table was created with a field where "primary_key=True" is specified.
* data is added to the table
* The model is modified so that no field is primary key, and Django auto-
creates "id" field.
To reproduce the problem:
1. create new model, set some field as primary key
2. set up migrations with initial migration
3. modify model so field is not primary key
4. generate migration
Problems:
* will ask for default value for auto-generated ID field
* will try to create id field as primary key, before modifying existing
key
Manual Fix:
* remove default from models.AutoField() call
* reverse order of operations so AlterField() comes before AddField()
I'm attaching a session log with a complete transcript.
--
Ticket URL: <https://code.djangoproject.com/ticket/22997>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Database layer (models, ORM) => Migrations
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
I guess it's probably too much of an edge case to be a blocker for 1.7,
but would be nice if it "just worked".
--
Ticket URL: <https://code.djangoproject.com/ticket/22997#comment:1>
* version: 1.7-rc-1 => 1.7
--
Ticket URL: <https://code.djangoproject.com/ticket/22997#comment:2>
Comment (by timgraham):
#24030 seems related.
--
Ticket URL: <https://code.djangoproject.com/ticket/22997#comment:3>