netbox v3.2-beta1 - dcim.0146_modules migration crashes #6094

Closed
opened 2025-12-29 19:36:44 +01:00 by adam · 10 comments
Owner

Originally created by @ThomasADavis on GitHub (Feb 16, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.2-beta1

Python version

3.9

Steps to Reproduce

Run migrate.sh on a db snapshot from a v2.11.12 instance.

Expected Behavior

Completion of the migration.

Observed Behavior

  Apply all migrations: admin, auth, circuits, contenttypes, dcim, django_rq, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization, wireless
Running migrations:
  Applying dcim.0146_modules...Traceback (most recent call last):
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django_prometheus/db/common.py", line 71, in execute
    return super().execute(*args, **kwargs)
psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/netbox-3.2-beta1/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 417, in execute
    output = self.handle(*args, **options)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 90, in wrapped
    res = handle_func(*args, **kwargs)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/commands/migrate.py", line 253, in handle
    post_migrate_state = executor.migrate(
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 126, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 156, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 235, in apply_migration
    with self.connection.schema_editor(atomic=migration.atomic) as schema_editor:
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/base/schema.py", line 126, in __exit__
    self.execute(sql)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/base/schema.py", line 153, in execute
    cursor.execute(sql, params)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute
    with self.db.wrap_database_errors:
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django_prometheus/db/common.py", line 71, in execute
    return super().execute(*args, **kwargs)
django.db.utils.ProgrammingError: relation "dcim_module_device_id_53cfd5be" already exists

Originally created by @ThomasADavis on GitHub (Feb 16, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.2-beta1 ### Python version 3.9 ### Steps to Reproduce Run migrate.sh on a db snapshot from a v2.11.12 instance. ### Expected Behavior Completion of the migration. ### Observed Behavior ``` Apply all migrations: admin, auth, circuits, contenttypes, dcim, django_rq, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization, wireless Running migrations: Applying dcim.0146_modules...Traceback (most recent call last): File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django_prometheus/db/common.py", line 71, in execute return super().execute(*args, **kwargs) psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/opt/netbox-3.2-beta1/netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line utility.execute() File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 373, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 417, in execute output = self.handle(*args, **options) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 90, in wrapped res = handle_func(*args, **kwargs) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/commands/migrate.py", line 253, in handle post_migrate_state = executor.migrate( File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 126, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 156, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 235, in apply_migration with self.connection.schema_editor(atomic=migration.atomic) as schema_editor: File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/base/schema.py", line 126, in __exit__ self.execute(sql) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/base/schema.py", line 153, in execute cursor.execute(sql, params) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers return executor(sql, params, many, context) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute with self.db.wrap_database_errors: File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django_prometheus/db/common.py", line 71, in execute return super().execute(*args, **kwargs) django.db.utils.ProgrammingError: relation "dcim_module_device_id_53cfd5be" already exists ```
adam added the type: bugstatus: acceptedbeta labels 2025-12-29 19:36:44 +01:00
adam closed this issue 2025-12-29 19:36:44 +01:00
Author
Owner

@ThomasADavis commented on GitHub (Feb 16, 2022):

The only plugins in the netbox-2.11.12 instance was netbox-topology-views and netbox-qrcode.

Taking this 2.11.12 db, I've successfully used it with v3.1.8.

I disabled all plugins in the v3.2-beta1 instance and commented them out of the configuration.py.

A fresh sync of the db from the v2.11.12 instance to v3.2-beta1 fails. The same db converts to v3.1.8 and succeeds.

This db has been upgraded from multiple 2.x versions; at least 2.8.x -> 2.9.x ->2.10.x -> 2.10.x

@ThomasADavis commented on GitHub (Feb 16, 2022): The only plugins in the netbox-2.11.12 instance was netbox-topology-views and netbox-qrcode. Taking this 2.11.12 db, I've successfully used it with v3.1.8. I disabled all plugins in the v3.2-beta1 instance and commented them out of the configuration.py. A fresh sync of the db from the v2.11.12 instance to v3.2-beta1 fails. The same db converts to v3.1.8 and succeeds. This db has been upgraded from multiple 2.x versions; at least 2.8.x -> 2.9.x ->2.10.x -> 2.10.x
Author
Owner

@ThomasADavis commented on GitHub (Feb 16, 2022):

Interesting. Changing the METRICS_ENABLED value to False in configuration.py gives:

Running migrations:
  Applying dcim.0146_modules...Traceback (most recent call last):
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/netbox-3.2-beta1/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 417, in execute
    output = self.handle(*args, **options)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 90, in wrapped
    res = handle_func(*args, **kwargs)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/commands/migrate.py", line 253, in handle
    post_migrate_state = executor.migrate(
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 126, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 156, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 235, in apply_migration
    with self.connection.schema_editor(atomic=migration.atomic) as schema_editor:
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/base/schema.py", line 126, in __exit__
    self.execute(sql)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/base/schema.py", line 153, in execute
    cursor.execute(sql, params)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute
    with self.db.wrap_database_errors:
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "dcim_module_device_id_53cfd5be" already exists
@ThomasADavis commented on GitHub (Feb 16, 2022): Interesting. Changing the METRICS_ENABLED value to False in configuration.py gives: ``` Running migrations: Applying dcim.0146_modules...Traceback (most recent call last): File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/opt/netbox-3.2-beta1/netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line utility.execute() File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 373, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 417, in execute output = self.handle(*args, **options) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/base.py", line 90, in wrapped res = handle_func(*args, **kwargs) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/core/management/commands/migrate.py", line 253, in handle post_migrate_state = executor.migrate( File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 126, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 156, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/migrations/executor.py", line 235, in apply_migration with self.connection.schema_editor(atomic=migration.atomic) as schema_editor: File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/base/schema.py", line 126, in __exit__ self.execute(sql) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/base/schema.py", line 153, in execute cursor.execute(sql, params) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers return executor(sql, params, many, context) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute with self.db.wrap_database_errors: File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: relation "dcim_module_device_id_53cfd5be" already exists ```
Author
Owner

@basti1508 commented on GitHub (Feb 16, 2022):

I'm running in the exact same issue tyring to upgrade from 3.1.0 to 3.1.8 to 3.2-beta1.
No Plugins enabled at the moment.

@basti1508 commented on GitHub (Feb 16, 2022): I'm running in the exact same issue tyring to upgrade from 3.1.0 to 3.1.8 to 3.2-beta1. No Plugins enabled at the moment.
Author
Owner

@jeremystretch commented on GitHub (Feb 16, 2022):

Interesting. Changing the METRICS_ENABLED value to False in configuration.py gives:

@ThomasADavis that appears to be the same traceback as your initial post. Is it supposed to be different?

@jeremystretch commented on GitHub (Feb 16, 2022): > Interesting. Changing the METRICS_ENABLED value to False in configuration.py gives: @ThomasADavis that appears to be the same traceback as your initial post. Is it supposed to be different?
Author
Owner

@jeremystretch commented on GitHub (Feb 16, 2022):

Ok, I was able to reproduce this with the following steps:

  1. Drop and recreate the PostgreSQL database
  2. Check out v2.11.12
  3. Run upgrade.sh
  4. Verify that NetBox runs
  5. Check out v3.2-beta1
  6. Run upgrade.sh again

The migration fails with the same exception reported above (psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists).

I'll need to do some digging, but I suspect this might be related to inventory items: The InventoryItem class was originally named Module many years ago. It's likely the relation was never renamed to match.

@jeremystretch commented on GitHub (Feb 16, 2022): Ok, I was able to reproduce this with the following steps: 1. Drop and recreate the PostgreSQL database 2. Check out v2.11.12 3. Run `upgrade.sh` 4. Verify that NetBox runs 5. Check out v3.2-beta1 6. Run `upgrade.sh` again The migration fails with the same exception reported above (`psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists`). I'll need to do some digging, but I suspect this might be related to inventory items: The InventoryItem class was [originally named Module](https://github.com/netbox-community/netbox/commit/22768ff6c6c64fe22972bffbeb44d0c64bf49a16) many years ago. It's likely the relation was never renamed to match.
Author
Owner

@jeremystretch commented on GitHub (Feb 16, 2022):

Yep, that's what it is:

netbox=> \d dcim_inventoryitem
...
Indexes:
    "dcim_module_pkey" PRIMARY KEY, btree (id)
    "dcim_inventoryitem_asset_tag_key" UNIQUE CONSTRAINT, btree (asset_tag)
    "dcim_module_device_id_parent_id_name_4d8292af_uniq" UNIQUE CONSTRAINT, btree (device_id, parent_id, name)
    "dcim_inventoryitem_asset_tag_d3289273_like" btree (asset_tag varchar_pattern_ops)
    "dcim_inventoryitem_tree_id_4676ade2" btree (tree_id)
    "dcim_module_device_id_53cfd5be" btree (device_id)
    "dcim_module_manufacturer_id_95322cbb" btree (manufacturer_id)
    "dcim_module_parent_id_bb5d0341" btree (parent_id)

It should just be a matter of dropping and recreating the affected indexes.

Relevant Django bug

@jeremystretch commented on GitHub (Feb 16, 2022): Yep, that's what it is: ``` netbox=> \d dcim_inventoryitem ... Indexes: "dcim_module_pkey" PRIMARY KEY, btree (id) "dcim_inventoryitem_asset_tag_key" UNIQUE CONSTRAINT, btree (asset_tag) "dcim_module_device_id_parent_id_name_4d8292af_uniq" UNIQUE CONSTRAINT, btree (device_id, parent_id, name) "dcim_inventoryitem_asset_tag_d3289273_like" btree (asset_tag varchar_pattern_ops) "dcim_inventoryitem_tree_id_4676ade2" btree (tree_id) "dcim_module_device_id_53cfd5be" btree (device_id) "dcim_module_manufacturer_id_95322cbb" btree (manufacturer_id) "dcim_module_parent_id_bb5d0341" btree (parent_id) ``` It should just be a matter of dropping and recreating the affected indexes. [Relevant Django bug](https://code.djangoproject.com/ticket/23577)
Author
Owner

@jeremystretch commented on GitHub (Feb 16, 2022):

For an immediate fix if you don't want to wait for the patch, you can manually rename the affected indexes. For the example above the solution would be:

$ ./manage.py dbshell
psql (10.19 (Ubuntu 10.19-0ubuntu0.18.04.1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

netbox=> ALTER INDEX dcim_module_pkey RENAME TO dcim_inventoryitem_pkey;
ALTER INDEX
netbox=> ALTER INDEX dcim_module_device_id_parent_id_name_4d8292af_uniq RENAME TO dcim_inventoryitem_device_id_parent_id_name_4d8292af_uniq; 
ALTER INDEX
netbox=> ALTER INDEX dcim_module_device_id_53cfd5be RENAME TO dcim_inventoryitem_device_id_53cfd5be;
ALTER INDEX
netbox=> ALTER INDEX dcim_module_manufacturer_id_95322cbb RENAME TO dcim_inventoryitem_manufacturer_id_95322cbb;
ALTER INDEX
netbox=> ALTER INDEX dcim_module_parent_id_bb5d0341 RENAME TO dcim_inventoryitem_parent_id_bb5d0341;
ALTER INDEX

However, take care to specify your index names, as most of them have been appended with a random ID to ensure uniqueness.

@jeremystretch commented on GitHub (Feb 16, 2022): For an immediate fix if you don't want to wait for the patch, you can manually rename the affected indexes. For the example above the solution would be: ``` $ ./manage.py dbshell psql (10.19 (Ubuntu 10.19-0ubuntu0.18.04.1)) SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off) Type "help" for help. netbox=> ALTER INDEX dcim_module_pkey RENAME TO dcim_inventoryitem_pkey; ALTER INDEX netbox=> ALTER INDEX dcim_module_device_id_parent_id_name_4d8292af_uniq RENAME TO dcim_inventoryitem_device_id_parent_id_name_4d8292af_uniq; ALTER INDEX netbox=> ALTER INDEX dcim_module_device_id_53cfd5be RENAME TO dcim_inventoryitem_device_id_53cfd5be; ALTER INDEX netbox=> ALTER INDEX dcim_module_manufacturer_id_95322cbb RENAME TO dcim_inventoryitem_manufacturer_id_95322cbb; ALTER INDEX netbox=> ALTER INDEX dcim_module_parent_id_bb5d0341 RENAME TO dcim_inventoryitem_parent_id_bb5d0341; ALTER INDEX ``` However, take care to specify _your_ index names, as most of them have been appended with a random ID to ensure uniqueness.
Author
Owner

@ThomasADavis commented on GitHub (Feb 16, 2022):

Interesting. Changing the METRICS_ENABLED value to False in configuration.py gives:

@ThomasADavis that appears to be the same traceback as your initial post. Is it supposed to be different?

One line change in the top of the trace..

With metrics enabled:

Running migrations:
  Applying dcim.0146_modules...Traceback (most recent call last):
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django_prometheus/db/common.py", line 71, in execute
    return super().execute(*args, **kwargs)
psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists

With metrics disabled:

Running migrations:
  Applying dcim.0146_modules...Traceback (most recent call last):
  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists

The difference is the line

  File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django_prometheus/db/common.py", line 71, in execute
    return super().execute(*args, **kwargs)

I'll try to rename and see what happens.

@ThomasADavis commented on GitHub (Feb 16, 2022): > > Interesting. Changing the METRICS_ENABLED value to False in configuration.py gives: > > @ThomasADavis that appears to be the same traceback as your initial post. Is it supposed to be different? One line change in the top of the trace.. With metrics enabled: ``` Running migrations: Applying dcim.0146_modules...Traceback (most recent call last): File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django_prometheus/db/common.py", line 71, in execute return super().execute(*args, **kwargs) psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists ``` With metrics disabled: ``` Running migrations: Applying dcim.0146_modules...Traceback (most recent call last): File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) psycopg2.errors.DuplicateTable: relation "dcim_module_device_id_53cfd5be" already exists ``` The difference is the line ``` File "/opt/netbox-3.2-beta1/venv/lib64/python3.10/site-packages/django_prometheus/db/common.py", line 71, in execute return super().execute(*args, **kwargs) ``` I'll try to rename and see what happens.
Author
Owner

@jeremystretch commented on GitHub (Feb 16, 2022):

One line change in the top of the trace..

You can ignore that, it's just the metrics middleware.

@jeremystretch commented on GitHub (Feb 16, 2022): > One line change in the top of the trace.. You can ignore that, it's just the metrics middleware.
Author
Owner

@ThomasADavis commented on GitHub (Feb 16, 2022):

The existing indexs match perfectly, and renaming them and then re-running upgrade.sh completes successfully.

@ThomasADavis commented on GitHub (Feb 16, 2022): The existing indexs match perfectly, and renaming them and then re-running upgrade.sh completes successfully.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6094