-- 0015 · SNS 계정 연결 -- -- ★ 번호가 0012·0013 이었는데 main 에 같은 번호가 이미 있어서(0012_place_faqs_template_source, -- 0013_job_progress) 병합하며 뒤로 밀었다. migrate.py 는 파일명 정렬로 돌고 적용 이력도 -- 파일명(stem)으로 남기므로, 이미 옛 이름으로 적용된 DB 는 이 파일을 한 번 더 돌린다 — -- 안에 있는 문장이 전부 IF NOT EXISTS 라 두 번 돌아도 결과가 같다(그래서 밀 수 있었다). CREATE TABLE IF NOT EXISTS public.owner_social_accounts ( account_id uuid PRIMARY KEY DEFAULT gen_random_uuid(), user_id uuid NOT NULL, provider smallint NOT NULL CHECK (provider IN (1,2)), provider_user_id varchar(200) NOT NULL, handle varchar(200) NOT NULL, profile_url text NOT NULL, access_token text, refresh_token text, access_expires_at timestamptz, scopes jsonb NOT NULL DEFAULT '[]', status varchar(20) NOT NULL DEFAULT 'linked', last_error text, created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), deleted boolean NOT NULL DEFAULT false ); CREATE UNIQUE INDEX IF NOT EXISTS uq_social_account ON public.owner_social_accounts(user_id, provider) WHERE deleted=false AND status IN ('linked','needs_reauth');