feat: identity PATCH update, alias system, name UNIQUE removal

- Add PATCH /api/v1/identity/:identity_uuid endpoint
- Migration 030: remove name UNIQUE, add tmdb_id index
- TMDb upsert: ON CONFLICT (name) -> ON CONFLICT (tmdb_id)
- get_or_create_identity: pre-check by name
- upload_identity: ON CONFLICT (name) -> ON CONFLICT (uuid)
- Search: include aliases in identity text search
- Add scripts/llm_metadata_enhancer.py
- Add DESIGN/IdentityUpdateAndAliasSystem.md
This commit is contained in:
M5Max128
2026-05-22 08:35:28 +08:00
parent e1dbd27333
commit 701e71463d
6 changed files with 524 additions and 16 deletions
@@ -0,0 +1,18 @@
-- Migration 030: Remove name UNIQUE constraint from identities table
-- Rationale: uuid is the true identity key; name is a display label that can repeat.
-- TMDb-sourced identities use tmdb_id as their unique key.
BEGIN;
-- Phase 1: Remove name UNIQUE (keep NOT NULL — every identity must have a name)
ALTER TABLE identities DROP CONSTRAINT IF EXISTS identities_name_key;
-- Phase 2: Add updated_at column for tracking modifications
ALTER TABLE identities ADD COLUMN IF NOT EXISTS updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW();
-- Phase 3: Partial unique index for TMDb-sourced identities
-- Only applies to rows with a non-null tmdb_id.
CREATE UNIQUE INDEX IF NOT EXISTS idx_identities_tmdb_id
ON identities(tmdb_id) WHERE tmdb_id IS NOT NULL;
COMMIT;