Spaces:
Sleeping
Sleeping
File size: 2,238 Bytes
aa9892b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | -- Phase 2 (laugh register): μ¬μ©μλ³ λ³νλ μμ wav μΊμ.
--
-- μ¬μ©μκ° μμ± μ€μ μμ apply_dual νΈμΆ μ λ°±κ·ΈλΌμ΄λ μμ
μ΄ λͺ¨λ active
-- admin μμ ν
νλ¦Ώμ μ¬μ©μ ref μμμΌλ‘ λ³ν β κ²°κ³Ό wav λ₯Ό storage μ μ μ₯.
-- μ±ν
chunker (Phase 3) κ° μμ ν ν° κ°μ§ μ μ΄ μΊμμμ wav url μ‘°ν.
--
-- ν€: (user_id, voice_storage_path, template_id) β ν μ¬μ©μμ κ°μ μμ± ref
-- + κ°μ ν
νλ¦Ώ μ‘°ν©λΉ 1ν. κ°μ μμ±μ΄λ©΄ voice_storage_path λμΌνλ―λ‘ dual
-- register (casual/formal) μμͺ½μ΄ 곡μ .
CREATE TABLE IF NOT EXISTS public.user_laugh_cache (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
voice_storage_path TEXT NOT NULL, -- μ¬μ©μ ref wav μ storage_path
template_id UUID NOT NULL REFERENCES public.admin_laugh_templates(id) ON DELETE CASCADE,
laugh_storage_path TEXT NOT NULL, -- λ³νλ wav μ storage_path (voice-clones λ²ν·)
ready BOOLEAN NOT NULL DEFAULT FALSE, -- λ³ν μ±κ³΅ = TRUE
error TEXT, -- λ³ν μ€ν¨ μ λ©μμ§ (~500 chars truncate)
duration_sec REAL, -- λ³νλ wav μ μ¬μ μκ°
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE (user_id, voice_storage_path, template_id)
);
CREATE INDEX IF NOT EXISTS user_laugh_cache_user_voice_idx
ON public.user_laugh_cache (user_id, voice_storage_path)
WHERE ready = TRUE;
ALTER TABLE public.user_laugh_cache ENABLE ROW LEVEL SECURITY;
-- μ μ±
μμ: service_role λ§ μ κ·Ό. νλ‘ νΈλ λ°±μλ API ν΅ν΄μ μ‘°ν.
COMMENT ON TABLE public.user_laugh_cache IS
'Phase 2 (laugh register): μ¬μ©μ ref Γ admin ν
νλ¦Ώ λ³ν μΊμ. apply_dual μ§ν λ°±κ·ΈλΌμ΄λ VC μμ
μ΄ μ±μ.';
COMMENT ON COLUMN public.user_laugh_cache.voice_storage_path IS
'μ¬μ©μ ref wav μ storage_path (μ: {user_id}/{stem}.wav). dual register μ casual/formal μμͺ½μ΄ κ°μ path 곡μ .';
COMMENT ON COLUMN public.user_laugh_cache.laugh_storage_path IS
'λ³νλ wav (μ: {user_id}/laughs/{stem}_{template_id}.wav).';
|