删除库存和旧回调管理
This commit is contained in:
@@ -135,42 +135,6 @@ CREATE TABLE IF NOT EXISTS order_items (
|
||||
CREATE INDEX IF NOT EXISTS idx_order_items_order_id ON order_items(order_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_order_items_sku_code ON order_items(sku_code);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS inventory_items (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
batch_no TEXT NOT NULL DEFAULT '',
|
||||
sku_code TEXT NOT NULL,
|
||||
credential_type TEXT NOT NULL,
|
||||
display_value TEXT NOT NULL DEFAULT '',
|
||||
payload_json JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
source_type TEXT NOT NULL DEFAULT 'static_import',
|
||||
status TEXT NOT NULL DEFAULT 'available',
|
||||
invalid_reason TEXT NOT NULL DEFAULT '',
|
||||
inventory_group_code TEXT NOT NULL DEFAULT '',
|
||||
metadata_json JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
consumed_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ NOT NULL,
|
||||
updated_at TIMESTAMPTZ NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_inventory_items_unique_payload
|
||||
ON inventory_items(sku_code, credential_type, md5(payload_json::text));
|
||||
CREATE INDEX IF NOT EXISTS idx_inventory_items_pool
|
||||
ON inventory_items(sku_code, credential_type, status, id);
|
||||
CREATE INDEX IF NOT EXISTS idx_inventory_items_group_lookup
|
||||
ON inventory_items(sku_code, credential_type, inventory_group_code, status, id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS admin_user_inventory_group_bindings (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
admin_user_id BIGINT NOT NULL REFERENCES admin_users(id) ON DELETE CASCADE,
|
||||
inventory_group_code TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL,
|
||||
updated_at TIMESTAMPTZ NOT NULL,
|
||||
UNIQUE(admin_user_id, inventory_group_code)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_admin_user_inventory_group_bindings_user_id
|
||||
ON admin_user_inventory_group_bindings(admin_user_id, inventory_group_code);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS fulfillment_tasks (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
order_id BIGINT NOT NULL REFERENCES orders(id) ON DELETE CASCADE,
|
||||
@@ -185,7 +149,6 @@ CREATE TABLE IF NOT EXISTS fulfillment_tasks (
|
||||
profile_id BIGINT NOT NULL REFERENCES fulfillment_profiles(id) ON DELETE RESTRICT,
|
||||
executor_key TEXT NOT NULL,
|
||||
task_status TEXT NOT NULL DEFAULT 'pending_payment',
|
||||
inventory_status TEXT NOT NULL DEFAULT 'pending',
|
||||
delivery_status TEXT NOT NULL DEFAULT 'pending',
|
||||
result_code TEXT NOT NULL DEFAULT '',
|
||||
result_message TEXT NOT NULL DEFAULT '',
|
||||
@@ -224,24 +187,6 @@ CREATE TABLE IF NOT EXISTS claim_tokens (
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_claim_tokens_status ON claim_tokens(status, expired_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS task_inventory_bindings (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
task_id BIGINT NOT NULL REFERENCES fulfillment_tasks(id) ON DELETE CASCADE,
|
||||
inventory_item_id BIGINT NOT NULL REFERENCES inventory_items(id) ON DELETE RESTRICT,
|
||||
role_key TEXT NOT NULL,
|
||||
quantity INTEGER NOT NULL DEFAULT 1,
|
||||
binding_status TEXT NOT NULL DEFAULT 'reserved',
|
||||
consumed_at TIMESTAMPTZ,
|
||||
released_at TIMESTAMPTZ,
|
||||
metadata_json JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
created_at TIMESTAMPTZ NOT NULL,
|
||||
updated_at TIMESTAMPTZ NOT NULL,
|
||||
UNIQUE(task_id, role_key, inventory_item_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_task_inventory_bindings_task ON task_inventory_bindings(task_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_task_inventory_bindings_inventory ON task_inventory_bindings(inventory_item_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS task_events (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
task_id BIGINT NOT NULL REFERENCES fulfillment_tasks(id) ON DELETE CASCADE,
|
||||
@@ -268,24 +213,3 @@ CREATE TABLE IF NOT EXISTS task_runtime_contexts (
|
||||
created_at TIMESTAMPTZ NOT NULL,
|
||||
updated_at TIMESTAMPTZ NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS webhook_events (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
provider TEXT NOT NULL DEFAULT '',
|
||||
platform TEXT NOT NULL DEFAULT '',
|
||||
shop_id TEXT NOT NULL DEFAULT '',
|
||||
shop_name TEXT NOT NULL DEFAULT '',
|
||||
event_type TEXT NOT NULL,
|
||||
event_key TEXT NOT NULL,
|
||||
signature_valid BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
headers_json JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
query_json JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
body_json JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
processed BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
process_error TEXT NOT NULL DEFAULT '',
|
||||
related_order_id BIGINT REFERENCES orders(id) ON DELETE SET NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_webhook_events_lookup ON webhook_events(provider, platform, shop_id, event_key);
|
||||
CREATE INDEX IF NOT EXISTS idx_webhook_events_processed ON webhook_events(processed, created_at DESC);
|
||||
|
||||
Reference in New Issue
Block a user