﻿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
25105	Migrating multiple CharFields to null=False breaks on PostgreSQL	Daniel Roseman	David Wobrock	"Given a model containing multiple CharFields defined as {{{null=True}}}, and at least one row with null data in two or more of those fields, then change the CharFields to null=False and create a migration with a temporary default of the empty string.

Running this migration will attempt, for each field, to set the null values to the empty string, then migrate the field to NOT NULL. However, the second field will fail with the error {{{psycopg2.OperationalError: cannot ALTER TABLE ""fundraising_donation"" because it has pending trigger events}}}.

Clearly this is the same issue warned against in the [https://docs.djangoproject.com/en/1.8/ref/migration-operations/#runpython migration documentation] as caused by mixing RunPython  and schema changes in the same migration; however, here it is a fully automatically-generated migration which causes the error.

Some possible solutions:

* Do nothing but mention this edge case in the documentation;
* Detect and warn against converting multiple null=False fields in one migration;
* Detect and deal with the problem in some way, perhaps by committing the transaction after each field."	Bug	closed	Migrations	3.2	Normal	fixed		Michał Łazowik Florian Demmer David Wobrock	Ready for checkin	1	0	0	0	0	0
