virtualization.0016_replicate_interfaces migration fails with IntegrityError #5606

Closed
opened 2025-12-29 19:30:06 +01:00 by adam · 0 comments
Owner

Originally created by @sschols on GitHub (Nov 4, 2021).

NetBox version

2.11.12

Python version

3.8

Steps to Reproduce

I'm upgrading a docker-based netbox install from 2.5.13 to 2.11.12 (as a intermediary step to 3.0.x), and I get the following migration error:

Running migrations:
  Applying virtualization.0016_replicate_interfaces...
    Replicating 22 VM interfaces...
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "virtualization_vminterfa_virtual_machine_id_name_cfb9c423_uniq"
DETAIL:  Key (virtual_machine_id, name)=(5, Network adapter 1) already exists.

Expected Behavior

The migration to go through smoothly and have a running netbox instance again.

Observed Behavior

The error message above pops up, and netbox doesn't come up.

I found #5334 which seems to match the error, but wasn't followed up properly.

We used to have a sync script from VMware to NetBox, maybe this caused this issue? We don't use NetBox for VMs anymore, so if there would be a way to remove all that from the database, and that would solve the issue, we'd be happy to do that.

Originally created by @sschols on GitHub (Nov 4, 2021). ### NetBox version 2.11.12 ### Python version 3.8 ### Steps to Reproduce I'm upgrading a docker-based netbox install from 2.5.13 to 2.11.12 (as a intermediary step to 3.0.x), and I get the following migration error: ``` Running migrations: Applying virtualization.0016_replicate_interfaces... Replicating 22 VM interfaces... Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "virtualization_vminterfa_virtual_machine_id_name_cfb9c423_uniq" DETAIL: Key (virtual_machine_id, name)=(5, Network adapter 1) already exists. ``` ### Expected Behavior The migration to go through smoothly and have a running netbox instance again. ### Observed Behavior The error message above pops up, and netbox doesn't come up. I found #5334 which seems to match the error, but wasn't followed up properly. We used to have a sync script from VMware to NetBox, maybe this caused this issue? We don't use NetBox for VMs anymore, so if there would be a way to remove all that from the database, and that would solve the issue, we'd be happy to do that.
adam added the type: bug label 2025-12-29 19:30:06 +01:00
adam closed this issue 2025-12-29 19:30:06 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5606