-
Notifications
You must be signed in to change notification settings - Fork 29
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
Team fixes+migration #1088
Team fixes+migration #1088
Conversation
django/thunderstore/repository/migrations/0055_delete_namespaces_without_team.py
Outdated
Show resolved
Hide resolved
django/thunderstore/repository/migrations/0055_delete_namespaces_without_team.py
Show resolved
Hide resolved
I think it’s a good idea to add a test for the migration. Also, please rebase on master to resolve the pre-commit build issue. |
Fix creating teams with taken namespaces by adding validation to save()
Fix leave team button logic, which previously only let you leave when there were two or more owners on a team
Migration to delete namespaces without a team
Remove unnecessary .lower() from team.py
fc73984
to
d8523d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good otherwise
def forwards(apps, schema_editor): | ||
Namespace = apps.get_model("repository", "Namespace") | ||
|
||
Namespace.objects.filter(team__isnull=True).delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break if the namespace has packages associated to it, so you should filter out namespaces with packages as well. I don't think the production db has any such instances but it is technically a bug so mentioning anyway.
def forwards(apps, schema_editor): | ||
Namespace = apps.get_model("repository", "Namespace") | ||
|
||
Namespace.objects.filter(team__isnull=True).delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namespace.objects.filter(team__isnull=True).delete() | |
Namespace.objects.filter(team__isnull=True, packages=None).delete() |
Deleting namespaces with packages won't work due to database constraints, so filter them out from the datamigration
PR to be merged after #1078
Cleans up the broken namespaces remaining in the database