Upgrade script for 3.5.3 fails with could not create unique index #12890
Unanswered
stevenwinfough
asked this question in
Q&A
Replies: 1 comment 1 reply
-
This is the same as #12793 and #12332 - for more details see those discussions. In short, you have two devices with similar names, maybe "cisco 3925" and "Cisco 3925", in the same site (id=1). If you check the release notes for v3.4.0 under "Breaking Changes":
You need to rename one of those devices. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all,
I was updating my 3.3.8 working installation to 3.5.3 and now I'm getting the following error:
Running migrations:
Applying dcim.0162_unique_constraints...Traceback (most recent call last):
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 87, in _execute
return self.cursor.execute(sql)
psycopg2.errors.UniqueViolation: could not create unique index "dcim_device_unique_name_site"
DETAIL: Key (lower(name::text), site_id)=(cisco 3925, 1) is duplicated.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/netbox-3.5.3/netbox/manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/core/management/init.py", line 446, in execute_from_command_line
utility.execute()
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/core/management/init.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/core/management/base.py", line 96, in wrapped
res = handle_func(*args, **kwargs)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 349, in handle
post_migrate_state = executor.migrate(
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 130, in apply
operation.database_forwards(
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/migrations/operations/models.py", line 1040, in database_forwards
schema_editor.add_constraint(model, self.constraint)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 515, in add_constraint
self.execute(sql, params=None)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 199, in execute
cursor.execute(sql, params)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/opt/netbox-3.5.3/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 87, in _execute
return self.cursor.execute(sql)
django.db.utils.IntegrityError: could not create unique index "dcim_device_unique_name_site"
DETAIL: Key (lower(name::text), site_id)=(cisco 3925, 1) is duplicated.
Please help! I do not know how to fix this issue.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions