#29515: put sample code in empty migrations
-----------------------------------------+------------------------
               Reporter:  Chris Curvey   |          Owner:  nobody
                   Type:  New feature    |         Status:  new
              Component:  Uncategorized  |        Version:  2.0
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 SHORT VERSION:  put sample code into the generated file when creating an
 "empty" migration, like this:

 #def combine_names(apps, schema_editor):
 #    # We can't import the Person model directly as it may be a newer
 #    # version than this migration expects. We use the historical version.
 #    Person = apps.get_model('yourappname', 'Person')
 #    for person in Person.objects.all():
 #        person.name = '%s %s' % (person.first_name, person.last_name)
 #        person.save()


 and then

     operations = [
         #migrations.RunPython(combine_names),
     ]

 LONG VERSION/JUSTIFICATION:

 Every time I create a data migration (python manage.py makemigrations foo
 --empty), I have to do a web search to remember what the parameters are to
 the function I want to call (apps, schema_editor), and how to use those
 parameters, and how to get the code to actually run
 (migrations.RunPython).

 It would be really nice to have that sample code just put into the empty
 migration so that it is there as an example.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29515>
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.19f4100334e85c8572a710014bc37641%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to