0142_rename_128gfc_qsfp28.py 685 B

1234567891011121314151617181920212223242526272829
  1. from django.db import migrations
  2. OLD_VALUE = '128gfc-sfp28'
  3. NEW_VALUE = '128gfc-qsfp28'
  4. def correct_type(apps, schema_editor):
  5. """
  6. Correct TYPE_128GFC_QSFP28 interface type.
  7. """
  8. Interface = apps.get_model('dcim', 'Interface')
  9. InterfaceTemplate = apps.get_model('dcim', 'InterfaceTemplate')
  10. for model in (Interface, InterfaceTemplate):
  11. model.objects.filter(type=OLD_VALUE).update(type=NEW_VALUE)
  12. class Migration(migrations.Migration):
  13. dependencies = [
  14. ('dcim', '0141_asn_model'),
  15. ]
  16. operations = [
  17. migrations.RunPython(
  18. code=correct_type,
  19. reverse_code=migrations.RunPython.noop
  20. ),
  21. ]