feat: 完善 Rock 发货异常闭环与绑定判定
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
-- 029: Rock 发货异常事件表。
|
||||
-- 原始请求/响应继续保留在 rock_delivery_logs;本表用于分类、筛选和人工处理。
|
||||
|
||||
CREATE TABLE IF NOT EXISTS rock_delivery_incidents (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
token_id BIGINT NOT NULL,
|
||||
order_no VARCHAR(128) NOT NULL DEFAULT '',
|
||||
upstream_token_id VARCHAR(64) NOT NULL DEFAULT '',
|
||||
category VARCHAR(40) NOT NULL,
|
||||
status VARCHAR(16) NOT NULL DEFAULT 'open',
|
||||
blocking_retry BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
message TEXT NOT NULL DEFAULT '',
|
||||
upstream_http_status INTEGER NOT NULL DEFAULT 0,
|
||||
upstream_response TEXT NOT NULL DEFAULT '',
|
||||
occurrences INTEGER NOT NULL DEFAULT 1,
|
||||
first_seen_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
last_seen_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
resolved_at TIMESTAMPTZ,
|
||||
resolved_by BIGINT,
|
||||
resolution_action VARCHAR(32) NOT NULL DEFAULT '',
|
||||
resolution_note TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_rock_delivery_incidents_filter
|
||||
ON rock_delivery_incidents (status, category, last_seen_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_rock_delivery_incidents_token
|
||||
ON rock_delivery_incidents (token_id, created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_rock_delivery_incidents_order
|
||||
ON rock_delivery_incidents (order_no, created_at DESC);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_rock_delivery_incidents_open_unique
|
||||
ON rock_delivery_incidents (token_id, order_no, category)
|
||||
WHERE status = 'open';
|
||||
Reference in New Issue
Block a user