'Tests the AlterField operation on primary keys (for things like PostgreSQL\'s SERIAL weirdness)'

def test_alter_field_pk(self):

    project_state = self.set_up_test_model('test_alflpk')
    operation = migrations.AlterField('Pony', 'id', models.IntegerField(primary_key=True))
    new_state = project_state.clone()
    operation.state_forwards('test_alflpk', new_state)
    self.assertIsInstance(project_state.models[('test_alflpk', 'pony')].get_field_by_name('id'), models.AutoField)
    self.assertIsInstance(new_state.models[('test_alflpk', 'pony')].get_field_by_name('id'), models.IntegerField)
    with connection.schema_editor() as editor:
        operation.database_forwards('test_alflpk', editor, project_state, new_state)
    with connection.schema_editor() as editor:
        operation.database_backwards('test_alflpk', editor, new_state, project_state)
