﻿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
22997	Migration fails when removing explicit primary key	a.lloyd.flanagan@…	bcail	"The automatic migration created by migrate fails when

* 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."	Bug	assigned	Migrations	1.7	Normal		migrate primary_key	bcail	Accepted	1	0	0	1	0	0
