#28523: Better error message for #22983 (squashed migration with RunPython)
https://code.djangoproject.com/ticket/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 migration 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")
---------------------------------------+------------------------
               Reporter:  washeck      |          Owner:  nobody
                   Type:  New feature  |         Status:  new
              Component:  Migrations   |        Version:  1.11
               Severity:  Normal       |       Keywords:
           Triage Stage:  Unreviewed   |      Has patch:  0
    Needs documentation:  0            |    Needs tests:  0
Patch needs improvement:  0            |  Easy pickings:  1
                  UI/UX:  1            |
---------------------------------------+------------------------
 #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
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28523>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.c475e2ff0ca5f22fd727f3710c9af079%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to