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

Team fixes+migration #1088

Merged
merged 5 commits into from
Jan 29, 2025
Merged

Team fixes+migration #1088

merged 5 commits into from
Jan 29, 2025

Conversation

x753
Copy link
Contributor

@x753 x753 commented Jan 17, 2025

PR to be merged after #1078

Cleans up the broken namespaces remaining in the database

@Roffenlund
Copy link
Contributor

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.

x753 added 4 commits January 20, 2025 07:21
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
@x753 x753 force-pushed the team-fixes+migration branch from fc73984 to d8523d7 Compare January 20, 2025 12:25
@Roffenlund Roffenlund mentioned this pull request Jan 21, 2025
@x753 x753 requested review from MythicManiac and removed request for MythicManiac January 29, 2025 14:46
Copy link
Member

@MythicManiac MythicManiac left a 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()
Copy link
Member

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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
@MythicManiac MythicManiac merged commit d4ab954 into master Jan 29, 2025
24 checks passed
@MythicManiac MythicManiac deleted the team-fixes+migration branch January 29, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants