Upgrade from 3.4.4 to 3.7.0 failed due to migrations applied in wrong order #9029

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

Originally created by @skyhisi on GitHub (Jan 3, 2024).

Deployment Type

Self-hosted

NetBox Version

v3.7.0

Python Version

3.9

Steps to Reproduce

When upgrading from 3.4.4 to 3.7.0, the upgrade.sh script failed with the error:

  Applying ipam.0064_clear_search_cache...Skipping config initialization (database unavailable)
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/netbox/venv/lib/python3.9/site-packages/psycopg/cursor.py", line 737, in execute
    raise ex.with_traceback(None)
psycopg.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block

Postgres logged the following:

2024-01-03 19:15:27.450 UTC [67224] netbox@netbox ERROR:  relation "core_configrevision" does not exist at character 136
2024-01-03 19:15:27.450 UTC [67224] netbox@netbox STATEMENT:  SELECT "core_configrevision"."id", "core_configrevision"."created", "core_configrevision"."comment", "core_configrevision"."data" FROM "core_configrevision" ORDER BY "core_configrevision"."created" ASC LIMIT 1
2024-01-03 19:15:27.460 UTC [67224] netbox@netbox ERROR:  current transaction is aborted, commands ignored until end of transaction block

I was able to work around the issue by manually running the migration to move configrevision:

./venv/bin/python3 netbox/manage.py migrate extras 0102_move_configrevision

After this the upgrade was able to work as expected.

Expected Behavior

Database migrations should have worked

Observed Behavior

Database migrations were applied in wrong order

Originally created by @skyhisi on GitHub (Jan 3, 2024). ### Deployment Type Self-hosted ### NetBox Version v3.7.0 ### Python Version 3.9 ### Steps to Reproduce When upgrading from 3.4.4 to 3.7.0, the upgrade.sh script failed with the error: ``` Applying ipam.0064_clear_search_cache...Skipping config initialization (database unavailable) Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params) File "/opt/netbox/venv/lib/python3.9/site-packages/psycopg/cursor.py", line 737, in execute raise ex.with_traceback(None) psycopg.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block ``` Postgres logged the following: ``` 2024-01-03 19:15:27.450 UTC [67224] netbox@netbox ERROR: relation "core_configrevision" does not exist at character 136 2024-01-03 19:15:27.450 UTC [67224] netbox@netbox STATEMENT: SELECT "core_configrevision"."id", "core_configrevision"."created", "core_configrevision"."comment", "core_configrevision"."data" FROM "core_configrevision" ORDER BY "core_configrevision"."created" ASC LIMIT 1 2024-01-03 19:15:27.460 UTC [67224] netbox@netbox ERROR: current transaction is aborted, commands ignored until end of transaction block ``` I was able to work around the issue by manually running the migration to move configrevision: ``` ./venv/bin/python3 netbox/manage.py migrate extras 0102_move_configrevision ``` After this the upgrade was able to work as expected. ### Expected Behavior Database migrations should have worked ### Observed Behavior Database migrations were applied in wrong order
adam closed this issue 2025-12-29 20:44:23 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9029