Management command sqlmigrate doesn't work #10980

Closed
opened 2025-12-29 21:38:44 +01:00 by adam · 3 comments
Owner

Originally created by @karimone on GitHub (Apr 2, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.2.6

Python Version

3.11

Steps to Reproduce

The django command sqlmigrate doesn't work with squashed migrations.

On main branch try

manage.py sqlmigrate wireless 0013

Expected Behavior

Show the SQL output of the migration.

This might be an issue with the Django command not being able to recognize the squashed migrations. Or maybe I'm doing something wrong.

I have a few questions:

  • Is it really worth squashing migrations? What’s the actual benefit? Django docs claims to be able to work with hundreds of migrations without any performance issue.
  • Should we be more careful when squashing, and also update the references in the other migrations? Maybe creating a specific command or script that updates the references?

Observed Behavior

  File "/Users/admin/.pyenv/versions/netbox/lib/python3.11/site-packages/django/db/migrations/graph.py", line 60, in raise_error
    raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration core.0006_datasource_type_remove_choices dependencies reference nonexistent parent node ('core', '0005_job_created_auto_now')
Originally created by @karimone on GitHub (Apr 2, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.2.6 ### Python Version 3.11 ### Steps to Reproduce The django command `sqlmigrate` doesn't work with squashed migrations. On main branch try ```bash manage.py sqlmigrate wireless 0013 ``` ### Expected Behavior Show the SQL output of the migration. This might be an issue with the Django command not being able to recognize the squashed migrations. Or maybe I'm doing something wrong. I have a few questions: - Is it really worth squashing migrations? What’s the actual benefit? Django docs claims to be able to work with hundreds of migrations without any performance issue. - Should we be more careful when squashing, and also update the references in the other migrations? Maybe creating a specific command or script that updates the references? ### Observed Behavior ``` File "/Users/admin/.pyenv/versions/netbox/lib/python3.11/site-packages/django/db/migrations/graph.py", line 60, in raise_error raise NodeNotFoundError(self.error_message, self.key, origin=self.origin) django.db.migrations.exceptions.NodeNotFoundError: Migration core.0006_datasource_type_remove_choices dependencies reference nonexistent parent node ('core', '0005_job_created_auto_now') ```
adam added the type: bugstatus: duplicate labels 2025-12-29 21:38:44 +01:00
adam closed this issue 2025-12-29 21:38:44 +01:00
Author
Owner

@nahun commented on GitHub (Apr 3, 2025):

See the original issue for why it was done #6471

@nahun commented on GitHub (Apr 3, 2025): See the original issue for why it was done #6471
Author
Owner

@bctiemann commented on GitHub (Apr 3, 2025):

This has been addressed in https://github.com/netbox-community/netbox/pull/18827 (targeted for 4.3).

@bctiemann commented on GitHub (Apr 3, 2025): This has been addressed in https://github.com/netbox-community/netbox/pull/18827 (targeted for 4.3).
Author
Owner

@bctiemann commented on GitHub (Apr 3, 2025):

Duplicate of #18808

@bctiemann commented on GitHub (Apr 3, 2025): Duplicate of #18808
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10980