Fuehre technische Shopify-Runpersistenz ein

This commit is contained in:
2026-08-12 16:14:02 +02:00
parent c76a33c518
commit f2c9150cb3
4 changed files with 61 additions and 2 deletions
@@ -0,0 +1,41 @@
BEGIN;
CREATE TABLE process_runs (
id BIGSERIAL PRIMARY KEY,
process_name TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'running',
scope_json JSONB NOT NULL DEFAULT '{}'::jsonb,
result_json JSONB,
requested_by TEXT,
started_at TIMESTAMP NOT NULL DEFAULT NOW(),
finished_at TIMESTAMP,
error_code TEXT,
error_message TEXT,
CONSTRAINT chk_process_runs_status CHECK (status IN ('running', 'done', 'partial_success', 'failed'))
);
CREATE INDEX idx_process_runs_name_started ON process_runs(process_name, started_at DESC);
CREATE INDEX idx_process_runs_status_started ON process_runs(status, started_at DESC);
CREATE TABLE shopify_webhook_event (
id BIGSERIAL PRIMARY KEY,
webhook_id TEXT NOT NULL,
topic TEXT NOT NULL,
shop_domain TEXT NOT NULL,
payload_sha256 TEXT NOT NULL,
payload JSONB NOT NULL,
shopify_order_gid TEXT,
status TEXT NOT NULL DEFAULT 'received',
received_at TIMESTAMP NOT NULL DEFAULT NOW(),
processed_at TIMESTAMP,
error_code TEXT,
error_message TEXT,
CONSTRAINT chk_shopify_webhook_event_status CHECK (status IN ('received', 'processed', 'duplicate', 'failed'))
);
CREATE UNIQUE INDEX uq_shopify_webhook_event_webhook_id ON shopify_webhook_event(webhook_id);
CREATE INDEX idx_shopify_webhook_event_order_gid ON shopify_webhook_event(shopify_order_gid);
CREATE INDEX idx_shopify_webhook_event_received_at ON shopify_webhook_event(received_at DESC);
CREATE INDEX idx_shopify_webhook_event_status ON shopify_webhook_event(status, received_at DESC);
COMMIT;