Files
creator-hub/internal/creator/migrations/032_douyin_release_remediation.sql
T

53 lines
2.5 KiB
SQL

ALTER TABLE creator_event
ADD COLUMN IF NOT EXISTS generation text NOT NULL DEFAULT '';
ALTER TABLE creator_operation
ADD COLUMN IF NOT EXISTS verification_state text NOT NULL DEFAULT 'not_verified'
CHECK (verification_state IN ('not_verified', 'not_sent', 'succeeded', 'failed', 'blocked', 'uncertain')),
ADD COLUMN IF NOT EXISTS verification_evidence jsonb NOT NULL DEFAULT '{}'::jsonb,
ADD COLUMN IF NOT EXISTS verified_at timestamptz;
ALTER TABLE creator_message
ADD COLUMN IF NOT EXISTS operation_id text REFERENCES creator_operation(id) ON DELETE SET NULL;
CREATE INDEX IF NOT EXISTS creator_message_operation_idx ON creator_message (operation_id);
ALTER TABLE creator_conversation
ADD COLUMN IF NOT EXISTS history_cursor text NOT NULL DEFAULT '',
ADD COLUMN IF NOT EXISTS history_has_more boolean NOT NULL DEFAULT false,
ADD COLUMN IF NOT EXISTS history_synced_at timestamptz;
ALTER TABLE creator_material_job
ADD COLUMN IF NOT EXISTS processing_step text NOT NULL DEFAULT '',
ADD COLUMN IF NOT EXISTS processing_token text NOT NULL DEFAULT '',
ADD COLUMN IF NOT EXISTS processing_started_at timestamptz;
CREATE TABLE IF NOT EXISTS creator_event_strategy_trace (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
event_id text NOT NULL REFERENCES creator_event(id) ON DELETE CASCADE,
strategy_id text NOT NULL,
position integer NOT NULL CHECK (position > 0),
outcome text NOT NULL CHECK (outcome IN ('skipped', 'selected')),
reason text NOT NULL DEFAULT '',
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS creator_event_strategy_trace_idx
ON creator_event_strategy_trace (event_id, position, id);
CREATE TABLE IF NOT EXISTS creator_listener_boundary (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
account_id text NOT NULL REFERENCES social_account(id) ON DELETE CASCADE,
platform text NOT NULL CHECK (platform IN ('douyin', 'xiaohongshu')),
generation text NOT NULL,
status text NOT NULL CHECK (status IN ('starting', 'ready', 'gap', 'stopped', 'error')),
boundary_at timestamptz,
last_delivery_id text NOT NULL DEFAULT '',
reason text NOT NULL DEFAULT '',
recorded_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS creator_listener_boundary_account_idx
ON creator_listener_boundary (account_id, recorded_at, id);
ALTER TABLE creator_listener_state
ADD COLUMN IF NOT EXISTS session_token text NOT NULL DEFAULT '',
ADD COLUMN IF NOT EXISTS invalidated boolean NOT NULL DEFAULT false;