feat(kol): enhance KOL constraints per review findings

- Add composite FK kol_usage_logs(prompt_id, prompt_revision_no) -> kol_prompt_revisions
  to enforce audit replay integrity
- Add CHECK constraint: active prompts must have a published revision
- Add tenant-leading index on kol_packages for list path performance

Addresses review feedback on commit 60fb8a4.
This commit is contained in:
2026-04-17 08:04:56 +08:00
parent 60fb8a4d7f
commit fd74ad703b
2 changed files with 25 additions and 0 deletions
@@ -0,0 +1,7 @@
DROP INDEX IF EXISTS idx_kol_package_tenant;
ALTER TABLE kol_prompts
DROP CONSTRAINT IF EXISTS chk_kol_prompts_active_has_published_revision;
ALTER TABLE kol_usage_logs
DROP CONSTRAINT IF EXISTS fk_kol_usage_logs_prompt_revision;