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 "Applying users.0006_custom_group_model" to 4.0-beta1 fails #15695

Closed
tobiasge opened this issue Apr 11, 2024 · 3 comments
Closed

Migration "Applying users.0006_custom_group_model" to 4.0-beta1 fails #15695

tobiasge opened this issue Apr 11, 2024 · 3 comments
Assignees
Labels
beta Concerns a bug/feature in a beta release severity: high Completely breaks certain functions, or substantially degrades performance application-wide status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@tobiasge
Copy link
Member

Deployment Type

Self-hosted

NetBox Version

v4.0-beta1 (89dd423)

Python Version

3.11

Steps to Reproduce

  1. Netbox setup with 3.7.5 (upgraded from 2.5)
  2. Migrate to v4.0-beta1 (89dd4230807bf5d8f6de586d86120d8148d23eb1)

Expected Behavior

Successful run of all migrations

Observed Behavior

Migration Applying users.0006_custom_group_model fails with this error:

psycopg.errors.ForeignKeyViolation: update or delete on table "auth_group" violates foreign key constraint "auth_group_permissions_group_id_b120cbf9_fk_auth_group_id" on table "auth_group_permissions"
DETAIL:  Key (id)=(10) is still referenced from table "auth_group_permissions".

Table list pre migration: https://gist.github.com/tobiasge/382ec52aaca740b622d480c75f95acf6#file-3-7-5-table-list-txt
Full stack trace: https://gist.github.com/tobiasge/382ec52aaca740b622d480c75f95acf6#file-exception-txt
Table list after migration try: https://gist.github.com/tobiasge/382ec52aaca740b622d480c75f95acf6#file-4-0-beta-table-list-txt

@tobiasge tobiasge added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Apr 11, 2024
@jeremystretch jeremystretch removed their assignment Apr 11, 2024
@jeremystretch jeremystretch added beta Concerns a bug/feature in a beta release severity: high Completely breaks certain functions, or substantially degrades performance application-wide status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation and removed status: needs triage This issue is awaiting triage by a maintainer labels Apr 11, 2024
@jeremystretch
Copy link
Member

@tobiasge it looks like you have one or more legacy permissions in the auth_group_permissions table referencing the stock Group model. NetBox moved to a custom object-based permission model back in v2.9, and the legacy permissions are no longer used for anything. There was a migration to copy the legacy permissions into the new table but I don't believe the old ones were ever deleted.

Could you try clearing out that table and re-running the v4.0 migration? (DELETE FROM auth_group_permissions in the dbshell should do it.)

@jeremystretch jeremystretch added status: under review Further discussion is needed to determine this issue's scope and/or implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Apr 15, 2024
@jeremystretch jeremystretch self-assigned this Apr 15, 2024
@tobiasge
Copy link
Member Author

DELETE FROM auth_group_permissions
DELETE 627

After this the Applying users.0006_custom_group_model was successful.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Apr 16, 2024
@tobiasge
Copy link
Member Author

Just for completeness: I did some research and figured out that the first installation with this database was on Netbox 2.2.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Concerns a bug/feature in a beta release severity: high Completely breaks certain functions, or substantially degrades performance application-wide status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants