Skip to content

Conversation

jeremystretch
Copy link
Member

Fixes: #20290

Reorders migrations to avoid an UndefinedTable exception when upgrading directly to NetBox v4.4 from v3.7.

Thanks to @pheus for identifying the fix!

@jeremystretch jeremystretch requested review from a team and bctiemann and removed request for a team September 10, 2025 16:35
@bctiemann bctiemann merged commit 01f1228 into main Sep 11, 2025
10 checks passed
@mindsolve
Copy link

Just a quick FYI: I was on v4.3.7, and updated to current main (after this PR), and got an exception during update.sh:
I don't know whether this is worthy of a issue, as I don't know if this affects other people as well.

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/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/management/base.py", line 416, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/management/base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 117, in handle
    executor.loader.check_consistent_history(connection)
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/migrations/loader.py", line 327, in check_consistent_history
    raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration users.0005_alter_user_table is applied before its dependency core.0018_concrete_objecttype on database 'default'.

@jeremystretch
Copy link
Member Author

Thanks for flagging this @mindsolve. I've captured it in bug #20329.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade from v3.7.8 to v4.4.0 fails on migration users.0005_alter_user_table (core_objecttype missing)

3 participants