Clean up nonexistent squashed migrations #10840

Closed
opened 2025-12-29 21:36:36 +01:00 by adam · 1 comment
Owner

Originally created by @bctiemann on GitHub (Mar 5, 2025).

Originally assigned to: @bctiemann on GitHub.

Proposed Changes

The sqlmigrate command fails with errors such as: django.db.migrations.exceptions.NodeNotFoundError: Migration extras.0002_squashed_0059 dependencies reference nonexistent parent node ('dcim', '0002_auto_20160622_1821')

This results from migration squashing where the dependencies list was not updated to point to the new squashed migrations.

Proposed change is to fix all dependencies pointers in existing migrations to ensure they point to the existing migrations containing the original (missing) parent nodes.

Justification

Though sqlmigrate is rarely used (it produces the native SQL operations to be applied during migrations in case they need to be run manually), it is useful as a diagnostic tool and ought to work properly. (Note: migrate itself does not seem to have this issue.)

Originally created by @bctiemann on GitHub (Mar 5, 2025). Originally assigned to: @bctiemann on GitHub. ### Proposed Changes The `sqlmigrate` command fails with errors such as: `django.db.migrations.exceptions.NodeNotFoundError: Migration extras.0002_squashed_0059 dependencies reference nonexistent parent node ('dcim', '0002_auto_20160622_1821')` This results from migration squashing where the `dependencies` list was not updated to point to the new squashed migrations. Proposed change is to fix all `dependencies` pointers in existing migrations to ensure they point to the existing migrations containing the original (missing) parent nodes. ### Justification Though `sqlmigrate` is rarely used (it produces the native SQL operations to be applied during migrations in case they need to be run manually), it is useful as a diagnostic tool and ought to work properly. (Note: `migrate` itself does not seem to have this issue.)
adam added the status: acceptedtype: housekeeping labels 2025-12-29 21:36:36 +01:00
adam closed this issue 2025-12-29 21:36:36 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 5, 2025):

Note: migrate itself does not seem to have this issue.

This is very peculiar. I'd expect both commands to use the same logic for determining dependent migrations.

@jeremystretch commented on GitHub (Mar 5, 2025): > Note: `migrate` itself does not seem to have this issue. This is very peculiar. I'd expect both commands to use the same logic for determining dependent migrations.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10840