Skip to content

Commit

Permalink
fix(cdp): update command to change the organization_id on the project…
Browse files Browse the repository at this point in the history
… as well (#27852)
  • Loading branch information
MarconLP authored Jan 24, 2025
1 parent 6f052c6 commit feee9c7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions posthog/management/commands/change_team_ownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.management import CommandError
from django.core.management.base import BaseCommand

from posthog.models import Organization, Team
from posthog.models import Organization, Team, Project

logger = structlog.get_logger(__name__)
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -40,6 +40,9 @@ def run(options):
team = Team.objects.get(pk=team_id)
logger.info(f"Team {team_id} is currently in organization {team.organization_id}, named {team.organization.name}")

project = Project.objects.get(pk=team.project_id)
logger.info(f"Team {team_id} is currently in project {team.project_id}, named {project.name}")

org = Organization.objects.get(pk=organization_id)
logger.info(f"Target organization {organization_id} is named {org.name}")

Expand All @@ -48,7 +51,9 @@ def run(options):

if live_run:
team.organization_id = organization_id
project.organization_id = organization_id
team.save()
logger.info("Saved team change")
project.save()
logger.info("Saved team and project changes")
else:
logger.info("Skipping the team change, pass --live-run to run it")

0 comments on commit feee9c7

Please sign in to comment.