-- 新增 modules 字段，记录各模块独立版本
ALTER TABLE ias_upgrade_logs
    ADD COLUMN modules JSONB NOT NULL DEFAULT '{}'::jsonb;

-- 更新已有记录的模块版本信息
UPDATE ias_upgrade_logs SET modules = '{
    "ias-common": "0.1.0",
    "ias-ai": "0.1.0",
    "ias-wechat": "0.1.0",
    "ias-context": "0.1.0",
    "ias-http": "0.1.0",
    "ias-mail": "0.1.0",
    "ias-service": "0.1.0",
    "ias-main": "0.1.0"
}'::jsonb WHERE version IN ('0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6');

-- 更新 0.1.7 的记录
UPDATE ias_upgrade_logs SET modules = '{
    "ias-common": "0.1.0",
    "ias-ai": "0.1.0",
    "ias-wechat": "0.1.0",
    "ias-context": "0.1.0",
    "ias-http": "0.1.0",
    "ias-mail": "0.1.0",
    "ias-service": "0.1.0",
    "ias-main": "0.1.7"
}'::jsonb WHERE version = '0.1.7';
