feat(llma): add prompt management
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?
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%) |
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)
đ 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:
- Add constraint with NOT VALID (instant, validates new rows only)
- 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)
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