ALTER TABLE tb_package ADD COLUMN IF NOT EXISTS virtual_ratio DECIMAL(18,6) NOT NULL DEFAULT 1.0;

COMMENT ON COLUMN tb_package.virtual_ratio IS '虚流量比例(real_data_mb/virtual_data_mb)，创建套餐时计算存储，默认1.0';

UPDATE tb_package
SET virtual_ratio = CASE
    WHEN enable_virtual_data = true AND virtual_data_mb > 0
        THEN (real_data_mb::DECIMAL / virtual_data_mb::DECIMAL)
    ELSE 1.0
END
WHERE deleted_at IS NULL;
