:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(aio): drop trial eval columns (#72692)
Carlos Marchal38181e5ebd75
diff --git a/posthog/temporal/ai_observability/__init__.py b/posthog/temporal/ai_observability/__init__.pyindex df13008704d7..376a6b007472 100644--- a/posthog/temporal/ai_observability/__init__.py+++ b/posthog/temporal/ai_observability/__init__.py@@ -38,9 +38,7 @@ from posthog.temporal.ai_observability.evaluation_workflow_activities import (emit_evaluation_event_activity,emit_internal_telemetry_activity,fetch_evaluation_activity,- increment_trial_eval_count_activity,send_evaluation_disabled_email_activity,- send_trial_usage_email_activity,update_key_state_activity,)from posthog.temporal.ai_observability.metrics import EvalsMetricsInterceptor # noqa: F401@@ -89,9 +87,6 @@ EVAL_WORKFLOWS = [EVAL_ACTIVITIES = [fetch_evaluation_activity,- # Trial-eval no-op stubs, kept registered so runs started on the previous release can finish.- increment_trial_eval_count_activity,- send_trial_usage_email_activity,disable_evaluation_activity,send_evaluation_disabled_email_activity,update_key_state_activity,@@ -172,9 +167,7 @@ ACTIVITIES = [emit_evaluation_cluster_events_activity,# Keep eval activities registered here temporarily so orphaned workflows on general-purpose queue can completefetch_evaluation_activity,- increment_trial_eval_count_activity,disable_evaluation_activity,- send_trial_usage_email_activity,send_evaluation_disabled_email_activity,update_key_state_activity,execute_llm_judge_activity,diff --git a/posthog/temporal/ai_observability/evaluation_workflow_activities.py b/posthog/temporal/ai_observability/evaluation_workflow_activities.pyindex bdd350d0750f..7165983f1f9e 100644--- a/posthog/temporal/ai_observability/evaluation_workflow_activities.py+++ b/posthog/temporal/ai_observability/evaluation_workflow_activities.py@@ -94,27 +94,6 @@ async def update_key_state_activity(key_id: str, state: str, error_message: strawait database_sync_to_async(_update)()-@dataclass-class SendTrialUsageEmailInputs:- team_id: int- threshold_pct: int---async def increment_trial_eval_count_activity(team_id: int) -> int | None:- """No-op stub kept registered so evaluation runs started on the previous release can finish- during the rollout. Returning None means no usage email follows. The follow-up column-drop PR- deletes it."""- return None---async def send_trial_usage_email_activity(inputs: SendTrialUsageEmailInputs) -> None:- """No-op stub kept registered so evaluation runs started on the previous release can finish- during the rollout. The follow-up column-drop PR deletes it."""- return None--@temporalio.activity.defnasync def disable_evaluation_activity(evaluation_id: str, team_id: int, status_reason: str = "", status_reason_detail: str | None = Nonediff --git a/posthog/temporal/ai_observability/run_evaluation.py b/posthog/temporal/ai_observability/run_evaluation.pyindex 63225e3f1046..94062b782eb5 100644--- a/posthog/temporal/ai_observability/run_evaluation.py+++ b/posthog/temporal/ai_observability/run_evaluation.py@@ -34,14 +34,11 @@ from posthog.temporal.ai_observability.evaluation_workflow_activities import (EmitInternalTelemetryInputs,RunEvaluationInputs,SendEvaluationDisabledEmailInputs,- SendTrialUsageEmailInputs,disable_evaluation_activity,emit_evaluation_event_activity,emit_internal_telemetry_activity,fetch_evaluation_activity,- increment_trial_eval_count_activity,send_evaluation_disabled_email_activity,- send_trial_usage_email_activity,update_key_state_activity,)from posthog.temporal.ai_observability.metrics import increment_errors@@ -65,7 +62,6 @@ __all__ = ["RunEvaluationInputs","RunEvaluationWorkflow","SendEvaluationDisabledEmailInputs",- "SendTrialUsageEmailInputs","WorkflowResult","build_system_prompt","disable_evaluation_activity",@@ -80,11 +76,8 @@ __all__ = ["get_output_type_config","handle_llm_judge_activity_error","handle_terminal_user_error_result",- "increment_trial_eval_count_activity",- "increment_trial_usage_and_notify","run_hog_eval","send_evaluation_disabled_email_activity",- "send_trial_usage_email_activity","update_key_state_activity",]@@ -198,43 +191,16 @@ async def handle_terminal_user_error_result(retry_policy=RetryPolicy(maximum_attempts=2),)- # Replay-only compatibility for runs started before trial evals were removed: reproduce the- # commands the old code scheduled for trial-era errors, without resurrecting their specs.- # workflow.patched returns False only when replaying pre-patch histories, so fresh runs never- # take the legacy branches. Remove together with the columns in the follow-up PR.- legacy_trial_era = not temporalio.workflow.patched("remove-trial-evals")- skip_reason_str = str(skip_reason) if skip_reason else None- if (- legacy_trial_era- and skip_reason_str == "trial_limit_reached"- and temporalio.workflow.patched("trial-usage-email")- ):- try:- await temporalio.workflow.execute_activity(- send_trial_usage_email_activity,- SendTrialUsageEmailInputs(team_id=evaluation["team_id"], threshold_pct=100),- activity_id=f"send-trial-usage-email-100pct-{evaluation['team_id']}",- schedule_to_close_timeout=timedelta(seconds=30),- retry_policy=RetryPolicy(maximum_attempts=2),- )- except Exception:- temporalio.workflow.logger.exception(- "Failed to send trial exhausted email",- team_id=evaluation["team_id"],- )-dedupe_disabled_email = temporalio.workflow.patched("eval-disabled-email-on-disable-transition")- legacy_model_not_allowed = legacy_trial_era and skip_reason_str == "model_not_allowed"should_send_disabled_email = (- ((spec is not None and spec.disables_evaluation) or legacy_model_not_allowed)+ spec is not None+ and spec.disables_evaluationand bool(status_reason)and (disabled_evaluation or not dedupe_disabled_email)and temporalio.workflow.patched("eval-disabled-email"))if should_send_disabled_email:- human_readable_reason = (- spec.safe_message if spec is not None else "The selected model is not available on the trial plan."- )+ assert spec is not Noneemail_status_reason = str(status_reason)try:await temporalio.workflow.execute_activity(@@ -244,7 +210,7 @@ async def handle_terminal_user_error_result(evaluation_id=evaluation["id"],evaluation_name=evaluation.get("name", "Unknown evaluation"),status_reason=email_status_reason,- human_readable_reason=human_readable_reason,+ human_readable_reason=spec.safe_message,disabled_at=temporalio.workflow.now(),),activity_id=f"send-eval-disabled-email-{evaluation['id']}-{email_status_reason}",@@ -269,36 +235,6 @@ async def handle_terminal_user_error_result(return workflow_result-async def increment_trial_usage_and_notify(evaluation: dict[str, Any]) -> None:- """Replay-only compatibility for runs started before trial evals were removed: reproduces the- activity commands the old code scheduled after a PostHog-key LLM judge run. Callers gate on- `workflow.patched("remove-trial-evals")`, so fresh runs never reach this. Must run inside a- workflow context. Remove together with the columns in the follow-up PR."""- threshold_pct = await temporalio.workflow.execute_activity(- increment_trial_eval_count_activity,- evaluation["team_id"],- activity_id=f"increment-trial-{evaluation['id']}",- schedule_to_close_timeout=timedelta(seconds=10),- retry_policy=RetryPolicy(maximum_attempts=2),- )-- if threshold_pct is not None and temporalio.workflow.patched("trial-usage-email"):- try:- await temporalio.workflow.execute_activity(- send_trial_usage_email_activity,- SendTrialUsageEmailInputs(team_id=evaluation["team_id"], threshold_pct=threshold_pct),- activity_id=f"send-trial-usage-email-{threshold_pct}pct-{evaluation['team_id']}",- schedule_to_close_timeout=timedelta(seconds=30),- retry_policy=RetryPolicy(maximum_attempts=2),- )- except Exception:- temporalio.workflow.logger.exception(- "Failed to send trial usage email",- team_id=evaluation["team_id"],- threshold_pct=threshold_pct,- )--@temporalio.workflow.defn(name="run-evaluation")class RunEvaluationWorkflow(PostHogWorkflow):@staticmethod@@ -310,6 +246,10 @@ class RunEvaluationWorkflow(PostHogWorkflow):@temporalio.workflow.runasync def run(self, inputs: RunEvaluationInputs) -> WorkflowResult:+ # Every #71518-era run recorded the "remove-trial-evals" patch marker; accept those+ # histories for one release, then delete this call (temporal-workflow-versioning rule).+ temporalio.workflow.deprecate_patch("remove-trial-evals")+start_time = temporalio.workflow.now()evaluation = await temporalio.workflow.execute_activity(fetch_evaluation_activity,@@ -347,14 +287,6 @@ class RunEvaluationWorkflow(PostHogWorkflow):if handled is not None:return handledraise-- # Replay-only; see increment_trial_usage_and_notify.- if (- not temporalio.workflow.patched("remove-trial-evals")- and not result.get("is_byok")- and not result.get("skipped")- ):- await increment_trial_usage_and_notify(evaluation)else:raise ApplicationError(f"Unsupported evaluation type: {evaluation_type}",diff --git a/posthog/temporal/ai_observability/run_tagger.py b/posthog/temporal/ai_observability/run_tagger.pyindex aff98c5f27cf..4f850710d803 100644--- a/posthog/temporal/ai_observability/run_tagger.py+++ b/posthog/temporal/ai_observability/run_tagger.py@@ -14,12 +14,7 @@ from posthog.api.capture import capture_internalfrom posthog.models.team import Teamfrom posthog.sync import database_sync_to_asyncfrom posthog.temporal.ai_observability.evaluation_event_io import extract_event_io-from posthog.temporal.ai_observability.evaluation_workflow_activities import (- SendTrialUsageEmailInputs,- increment_trial_eval_count_activity,- send_trial_usage_email_activity,- update_key_state_activity,-)+from posthog.temporal.ai_observability.evaluation_workflow_activities import update_key_state_activityfrom posthog.temporal.ai_observability.message_utils import extract_text_from_messagesfrom posthog.temporal.ai_observability.model_resolution import model_specfrom posthog.temporal.common.base import PostHogWorkflow@@ -567,6 +562,10 @@ class RunTaggerWorkflow(PostHogWorkflow):@temporalio.workflow.runasync def run(self, inputs: RunTaggerInputs) -> dict[str, Any]:+ # Every #71518-era run recorded the "remove-trial-evals" patch marker; accept those+ # histories for one release, then delete this call (temporal-workflow-versioning rule).+ temporalio.workflow.deprecate_patch("remove-trial-evals")+start_time = temporalio.workflow.now()# Activity 1: Fetch tagger config@@ -615,24 +614,15 @@ class RunTaggerWorkflow(PostHogWorkflow):details = e.cause.details[0]error_type = details.get("error_type")- # Replay-only compatibility for runs started before trial evals were removed:- # reproduce the commands the old code scheduled for trial-era errors.- # workflow.patched returns False only when replaying pre-patch histories, so- # fresh runs never take the legacy branches. Remove in the follow-up PR.- legacy_trial_era = not temporalio.workflow.patched("remove-trial-evals")- legacy_trial_error_types = ("trial_limit_reached", "model_not_allowed") if legacy_trial_era else ()-if error_type in ("provider_key_required","key_invalid","parse_error","no_default_model",- *legacy_trial_error_types,):if error_type in ("provider_key_required","no_default_model",- *legacy_trial_error_types,):await temporalio.workflow.execute_activity(disable_tagger_activity,@@ -640,24 +630,6 @@ class RunTaggerWorkflow(PostHogWorkflow):schedule_to_close_timeout=timedelta(seconds=30),retry_policy=RetryPolicy(maximum_attempts=2),)- if (- legacy_trial_era- and error_type in ("provider_key_required", "trial_limit_reached", "model_not_allowed")- and temporalio.workflow.patched("trial-usage-email")- ):- try:- await temporalio.workflow.execute_activity(- send_trial_usage_email_activity,- SendTrialUsageEmailInputs(team_id=tagger["team_id"], threshold_pct=100),- activity_id=f"send-trial-usage-email-100pct-tagger-{tagger['team_id']}",- schedule_to_close_timeout=timedelta(seconds=30),- retry_policy=RetryPolicy(maximum_attempts=2),- )- except Exception:- temporalio.workflow.logger.exception(- "Failed to send trial exhausted email",- team_id=tagger["team_id"],- )return {"tags": [],"skipped": True,@@ -680,33 +652,6 @@ class RunTaggerWorkflow(PostHogWorkflow):)raise- # Replay-only trial counting for runs started before trial evals were removed; the- # activities are no-op stubs. Remove in the follow-up PR.- if not temporalio.workflow.patched("remove-trial-evals") and tagger_type != "hog" and not result.get("is_byok"):- threshold_pct = await temporalio.workflow.execute_activity(- increment_trial_eval_count_activity,- tagger["team_id"],- activity_id=f"increment-trial-tagger-{tagger['id']}",- schedule_to_close_timeout=timedelta(seconds=10),- retry_policy=RetryPolicy(maximum_attempts=2),- )-- if threshold_pct is not None and temporalio.workflow.patched("trial-usage-email"):- try:- await temporalio.workflow.execute_activity(- send_trial_usage_email_activity,- SendTrialUsageEmailInputs(team_id=tagger["team_id"], threshold_pct=threshold_pct),- activity_id=f"send-trial-usage-email-{threshold_pct}pct-tagger-{tagger['team_id']}",- schedule_to_close_timeout=timedelta(seconds=30),- retry_policy=RetryPolicy(maximum_attempts=2),- )- except Exception:- temporalio.workflow.logger.exception(- "Failed to send trial usage email",- team_id=tagger["team_id"],- threshold_pct=threshold_pct,- )-# Activity 3: Emit tagger eventawait temporalio.workflow.execute_activity(emit_tagger_event_activity,diff --git a/posthog/temporal/ai_observability/run_trace_evaluation.py b/posthog/temporal/ai_observability/run_trace_evaluation.pyindex 8daf2f857832..7d492f11e7d3 100644--- a/posthog/temporal/ai_observability/run_trace_evaluation.py+++ b/posthog/temporal/ai_observability/run_trace_evaluation.py@@ -62,7 +62,6 @@ from posthog.temporal.ai_observability.run_evaluation import (WorkflowResult,handle_llm_judge_activity_error,handle_terminal_user_error_result,- increment_trial_usage_and_notify,)from posthog.temporal.common.base import PostHogWorkflowfrom posthog.temporal.common.utils import close_db_connections@@ -481,6 +480,10 @@ class RunTraceEvaluationWorkflow(PostHogWorkflow):@temporalio.workflow.runasync def run(self, inputs: RunTraceEvaluationInputs) -> WorkflowResult:+ # Every #71518-era run recorded the "remove-trial-evals" patch marker; accept those+ # histories for one release, then delete this call (temporal-workflow-versioning rule).+ temporalio.workflow.deprecate_patch("remove-trial-evals")+window_start = temporalio.workflow.now()# Wait for the rest of the trace to arrive. Timers are server-side, so sleeping@@ -542,14 +545,6 @@ class RunTraceEvaluationWorkflow(PostHogWorkflow):return handledraise- # Replay-only; see increment_trial_usage_and_notify.- if (- not temporalio.workflow.patched("remove-trial-evals")- and not result.get("is_byok")- and not result.get("skipped")- ):- await increment_trial_usage_and_notify(evaluation)-if is_terminal_user_error_result(result):return await handle_terminal_user_error_result(evaluation=evaluation,diff --git a/posthog/temporal/tests/ai/test_module_integrity.py b/posthog/temporal/tests/ai/test_module_integrity.pyindex 47fdc406dce5..f2ee82d05e6b 100644--- a/posthog/temporal/tests/ai/test_module_integrity.py+++ b/posthog/temporal/tests/ai/test_module_integrity.py@@ -353,9 +353,7 @@ class TestAIObservabilityModuleIntegrity:"compute_evaluation_cluster_aggregates_activity","emit_evaluation_cluster_events_activity","fetch_evaluation_activity",- "increment_trial_eval_count_activity","disable_evaluation_activity",- "send_trial_usage_email_activity","send_evaluation_disabled_email_activity","update_key_state_activity","execute_llm_judge_activity",diff --git a/products/ai_observability/backend/api/provider_keys.py b/products/ai_observability/backend/api/provider_keys.pyindex 01b0e0aef766..0a2fe17cfffb 100644--- a/products/ai_observability/backend/api/provider_keys.py+++ b/products/ai_observability/backend/api/provider_keys.py@@ -434,6 +434,12 @@ class LLMProviderKeyViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, vexcept LLMProviderKey.DoesNotExist:return Response({"detail": "Replacement key not found"}, status=status.HTTP_400_BAD_REQUEST)+ if replacement_key.id == instance.id:+ return Response(+ {"detail": "Replacement key cannot be the key being deleted"},+ status=status.HTTP_400_BAD_REQUEST,+ )+if replacement_key.provider != instance.provider:return Response({"detail": "Replacement key must be from the same provider"}, status=status.HTTP_400_BAD_REQUEST@@ -448,6 +454,15 @@ class LLMProviderKeyViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, vLLMModelConfiguration.objects.filter(id__in=model_config_ids, team_id=self.team_id).update(provider_key=replacement_key)++ # The deleted key may also be the team's active key — the fallback that keyless+ # evals resolve through. Honor the user's replacement choice instead of letting+ # the SET_NULL cascade strand them.+ config = EvaluationConfig.objects.filter(team_id=self.team_id, active_provider_key=instance).first()+ if config:+ config.active_provider_key = replacement_key+ config.save(update_fields=["active_provider_key", "updated_at"])+_reload_model_config_dependents_on_commit(self.team_id, model_config_ids)return super().destroy(request, *args, **kwargs)else:diff --git a/products/ai_observability/backend/api/test/test_provider_keys.py b/products/ai_observability/backend/api/test/test_provider_keys.pyindex e86409c24dc3..95af100235b3 100644--- a/products/ai_observability/backend/api/test/test_provider_keys.py+++ b/products/ai_observability/backend/api/test/test_provider_keys.py@@ -1044,6 +1044,97 @@ class TestLLMProviderKeyDependentConfigs(APIBaseTest):self.assertEqual(model_config.provider_key, key2)self.assertEqual(LLMProviderKey.objects.filter(id=key1.id).count(), 0)+ def test_delete_active_key_with_replacement_switches_active_key(self):+ key1 = LLMProviderKey.objects.create(+ team=self.team,+ provider="openai",+ name="Key 1",+ state=LLMProviderKey.State.OK,+ encrypted_config={"api_key": "sk-key1"},+ created_by=self.user,+ )+ key2 = LLMProviderKey.objects.create(+ team=self.team,+ provider="openai",+ name="Key 2",+ state=LLMProviderKey.State.OK,+ encrypted_config={"api_key": "sk-key2"},+ created_by=self.user,+ )+ config = EvaluationConfig.objects.create(team=self.team, active_provider_key=key1)++ response = self.client.delete(+ f"/api/environments/{self.team.id}/llm_analytics/provider_keys/{key1.id}/?replacement_key_id={key2.id}"+ )+ self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)++ config.refresh_from_db()+ self.assertEqual(config.active_provider_key, key2)++ def test_delete_non_active_key_with_replacement_keeps_active_key(self):+ active_key = LLMProviderKey.objects.create(+ team=self.team,+ provider="openai",+ name="Active",+ state=LLMProviderKey.State.OK,+ encrypted_config={"api_key": "sk-active"},+ created_by=self.user,+ )+ key1 = LLMProviderKey.objects.create(+ team=self.team,+ provider="openai",+ name="Key 1",+ state=LLMProviderKey.State.OK,+ encrypted_config={"api_key": "sk-key1"},+ created_by=self.user,+ )+ key2 = LLMProviderKey.objects.create(+ team=self.team,+ provider="openai",+ name="Key 2",+ state=LLMProviderKey.State.OK,+ encrypted_config={"api_key": "sk-key2"},+ created_by=self.user,+ )+ config = EvaluationConfig.objects.create(team=self.team, active_provider_key=active_key)++ response = self.client.delete(+ f"/api/environments/{self.team.id}/llm_analytics/provider_keys/{key1.id}/?replacement_key_id={key2.id}"+ )+ self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)++ config.refresh_from_db()+ self.assertEqual(config.active_provider_key, active_key)++ def test_delete_active_key_switches_even_when_replacement_unhealthy(self):+ key1 = LLMProviderKey.objects.create(+ team=self.team,+ provider="openai",+ name="Key 1",+ state=LLMProviderKey.State.OK,+ encrypted_config={"api_key": "sk-key1"},+ created_by=self.user,+ )+ key2 = LLMProviderKey.objects.create(+ team=self.team,+ provider="openai",+ name="Key 2",+ state=LLMProviderKey.State.INVALID,+ encrypted_config={"api_key": "sk-key2"},+ created_by=self.user,+ )+ config = EvaluationConfig.objects.create(team=self.team, active_provider_key=key1)++ response = self.client.delete(+ f"/api/environments/{self.team.id}/llm_analytics/provider_keys/{key1.id}/?replacement_key_id={key2.id}"+ )+ self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)++ # The user explicitly chose the replacement; an unhealthy key surfaces precise runtime+ # errors, where a NULL active key would only ever say provider_key_required.+ config.refresh_from_db()+ self.assertEqual(config.active_provider_key, key2)+def test_delete_without_replacement_disables_evaluations(self):key = LLMProviderKey.objects.create(team=self.team,@@ -1157,6 +1248,31 @@ class TestLLMProviderKeyDependentConfigs(APIBaseTest):self.assertIn("not found", response.data["detail"])self.assertEqual(LLMProviderKey.objects.filter(id=key.id).count(), 1)+ def test_delete_with_self_as_replacement_fails(self):+ key = LLMProviderKey.objects.create(+ team=self.team,+ provider="openai",+ name="My Key",+ state=LLMProviderKey.State.OK,+ encrypted_config={"api_key": "sk-key"},+ created_by=self.user,+ )+ model_config = LLMModelConfiguration.objects.create(+ team=self.team,+ provider="openai",+ model="gpt-5-mini",+ provider_key=key,+ )++ response = self.client.delete(+ f"/api/environments/{self.team.id}/llm_analytics/provider_keys/{key.id}/?replacement_key_id={key.id}"+ )+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)+ self.assertIn("key being deleted", response.data["detail"])+ self.assertEqual(LLMProviderKey.objects.filter(id=key.id).count(), 1)+ model_config.refresh_from_db()+ self.assertEqual(model_config.provider_key, key)+def test_delete_with_other_teams_replacement_key_fails(self):other_team = _setup_team()key = LLMProviderKey.objects.create(diff --git a/products/ai_observability/backend/migrations/0027_resweep_trial_status_reasons.py b/products/ai_observability/backend/migrations/0027_resweep_trial_status_reasons.pynew file mode 100644index 000000000000..a5445b519843--- /dev/null+++ b/products/ai_observability/backend/migrations/0027_resweep_trial_status_reasons.py@@ -0,0 +1,22 @@+from django.db import migrations+++def resweep_trial_status_reasons(apps, schema_editor):+ """0024 relabeled trial-era status reasons, but workers on the previous release could still+ write `trial_limit_reached` / `model_not_allowed` during the rollout after that sweep ran.+ No writer of these values exists anymore, so this second sweep is final."""+ Evaluation = apps.get_model("ai_observability", "Evaluation")+ Evaluation.objects.filter(status_reason__in=["trial_limit_reached", "model_not_allowed"]).update(+ status_reason="provider_key_required", status_reason_detail=None+ )+++class Migration(migrations.Migration):+ dependencies = [+ ("ai_observability", "0026_retire_trial_columns"),+ ]++ operations = [+ # Lossy relabel; reverse is a no-op.+ migrations.RunPython(resweep_trial_status_reasons, migrations.RunPython.noop),+ ]diff --git a/products/ai_observability/backend/migrations/0028_drop_trial_eval_columns.py b/products/ai_observability/backend/migrations/0028_drop_trial_eval_columns.pynew file mode 100644index 000000000000..a27972ab741a--- /dev/null+++ b/products/ai_observability/backend/migrations/0028_drop_trial_eval_columns.py@@ -0,0 +1,24 @@+from django.db import migrations+++class Migration(migrations.Migration):+ dependencies = [+ ("ai_observability", "0027_resweep_trial_status_reasons"),+ ]++ operations = [+ # The columns left Django state in 0026 (SeparateDatabaseAndState) and the previous+ # release is fully rolled off, so the physical drop is safe. IF EXISTS keeps bin/migrate+ # retries idempotent. reverse_sql restores the exact 0026 state (nullable + DB defaults)+ # so the migration graph stays reversible for TestMigrations-based tests.+ migrations.RunSQL(+ sql=[+ "ALTER TABLE llm_analytics_evaluationconfig DROP COLUMN IF EXISTS trial_eval_limit;",+ "ALTER TABLE llm_analytics_evaluationconfig DROP COLUMN IF EXISTS trial_evals_used;",+ ],+ reverse_sql=[+ "ALTER TABLE llm_analytics_evaluationconfig ADD COLUMN IF NOT EXISTS trial_evals_used integer NULL DEFAULT 0;",+ "ALTER TABLE llm_analytics_evaluationconfig ADD COLUMN IF NOT EXISTS trial_eval_limit integer NULL DEFAULT 100;",+ ],+ ),+ ]diff --git a/products/ai_observability/backend/migrations/max_migration.txt b/products/ai_observability/backend/migrations/max_migration.txtindex 5fe7a221056b..244695ffd69d 100644--- a/products/ai_observability/backend/migrations/max_migration.txt+++ b/products/ai_observability/backend/migrations/max_migration.txt@@ -1 +1 @@-0026_retire_trial_columns+0028_drop_trial_eval_columns