'Creating and then altering an FK works correctly
and deals with the pending SQL (#23091)'

def test_alter_fk(self):

    project_state = self.set_up_test_model('test_alfk')
    create_operation = migrations.CreateModel(name='Rider', fields=[('id', models.AutoField(primary_key=True)), ('pony', models.ForeignKey('Pony', models.CASCADE))])
    create_state = project_state.clone()
    create_operation.state_forwards('test_alfk', create_state)
    alter_operation = migrations.AlterField(model_name='Rider', name='pony', field=models.ForeignKey('Pony', models.CASCADE, editable=False))
    alter_state = create_state.clone()
    alter_operation.state_forwards('test_alfk', alter_state)
    with connection.schema_editor() as editor:
        create_operation.database_forwards('test_alfk', editor, project_state, create_state)
        alter_operation.database_forwards('test_alfk', editor, create_state, alter_state)
