diff --git a/python/nav/models/oui.py b/python/nav/models/oui.py index 88846ebff9..e2911f1892 100644 --- a/python/nav/models/oui.py +++ b/python/nav/models/oui.py @@ -6,8 +6,8 @@ class OUI(models.Model): """Defines an OUI and the name of the vendor the OUI belongs to""" + oui = models.CharField(max_length=17, primary_key=True) vendor = VarcharField() - oui = models.CharField(max_length=17, unique=True) def __str__(self): return self.oui diff --git a/python/nav/models/sql/changes/sc.05.10.0002.sql b/python/nav/models/sql/changes/sc.05.10.0002.sql index e59e8ed263..514768bccf 100644 --- a/python/nav/models/sql/changes/sc.05.10.0002.sql +++ b/python/nav/models/sql/changes/sc.05.10.0002.sql @@ -1,6 +1,5 @@ CREATE TABLE manage.oui ( - id SERIAL PRIMARY KEY, + oui MACADDR PRIMARY KEY, vendor VARCHAR NOT NULL, - oui MACADDR NOT NULL UNIQUE, CHECK (oui=trunc(oui)) ); diff --git a/tests/integration/models/oui_test.py b/tests/integration/models/oui_test.py index 6efe189563..ce1323fe13 100644 --- a/tests/integration/models/oui_test.py +++ b/tests/integration/models/oui_test.py @@ -22,8 +22,7 @@ def valid_oui(): oui = "aa:bb:cc:00:00:00" instance = OUI(oui=oui, vendor="myvendor") yield instance - if instance.id: - instance.delete() + instance.delete() @pytest.fixture() @@ -31,5 +30,4 @@ def invalid_oui(): oui = "aa:bb:cc:dd:ee:ff" instance = OUI(oui=oui, vendor="myvendor") yield instance - if instance.id: - instance.delete() + instance.delete()