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

fix: make plan non-nullable and drop plan type #533

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.16 on 2025-02-24 23:48

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("codecov_auth", "0066_add_pro_plan"),
]

operations = [
migrations.RunSQL("ALTER TABLE owners ALTER COLUMN plan DROP DEFAULT;"),
migrations.AlterField(
model_name="owner",
name="plan",
field=models.TextField(blank=True, default="users-developer"),
),
]
4 changes: 1 addition & 3 deletions shared/django_apps/codecov_auth/models.py
Original file line number Diff line number Diff line change
@@ -327,9 +327,7 @@ class Meta:
staff = models.BooleanField(null=True, default=False)
cache = models.JSONField(null=True)
# Really an ENUM in db
plan = models.TextField(
null=True, default=PlanName.USERS_DEVELOPER.value, blank=True
)
plan = models.TextField(default=PlanName.USERS_DEVELOPER.value, blank=True)
plan_provider = models.TextField(
null=True, choices=PlanProviders.choices, blank=True
) # postgres enum containing only "github"
Original file line number Diff line number Diff line change
@@ -79,10 +79,10 @@ def test_repo_credits_returns_infinity_for_user_plans(self):
self.owner.plan = plan
assert self.owner.repo_credits == INFINITY

def test_repo_credits_treats_null_plan_as_free_plan(self):
def test_repo_credits_errors_when_plan_is_null(self):
self.owner.plan = None
self.owner.save()
assert self.owner.repo_credits == 1 + self.owner.free or 0
with self.assertRaises(IntegrityError):
self.owner.save()

def test_nb_active_private_repos(self):
owner = OwnerFactory()