-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- IX media type field deprecated peeringdb/#1555 - Add location of Physical IX-Port & Router Port peeringdb/#607
- Loading branch information
Showing
9 changed files
with
849 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Generated by Django 4.2.7 on 2024-08-07 19:37 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def _from_db_value(value, expression, connection): | ||
# for bypass clean_choices validation | ||
if value is None: | ||
return None | ||
if not value or value == "[]": | ||
return [] | ||
return value.split(",") | ||
|
||
|
||
def forward(apps, schema_editor): | ||
Facility = apps.get_model("django_peeringdb", "Facility") | ||
updated_field = Facility._meta.get_field("updated") | ||
updated_field_auto_now = updated_field.auto_now | ||
from_db_value = Facility._meta.get_field("available_voltage_services").from_db_value | ||
invalid_voltage_values = ["120 VAC", "208 VAC", "240 VAC"] | ||
|
||
try: | ||
# overide from_db_value method | ||
# because this method calls "clean_choices" resulting in a validation error when retrieving all facilites. | ||
Facility._meta.get_field( | ||
"available_voltage_services" | ||
).from_db_value = _from_db_value | ||
facilities = Facility.handleref.all() | ||
for facility in facilities: | ||
voltage = facility.available_voltage_services | ||
removed = [] | ||
|
||
for invalid_voltage_value in invalid_voltage_values: | ||
try: | ||
voltage.remove(invalid_voltage_value) | ||
removed.append(invalid_voltage_value) | ||
except ValueError: | ||
pass | ||
|
||
if removed: | ||
facility.available_voltage_services = voltage | ||
print(f"Removed {removed} from {facility}") | ||
facility.save() | ||
finally: | ||
Facility._meta.get_field( | ||
"available_voltage_services" | ||
).from_db_value = from_db_value | ||
updated_field.auto_now = updated_field_auto_now | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
( | ||
"django_peeringdb", | ||
"0033_alter_facility_property_alter_ixlan_rs_asn_and_more", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forward, migrations.RunPython.noop), | ||
] |
26 changes: 26 additions & 0 deletions
26
src/django_peeringdb/migrations/0035_alter_ix_media_field_add_default_value.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 4.2.16 on 2024-09-29 14:10 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("django_peeringdb", "0034_fix_voltage"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="internetexchange", | ||
name="media", | ||
field=models.CharField( | ||
choices=[ | ||
("Ethernet", "Ethernet"), | ||
("ATM", "ATM"), | ||
("Multiple", "Multiple"), | ||
], | ||
default="Ethernet", | ||
max_length=128, | ||
verbose_name="Media Type", | ||
), | ||
), | ||
] |
35 changes: 35 additions & 0 deletions
35
src/django_peeringdb/migrations/0036_networkixlan_net_side_networkixlan_ix_side.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 4.2.16 on 2024-09-19 12:23 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("django_peeringdb", "0035_alter_ix_media_field_add_default_value"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="networkixlan", | ||
name="net_side", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="net_side_set", | ||
to="django_peeringdb.facility", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="networkixlan", | ||
name="ix_side", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="ix_side_set", | ||
to="django_peeringdb.facility", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters