← back to Dw Image Shrink
video-ledger.sql
28 lines
-- Ledger for the product-video shrink job (mirrors img_shrink_ledger).
-- One row per attached product Video. Upload-first-safe: never leaves a product
-- video-less; at the cap the row parks 'blocked' with the original intact.
CREATE TABLE IF NOT EXISTS vid_shrink_ledger (
id bigserial PRIMARY KEY,
product_id bigint NOT NULL,
handle text,
prod_status text,
shard int NOT NULL DEFAULT 0,
orig_media_id text NOT NULL UNIQUE, -- gid://shopify/Video/...
orig_url text NOT NULL, -- originalSource.url (downloadable)
orig_bytes bigint,
orig_format text,
orig_width int,
orig_height int,
state text NOT NULL DEFAULT 'pending', -- pending|claimed|done|skipped|blocked|failed
worker_id text,
attempts int NOT NULL DEFAULT 0,
new_media_id text,
new_url text,
new_bytes bigint,
skip_reason text,
fail_reason text,
claimed_at timestamptz,
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS vid_shrink_state_idx ON vid_shrink_ledger(state);