bindbox-game/migrations/20260129_add_douyin_orders_fields.sql

17 lines
774 B
SQL
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 确保 douyin_orders 表包含所需字段解决产品ID窜台问题
-- 1. 添加产品ID字段如果不存在
ALTER TABLE douyin_orders
ADD COLUMN IF NOT EXISTS douyin_product_id VARCHAR(64) DEFAULT '' COMMENT '关联商品ID' AFTER shop_order_id;
-- 2. 添加商品数量字段(如果不存在)
ALTER TABLE douyin_orders
ADD COLUMN IF NOT EXISTS product_count INT NOT NULL DEFAULT 1 COMMENT '商品数量' AFTER order_status;
-- 3. 添加已发放次数字段(如果不存在)
ALTER TABLE douyin_orders
ADD COLUMN IF NOT EXISTS reward_granted INT NOT NULL DEFAULT 0 COMMENT '已发放次数' AFTER product_count;
-- 4. 添加索引(提升查询性能)
CREATE INDEX IF NOT EXISTS idx_douyin_product_id ON douyin_orders(douyin_product_id);