﻿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
32634	AlterField drops contraints in the wrong order when performed as reverse migration	Matthias Dellweg	nobody	"The following migration step

{{{
migrations.AlterField(
            model_name='filedistribution',
            name='distribution_ptr',
            field=models.OneToOneField(auto_created=True,
                                       on_delete=django.db.models.deletion.CASCADE,
                                       parent_link=True, primary_key=True,
                                       related_name='file_filedistribution', serialize=False,
                                       to='core.Distribution'),
            preserve_default=False,
        ),
}}}

in reverse mode produces

{{{
ALTER TABLE ""file_filedistribution"" ALTER COLUMN ""distribution_ptr_id"" DROP NOT NULL;
ALTER TABLE ""file_filedistribution"" DROP CONSTRAINT ""file_filedistribution_distribution_ptr_id_5ce5564b_pk"";
}}}

leading to an error

{{{
django.db.utils.ProgrammingError: column ""distribution_ptr_id"" is in a primary key
}}}

Switching the order of the statements enabled me execute the SQL just fine."	Bug	closed	Migrations	3.2	Normal	invalid			Unreviewed	0	0	0	0	0	0
