Migration from old database (3 years old from 2.2.6) is broken because of ipam squash migration 0026-to-0032 #3614

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

Originally created by @Psycojoker on GitHub (Apr 27, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.6.8
  • NetBox version: 2.2.6 to 2.8.1
  • PostgreSQL version: 9.6.17

Steps to Reproduce

For the context: I've debuged this situation from a friend, apparently upgrade.sh didn't worked for them but looking at the script this is an unrelated bug.

  1. install current stable netbox release (2.8.1)
  2. Take a database dump from a netbox version 2.2.6
  3. restore it
  4. run database migrations (python3 manage.py migrate)

Expected Behavior

Database migrations to run without an error.

Observed Behavior

Migrations fails on migration ipam.0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description with the following traceback:

[root@localhost netbox]# python3 manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, secrets, sessions, taggit, tenancy, users, virtualization
Running migrations:
  Applying ipam.0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description...Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.ObjectInUse: cannot ALTER TABLE "ipam_ipaddress" because it has pending trigger events


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

Traceback (most recent call last):

Solution (I'm sending a PR)

Remove the squashed migration 0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description, re-run the migrate command, django will apply all 0026 to 0032 migrations one by one without any problem.

I'm sending a PR to fix this.

Kind regards,

Originally created by @Psycojoker on GitHub (Apr 27, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: 3.6.8 * NetBox version: 2.2.6 to 2.8.1 * PostgreSQL version: 9.6.17 ### Steps to Reproduce For the context: I've debuged this situation from a friend, apparently `upgrade.sh` didn't worked for them but looking at the script this is an unrelated bug. 1. install current stable netbox release (2.8.1) 2. Take a database dump from a netbox version 2.2.6 3. restore it 4. run database migrations (`python3 manage.py migrate`) ### Expected Behavior Database migrations to run without an error. ### Observed Behavior Migrations fails on migration ipam.0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description with the following traceback: ``` [root@localhost netbox]# python3 manage.py migrate Operations to perform: Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, secrets, sessions, taggit, tenancy, users, virtualization Running migrations: Applying ipam.0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description...Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute return self.cursor.execute(sql, params) psycopg2.errors.ObjectInUse: cannot ALTER TABLE "ipam_ipaddress" because it has pending trigger events The above exception was the direct cause of the following exception: Traceback (most recent call last): ``` ### Solution (I'm sending a PR) Remove the squashed migration 0026_prefix_ordering_vrf_nulls_first_squashed_0032_role_description, re-run the migrate command, django will apply all 0026 to 0032 migrations one by one without any problem. I'm sending a PR to fix this. Kind regards,
adam added the type: bugstatus: accepted labels 2025-12-29 18:30:10 +01:00
adam closed this issue 2025-12-29 18:30:10 +01:00
Author
Owner

@sdktr commented on GitHub (Apr 29, 2020):

I’m surprised it worked to upgrade from this very old release at all. This big of a gap is not something that can be supported reliably so I assume this request will end on the ‘wontfix’ list.
The squashed migrations are created for more speedy upgrades I believe. Around the time they were first used there was some guidance on what upgrade scenarios were targeted for support..

@sdktr commented on GitHub (Apr 29, 2020): I’m surprised it worked to upgrade from this very old release at all. This big of a gap is not something that can be supported reliably so I assume this request will end on the ‘wontfix’ list. The squashed migrations are created for more speedy upgrades I believe. Around the time they were first used there was some guidance on what upgrade scenarios were targeted for support..
Author
Owner

@jeremystretch commented on GitHub (Apr 29, 2020):

I discussed this and related issues with the other maintainers today, and the consensus was to simply ditch the squashed migrations. The meager performance gains they afford are outweighed by the burden of curating them.

@jeremystretch commented on GitHub (Apr 29, 2020): I discussed this and related issues with the other maintainers today, and the consensus was to simply ditch the squashed migrations. The meager performance gains they afford are outweighed by the burden of curating them.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3614