'use strict';

exports.up = async function (db) {
    const allDomains = await db.runSql('SELECT * FROM domains');
    for (const domain of allDomains) {
        if (domain.provider !== 'cloudflare') continue;

        const config = JSON.parse(domain.configJson);
        if ('defaultProxyStatus' in config) continue;
        config.defaultProxyStatus = false;

        await db.runSql('UPDATE domains SET configJson=? WHERE domain=?', [ JSON.stringify(config), domain.domain ]);
    }
};

exports.down = async function () {
};
