Upgrade 2.6.9 -> 2.7.11: Database migration failing, netbox not working anymore #3522

Closed
opened 2025-12-29 18:29:38 +01:00 by adam · 2 comments
Owner

Originally created by @jacotec on GitHub (Mar 30, 2020).

Environment

  • Python version: 3.6.9
  • NetBox version: 2.7.11

Steps to Reproduce

  1. Upgraded Netbox from version 2.6.2 to 2.7.11
  2. Run ./upgrade.sh

Expected Behavior

It should migrate the database and start

Observed Behavior

The database migration fails with an error, netbox is not running. See log below:

Applying database migrations (python3 netbox/manage.py migrate)...
Traceback (most recent call last):
  File "netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 87, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
    self.build_graph()
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 206, in build_graph
    self.load_disk()
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 108, in load_disk
    migration_module = import_module(migration_path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/netbox/netbox/extras/migrations/0001_initial_squashed_0010_customfield_filter_logic.py", line 11, in <module>
    from extras.constants import CF_FILTER_DISABLED, CF_FILTER_EXACT, CF_FILTER_LOOSE, CF_TYPE_SELECT
ImportError: cannot import name 'CF_FILTER_DISABLED'
Originally created by @jacotec on GitHub (Mar 30, 2020). ### Environment * Python version: 3.6.9 * NetBox version: 2.7.11 ### Steps to Reproduce 1. Upgraded Netbox from version 2.6.2 to 2.7.11 2. Run ./upgrade.sh <!-- What did you expect to happen? --> ### Expected Behavior It should migrate the database and start <!-- What happened instead? --> ### Observed Behavior The database migration fails with an error, netbox is not running. See log below: ``` Applying database migrations (python3 netbox/manage.py migrate)... Traceback (most recent call last): File "netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 87, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__ self.build_graph() File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 206, in build_graph self.load_disk() File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 108, in load_disk migration_module = import_module(migration_path) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/opt/netbox/netbox/extras/migrations/0001_initial_squashed_0010_customfield_filter_logic.py", line 11, in <module> from extras.constants import CF_FILTER_DISABLED, CF_FILTER_EXACT, CF_FILTER_LOOSE, CF_TYPE_SELECT ImportError: cannot import name 'CF_FILTER_DISABLED' ```
adam closed this issue 2025-12-29 18:29:38 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 30, 2020):

File "/opt/netbox/netbox/extras/migrations/0001_initial_squashed_0010_customfield_filter_logic.py"

This file is from the v2.6.2 release, and does not exist in the v2.7.11 code base. (This migration was replaced with 0001_initial_squashed_0013_objectchange.py in more recent releases.) It appears something has gone wrong with your upgrade; likely the v2.7.11 code being installed on top of the existing code instead of in a new directory. I suggest installing v2.7.11 to a new path and trying again. Please post to the mailing list if you need any further assistance.

@jeremystretch commented on GitHub (Mar 30, 2020): > `File "/opt/netbox/netbox/extras/migrations/0001_initial_squashed_0010_customfield_filter_logic.py"` This file is from the v2.6.2 release, and does not exist in the v2.7.11 code base. (This migration was replaced with `0001_initial_squashed_0013_objectchange.py` in more recent releases.) It appears something has gone wrong with your upgrade; likely the v2.7.11 code being installed on top of the existing code instead of in a new directory. I suggest installing v2.7.11 to a new path and trying again. Please post to the [mailing list](https://groups.google.com/forum/#!forum/netbox-discuss) if you need any further assistance.
Author
Owner

@jacotec commented on GitHub (Mar 30, 2020):

Thank you, that was the issue! I always updated by copying the new files over ... lesson learnt! 😊

@jacotec commented on GitHub (Mar 30, 2020): Thank you, that was the issue! I always updated by copying the new files over ... lesson learnt! 😊
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3522