Spaces:
Sleeping
Sleeping
Download backend/sql/019_device_user_links.sql from stylevoice/talk: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/spaces/stylevoice/talk/resolve/main/backend/sql/019_device_user_links.sql
- Command line
-
hf download hf://spaces/stylevoice/talk/backend/sql/019_device_user_links.sql
-
curl -L -o 019_device_user_links.sql https://huggingface.co/spaces/stylevoice/talk/resolve/main/backend/sql/019_device_user_links.sql
1.55 kB
| -- λ¨λ§ β μ¬μ©μ λ§€ν (μ΄λ·°μ¦ μμ¬ κ²μΆ, 2026-05-06). | |
| -- | |
| -- λ°°κ²½: device_daily_usage μ last_user_id λ λ§μ§λ§ 1κ° κ³μ λ§ μ μ₯νμ¬ | |
| -- λμΌ λ¨λ§μ λ€μ€ κ³μ μ¬μ© μΆμ μ΄ μ λ¨. λ³λ λ§€ν ν μ΄λΈλ‘ (λ¨λ§, | |
| -- μ¬μ©μ) unique μ‘°ν©μ λμ β admin νλ©΄μμ "μ΄ λ¨λ§μ΄ Nκ° κ³μ μΌλ‘ | |
| -- μ μ" ν΅κ³ κ°λ₯. | |
| -- | |
| -- μ μ± : | |
| -- - PK = (client_ip, device_fp, user_id) 3 μ»¬λΌ unique | |
| -- - upsert μ last_seen_at κ°±μ , total_credits_used λμ | |
| -- - admin λͺ¨λν°λ§μ© β μΌλ° μ¬μ©μ μν₯ μμ | |
| CREATE TABLE IF NOT EXISTS public.device_user_links ( | |
| client_ip TEXT NOT NULL, | |
| device_fp TEXT NOT NULL, | |
| user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE, | |
| first_seen_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | |
| last_seen_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | |
| total_credits_used INTEGER NOT NULL DEFAULT 0, | |
| PRIMARY KEY (client_ip, device_fp, user_id) | |
| ); | |
| -- λ¨λ§λ³ μ¬μ©μ μ μ§κ³μ© | |
| CREATE INDEX IF NOT EXISTS idx_device_user_links_device | |
| ON public.device_user_links (client_ip, device_fp); | |
| -- μ¬μ©μλ³ λ¨λ§ μ μ§κ³μ© (μλ°©ν₯) | |
| CREATE INDEX IF NOT EXISTS idx_device_user_links_user | |
| ON public.device_user_links (user_id); | |
| -- μ΅κ·Ό νλ μ λ ¬μ© | |
| CREATE INDEX IF NOT EXISTS idx_device_user_links_seen | |
| ON public.device_user_links (last_seen_at DESC); | |
| ALTER TABLE public.device_user_links ENABLE ROW LEVEL SECURITY; | |
| -- μ μ± λ―Έμ€μ = μλΉμ€ λ‘€λ§ ν΅κ³Ό. μ¬μ©μ μ§μ SELECT λΆκ°. | |