Errors when upgrading from 3.4.3 to 3.7.1 ( Migration account.0001_initial is applied before its dependency users.0004_netboxgroup_netboxuser) #9149

Closed
opened 2025-12-29 20:46:17 +01:00 by adam · 0 comments
Owner

Originally created by @etigui on GitHub (Jan 24, 2024).

Deployment Type

Self-hosted

NetBox Version

v3.7.1

Python Version

3.9

Steps to Reproduce

We have 2 instances, one prod with Netbox 3.4.3 and postgesql 13 and one test with Netbox 3.7.1 and postgesql 15. We are trying to upgrade from the prod to the test instance:

Prod instance (Netbox 3.4.3 with postgesql v13):

  1. Dump production database

Test instance (Netbox 3.7.1 with postgesql v15):

  1. Create database from dump
  2. Run upgrade.sh
  3. Upgrade get stuck on DB migration

Expected Behavior

Migrate Netbox from 3.4.3 (postgesql v13) to 3.7.1 (postgesql v15)

Observed Behavior

$ PYTHON=/usr/bin/python3.9 ./upgrade.sh
.
.
.
Applying database migrations (python3 netbox/manage.py migrate)...
Traceback (most recent call last):
  File "/opt/netbox/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/commands/migrate.py", line 120, in handle
    executor.loader.check_consistent_history(connection)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/migrations/loader.py", line 327, in check_consistent_history
    raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration account.0001_initial is applied before its dependency users.0004_netboxgroup_netboxuser on database 'default'.
Originally created by @etigui on GitHub (Jan 24, 2024). ### Deployment Type Self-hosted ### NetBox Version v3.7.1 ### Python Version 3.9 ### Steps to Reproduce We have 2 instances, one prod with Netbox 3.4.3 and postgesql 13 and one test with Netbox 3.7.1 and postgesql 15. We are trying to upgrade from the prod to the test instance: Prod instance (Netbox 3.4.3 with postgesql v13): 1. Dump production database Test instance (Netbox 3.7.1 with postgesql v15): 1. Create database from dump 2. Run upgrade.sh 3. Upgrade get stuck on DB migration ### Expected Behavior Migrate Netbox from 3.4.3 (postgesql v13) to 3.7.1 (postgesql v15) ### Observed Behavior ``` $ PYTHON=/usr/bin/python3.9 ./upgrade.sh . . . Applying database migrations (python3 netbox/manage.py migrate)... Traceback (most recent call last): File "/opt/netbox/netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 458, in execute output = self.handle(*args, **options) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 106, in wrapper res = handle_func(*args, **kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/management/commands/migrate.py", line 120, in handle executor.loader.check_consistent_history(connection) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/db/migrations/loader.py", line 327, in check_consistent_history raise InconsistentMigrationHistory( django.db.migrations.exceptions.InconsistentMigrationHistory: Migration account.0001_initial is applied before its dependency users.0004_netboxgroup_netboxuser on database 'default'. ```
adam closed this issue 2025-12-29 20:46:17 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9149