把卡密自动发货从 engine.DeliveryService 收敛到统一的 automation.Center: WS 事件/计划任务/手动触发统一为 Task,trigger_key 持久化防重,付款发货、 评价赠品、超时求评价共用一套规则+动作编排。新增 internal/automation 包、 db.AutomationRules repository、00007 迁移。 同步删除被取代的并行死系统: - engine.DeliveryService + delivery_test.go(已无引用) - db.DeliveryRules/DeliveryRule + 3 个 Match 方法(生产零调用) - card_handlers 的 /delivery-rules CRUD(前端早已只走 automation-rules) - engine.SystemMessage + extractSystemMessage(dispatch 不再单独路由 message["3"]) - store.DeliveryRules 字段、Cards.IncrementDeliveryTimes - 00008 迁移 DROP delivery_rules/delivery_rule_variants + email_verifications/ captcha_codes/ai_item_cache/risk_control_logs + publish 批次 3 个死列 - isAPIPath 清理 ~15 个未挂载的前缀,stub_handlers.go 内联删除 - vite.config 删 /delivery-rules proxy 其它:orders.Upsert 注释改为诚实描述(version 列不参与并发控制); dispatch.cleanupDedupLocked 用 sort.Slice 取代 O(n²) 选择排序; 删自定义 min 用内置;deliveryRuleItemOwned 改名 itemOwnedByUser。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
52 lines
2.2 KiB
SQL
52 lines
2.2 KiB
SQL
-- +goose Up
|
||
-- +goose StatementBegin
|
||
-- 清理被 automation_rules 取代或从未使用的 schema:
|
||
-- - delivery_rules + delivery_rule_variants:发货规则旧系统,已被 automation_rules 完全取代(前端只走 automation-rules)。
|
||
-- - email_verifications / captcha_codes / ai_item_cache / risk_control_logs:从未有 Go 代码读写。
|
||
-- - item_publish_batch_rows.auto_create_delivery_rule / card_group_id / delivery_count:批量铺货改走 automation_json,三列从未读写。
|
||
|
||
DROP TABLE IF EXISTS delivery_rule_variants;
|
||
DROP TABLE IF EXISTS delivery_rules;
|
||
DROP TABLE IF EXISTS email_verifications;
|
||
DROP TABLE IF EXISTS captcha_codes;
|
||
DROP TABLE IF EXISTS ai_item_cache;
|
||
DROP TABLE IF EXISTS risk_control_logs;
|
||
|
||
ALTER TABLE item_publish_batch_rows DROP COLUMN auto_create_delivery_rule;
|
||
ALTER TABLE item_publish_batch_rows DROP COLUMN card_group_id;
|
||
ALTER TABLE item_publish_batch_rows DROP COLUMN delivery_count;
|
||
-- +goose StatementEnd
|
||
|
||
-- +goose Down
|
||
-- +goose StatementBegin
|
||
-- 仅重建结构,历史数据不可恢复。
|
||
CREATE TABLE IF NOT EXISTS delivery_rules (
|
||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||
keyword TEXT NOT NULL,
|
||
card_id INTEGER NOT NULL,
|
||
delivery_count INTEGER DEFAULT 1,
|
||
enabled BOOLEAN DEFAULT TRUE,
|
||
description TEXT,
|
||
delivery_times INTEGER DEFAULT 0,
|
||
user_id INTEGER NOT NULL DEFAULT 1,
|
||
cookie_id TEXT NOT NULL DEFAULT '',
|
||
item_id TEXT NOT NULL DEFAULT '',
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||
);
|
||
CREATE TABLE IF NOT EXISTS delivery_rule_variants (
|
||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||
rule_id INTEGER NOT NULL,
|
||
spec_name TEXT NOT NULL DEFAULT '',
|
||
spec_value TEXT NOT NULL DEFAULT '',
|
||
card_id INTEGER NOT NULL,
|
||
delivery_count INTEGER NOT NULL DEFAULT 1,
|
||
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||
);
|
||
ALTER TABLE item_publish_batch_rows ADD COLUMN auto_create_delivery_rule INTEGER NOT NULL DEFAULT 0;
|
||
ALTER TABLE item_publish_batch_rows ADD COLUMN card_group_id INTEGER NOT NULL DEFAULT 0;
|
||
ALTER TABLE item_publish_batch_rows ADD COLUMN delivery_count INTEGER NOT NULL DEFAULT 1;
|
||
-- +goose StatementEnd
|