posthog icon indicating copy to clipboard operation
posthog copied to clipboard

feat(llma): add prompt management

Open Radu-Raicea opened this issue 1 month ago â€ĸ 3 comments

Problem

Changes

How did you test this code?

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Changelog: (features only) Is this feature complete?

Radu-Raicea avatar Dec 09 '25 21:12 Radu-Raicea

Size Change: +880 B (+0.02%)

Total Size: 3.7 MB

â„šī¸ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 3.7 MB +880 B (+0.02%)

compressed-size-action

github-actions[bot] avatar Dec 09 '25 21:12 github-actions[bot]

Migration SQL Changes

Hey 👋, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:

posthog/migrations/0942_llm_prompt.py

BEGIN;
--
-- Create model LLMPrompt
--
CREATE TABLE "posthog_llmprompt" ("id" uuid NOT NULL PRIMARY KEY, "name" varchar(255) NOT NULL, "prompt" jsonb NOT NULL, "version" integer NOT NULL CHECK ("version" >= 0), "created_at" timestamp with time zone NOT NULL, "updated_at" timestamp with time zone NOT NULL, "deleted" boolean NOT NULL, "created_by_id" integer NULL, "team_id" integer NOT NULL);
ALTER TABLE "posthog_llmprompt" ADD CONSTRAINT "posthog_llmprompt_created_by_id_7b84f0d6_fk_posthog_user_id" FOREIGN KEY ("created_by_id") REFERENCES "posthog_user" ("id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "posthog_llmprompt" ADD CONSTRAINT "posthog_llmprompt_team_id_b16197ec_fk_posthog_team_id" FOREIGN KEY ("team_id") REFERENCES "posthog_team" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "posthog_llmprompt_created_by_id_7b84f0d6" ON "posthog_llmprompt" ("created_by_id");
CREATE INDEX "posthog_llmprompt_team_id_b16197ec" ON "posthog_llmprompt" ("team_id");
COMMIT;

posthog/migrations/0943_llm_prompt_unique_name.py

BEGIN;
--
-- Create constraint unique_llm_prompt_name_per_team on model llmprompt
--
CREATE UNIQUE INDEX "unique_llm_prompt_name_per_team" ON "posthog_llmprompt" ("team_id", "name") WHERE NOT "deleted";
COMMIT;

Last updated: 2025-12-15 19:25 UTC (b83bbc0)

github-actions[bot] avatar Dec 09 '25 21:12 github-actions[bot]

🔍 Migration Risk Analysis

We've analyzed your migrations for potential risks.

Summary: 1 Safe | 1 Needs Review | 0 Blocked

âš ī¸ Needs Review

May have performance impact

posthog.0943_llm_prompt_unique_name
  └─ #1 âš ī¸ AddConstraint
     Adding constraint may lock table (use NOT VALID pattern)
     model: llmprompt

✅ Safe

Brief or no lock, backwards compatible

posthog.0942_llm_prompt
  └─ #1 ✅ CreateModel
     Creating new table is safe
     model: LLMPrompt
  │
  └──> â„šī¸  INFO:
       â„šī¸  Skipped operations on newly created tables (empty tables
       don't cause lock contention).

📚 How to Deploy These Changes Safely

AddConstraint:

Add constraints in 2 phases without locking:

  1. Add constraint with NOT VALID (instant, validates new rows only)
  2. Validate constraint in separate migration (scans table with non-blocking lock)

See the migration safety guide

Last updated: 2025-12-15 19:26 UTC (b83bbc0)

github-actions[bot] avatar Dec 09 '25 21:12 github-actions[bot]

Query snapshots: Backend query snapshots updated

Changes: 1 snapshots (1 modified, 0 added, 0 deleted)

What this means:

  • Query snapshots have been automatically updated to match current output
  • These changes reflect modifications to database queries or schema

Next steps:

  • Review the query changes to ensure they're intentional
  • If unexpected, investigate what caused the query to change

Review snapshot changes →

posthog-bot avatar Dec 12 '25 21:12 posthog-bot