-- 为 tb_iot_card 添加套餐系列绑定相关字段
ALTER TABLE tb_iot_card
    ADD COLUMN series_allocation_id INTEGER DEFAULT NULL,
    ADD COLUMN first_commission_paid BOOLEAN NOT NULL DEFAULT FALSE,
    ADD COLUMN accumulated_recharge BIGINT NOT NULL DEFAULT 0;

-- 为 tb_iot_card 的 series_allocation_id 字段添加索引
CREATE INDEX idx_iot_card_series_allocation ON tb_iot_card(series_allocation_id);

-- 为 tb_iot_card 添加注释
COMMENT ON COLUMN tb_iot_card.series_allocation_id IS '套餐系列分配ID(关联ShopSeriesAllocation)';
COMMENT ON COLUMN tb_iot_card.first_commission_paid IS '一次性佣金是否已发放';
COMMENT ON COLUMN tb_iot_card.accumulated_recharge IS '累计充值金额(分)';

-- 为 tb_device 添加套餐系列绑定相关字段
ALTER TABLE tb_device
    ADD COLUMN series_allocation_id INTEGER DEFAULT NULL,
    ADD COLUMN first_commission_paid BOOLEAN NOT NULL DEFAULT FALSE,
    ADD COLUMN accumulated_recharge BIGINT NOT NULL DEFAULT 0;

-- 为 tb_device 的 series_allocation_id 字段添加索引
CREATE INDEX idx_device_series_allocation ON tb_device(series_allocation_id);

-- 为 tb_device 添加注释
COMMENT ON COLUMN tb_device.series_allocation_id IS '套餐系列分配ID(关联ShopSeriesAllocation)';
COMMENT ON COLUMN tb_device.first_commission_paid IS '一次性佣金是否已发放';
COMMENT ON COLUMN tb_device.accumulated_recharge IS '累计充值金额(分)';
