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

Add Pro plan via Migration #495

Merged
merged 14 commits into from
Feb 7, 2025
61 changes: 61 additions & 0 deletions shared/django_apps/codecov_auth/migrations/0066_add_pro_plan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from django.db import migrations

from shared.django_apps.utils.config import RUN_ENV


def add_pro_plan(apps, schema_editor):
if RUN_ENV != "ENTERPRISE":
return

Plan = apps.get_model("codecov_auth", "Plan")
Tier = apps.get_model("codecov_auth", "Tier")
Owner = apps.get_model("codecov_auth", "Owner")
Account = apps.get_model("codecov_auth", "Account")

defaults = {
"bundle_analysis": True,
"test_analytics": True,
"flaky_test_detection": True,
"project_coverage": True,
"private_repo_support": True,
}
pro_tier, _ = Tier.objects.update_or_create(
tier_name="pro",
defaults=defaults,
)

plan_defaults = {
"tier": pro_tier,
"base_unit_price": 10,
"benefits": [
"Configurable # of users",
"Unlimited public repositories",
"Unlimited private repositories",
"Priority Support",
],
"billing_rate": "annually",
"is_active": True,
"marketing_name": "Pro",
"max_seats": None,
"monthly_uploads_limit": None,
"paid_plan": True,
}

Plan.objects.update_or_create(
name="users-pr-inappy",
defaults=plan_defaults,
)

Owner.objects.all().update(plan="users-pr-inappy")

Account.objects.all().update(plan="users-pr-inappy")


class Migration(migrations.Migration):
dependencies = [
("codecov_auth", "0065_alter_account_plan_alter_owner_plan"),
]

operations = [
migrations.RunPython(add_pro_plan),
]
1 change: 1 addition & 0 deletions shared/django_apps/dummy_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
# Needed as certain migrations refer to it
SKIP_RISKY_MIGRATION_STEPS = get_config("migrations", "skip_risky_steps", default=False) # noqa: F405


TEST = True

# Database
Expand Down
4 changes: 3 additions & 1 deletion shared/plan/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from dataclasses import dataclass
from typing import List, Optional

from shared.django_apps.utils.config import RUN_ENV


class MonthlyUploadLimits(enum.Enum):
CODECOV_FREE_PLAN = 250
Expand All @@ -23,7 +25,7 @@ class PlanMarketingName(enum.Enum):
TEAM = "Team"


DEFAULT_FREE_PLAN = "users-developer"
DEFAULT_FREE_PLAN = "users-pr-inappy" if RUN_ENV == "ENTERPRISE" else "users-developer"


class PlanName(enum.Enum):
Expand Down