From feee9c7e7a24ba19391c09351b4e643ec5d62016 Mon Sep 17 00:00:00 2001 From: Marcus Hof <13001502+MarconLP@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:58:05 +0100 Subject: [PATCH] fix(cdp): update command to change the organization_id on the project as well (#27852) --- posthog/management/commands/change_team_ownership.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/posthog/management/commands/change_team_ownership.py b/posthog/management/commands/change_team_ownership.py index 1dac8b957d191..88b02b4b7bd87 100644 --- a/posthog/management/commands/change_team_ownership.py +++ b/posthog/management/commands/change_team_ownership.py @@ -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) @@ -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}") @@ -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")