Merge branch 'feature/social-post'
This commit is contained in:
commit
46171b4f24
55 files changed
+2872
-7
No files matched your search
@@ -544,3 +544,53 @@ INSERT INTO public.schema_migrations (version) VALUES
|
||||
('0008_personalization_to_site_sections'),
|
||||
('0009_align_with_init_sql')
|
||||
ON CONFLICT (version) DO NOTHING;
|
||||
|
||||
-- SNS: credentials and approval records never enter public payloads.
|
||||
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');
|
||||
|
||||
-- SNS: credentials and approval records never enter public payloads.
|
||||
CREATE TABLE IF NOT EXISTS public.place_social_posts (
|
||||
post_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
place_id uuid NOT NULL,
|
||||
user_id uuid NOT NULL,
|
||||
site_version_id uuid NOT NULL,
|
||||
account_id uuid,
|
||||
provider smallint NOT NULL CHECK (provider IN (1,2)),
|
||||
body text NOT NULL DEFAULT '',
|
||||
link_url text NOT NULL,
|
||||
grounded_facts jsonb NOT NULL DEFAULT '[]',
|
||||
status varchar(24) NOT NULL DEFAULT 'DRAFTING',
|
||||
approval_token_sha varchar(64),
|
||||
approval_sent_at timestamptz,
|
||||
approval_channel varchar(20),
|
||||
approval_expires_at timestamptz,
|
||||
decided_at timestamptz,
|
||||
decided_via varchar(20),
|
||||
provider_post_id varchar(200),
|
||||
permalink text,
|
||||
posted_at timestamptz,
|
||||
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_version ON public.place_social_posts(place_id, site_version_id) WHERE deleted=false;
|
||||
CREATE INDEX IF NOT EXISTS idx_social_posted ON public.place_social_posts(place_id, posted_at DESC) WHERE deleted=false AND status='POSTED';
|
||||
Reference in new issue
Block a user