﻿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
28523	Improve the error message when squashing migration with RunPython that require manual changes	Václav Řehák	nobody	"#22983 fixed the need to manually modify squashed migration with RunPython by providing explanation in the squasmigrations output and as a comment on the top of the migration file. While this should be enough for careful reader I missed it and spent some time investigating why migrations are giving me a syntax error:


{{{
  File ""/home/vaclav/project/src/core/migrations/0002_user_authentication_squashed_0056_my_migration.py"", line 84
    code=core.migrations.0005_add_social_providers.create_providers,
                            ^
SyntaxError: invalid syntax

}}}

The problem is that if you open the squashed migration file on the line with error, you start thinking why Django is creating file with invalid Python syntax and miss the comment on the top of the file.

I'm proposing a simple change to migration which require manual change to make it more obvious. I'm not sure what the right form would be but e.g. placing this right after the comment makes the developers experience much better:


{{{
from django.core.exceptions import ImproperlyConfigured                                                                 
raise ImproperlyConfigured(""Manual change to migration required"")
}}}
 
Now if I run ""manage.py migrate"" I get a clear error message what is wrong:


{{{
  File ""/home/vaclav/project/src/core/migrations/0002_user_authentication_squashed_0056_my_migration.py"", line 33, in <module>
    raise ImproperlyConfigured(""Manual change to migration required"")
django.core.exceptions.ImproperlyConfigured: Manual change to migration required
}}}
"	Cleanup/optimization	closed	Migrations	1.11	Normal	wontfix			Unreviewed	0	0	0	0	0	1
