0182_zero_length_cable_fix.py 524 B

12345678910111213141516171819202122
  1. from django.db import migrations
  2. def update_cable_lengths(apps, schema_editor):
  3. Cable = apps.get_model('dcim', 'Cable')
  4. # Set the absolute length for any zero-length Cables
  5. Cable.objects.filter(length=0).update(_abs_length=0)
  6. class Migration(migrations.Migration):
  7. dependencies = [
  8. ('dcim', '0181_rename_device_role_device_role'),
  9. ]
  10. operations = [
  11. migrations.RunPython(
  12. code=update_cable_lengths,
  13. reverse_code=migrations.RunPython.noop
  14. ),
  15. ]