#23861: IPAddressField removal will break migrations and test suites
-----------------------------+--------------------------------------
     Reporter:  spookylukey  |                    Owner:  nobody
         Type:  Bug          |                   Status:  new
    Component:  Migrations   |                  Version:  master
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Unreviewed
    Has patch:  0            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+--------------------------------------
Changes (by MarkusH):

 * cc: info+coding@… (added)


Comment:

 A few thoughts I collected over the last days while silently following the
 discussion here:

 - We should extend the lifetime of removed fields by a single version as
 stub fields. Shouldn't be too hard to get something "working" in
 migrations (aka not failing) but throwing warnings or blowing up during
 normal use.
 - Magic that happens during migrations and adds some legacy fields back,
 but not during "normal" runtime, makes migrations even worse to debug.
 It's hard enough to figure out where and when (in which migration) a model
 was defined.
 - The problem Django has with the `IPAddressField` is kind of a luxury. We
 could add some magic that will make migrations work even after the field
 was removed. This won't work for 3rd party apps though (as already said).
 Thus magic import features, as stated above, shouldn't be a solution.
 - Carl's idea to make `operations` a property that internally imports all
 used code, could work. I'm not sure what we are missing though.
 - Going with some `@lazy` decorator or implementation won't help in any
 way. The classes still need to be imported.
 - Referencing imports by strings would be possible, but it's quite
 invasive:

 {{{#!python
 from django.db import migrations, get_migration_operation,
 get_migration_thing


 def get_migration_operation(to_import, *args, **kwargs):
     try:
         klass = import_string(to_import)
         return klass(*args, **kwargs)
     except ImportError:
         return NoOp()


 def get_migration_thing(to_import, *args, **kwargs):
     try:
         klass = import_string(to_import)
         return klass(*args, **kwargs)
     except ImportError:
         # raise warning / error


 class Migration(migrations.Migration):

     dependencies = []

     operations = [
 
migrations.get_migration_operation('django.db.migrations.operations.CreateModel',
 fields=[
             migrations.get_migration_thing('myapp.fields.MyField', 'x',
 'y'),
         ]),
 
migrations.get_migration_operation('django.db.migrations.operations.ANewOperationIn18',
 'arg1', kwarg1='kwarg1'),
     ]
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23861#comment:10>
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/069.6450c815078c68d253cc180b9bdb9933%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to