Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Psycojoker opened this issue Apr 27, 2020 · 2 comments · Fixed by #4552
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@Psycojoker
Copy link

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,

@Psycojoker Psycojoker changed the title Migration from old database (3 years old) is broken because of ipam squash migration 0026-to-0032 Migration from old database (3 years old from 2.2.6) is broken because of ipam squash migration 0026-to-0032 Apr 27, 2020
@sdktr
Copy link
Contributor

sdktr commented Apr 28, 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..

@jeremystretch
Copy link
Member

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 jeremystretch added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Apr 29, 2020
@jeremystretch jeremystretch self-assigned this Apr 29, 2020
jeremystretch added a commit that referenced this issue Apr 29, 2020
…igrations

Fixes #4545: Remove squashed migrations
jeremystretch added a commit that referenced this issue Apr 29, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants