Ejemplo n.º 1
0
if ($db->get_type() == DB::MYSQL && checkIfTableExists($db, "reputation") && getColumnType($db, 'reputation', 'charid') != 'bigint(20)') {
    upgrade($db, "ALTER TABLE reputation CHANGE COLUMN charid charid BIGINT NOT NULL");
}
if ($db->get_type() == DB::MYSQL && checkIfTableExists($db, "reputation") && getColumnType($db, 'reputation', 'by_charid') != 'bigint(20)') {
    upgrade($db, "ALTER TABLE reputation CHANGE COLUMN by_charid by_charid BIGINT NOT NULL");
}
if ($db->get_type() == DB::MYSQL && checkIfTableExists($db, "tracked_users_<myname>") && getColumnType($db, 'tracked_users_<myname>', 'uid') != 'bigint(20)') {
    upgrade($db, "ALTER TABLE tracked_users_<myname> CHANGE COLUMN uid uid BIGINT NOT NULL");
}
if ($db->get_type() == DB::MYSQL && checkIfTableExists($db, "tracking_<myname>") && getColumnType($db, 'tracking_<myname>', 'uid') != 'bigint(20)') {
    upgrade($db, "ALTER TABLE tracking_<myname> CHANGE COLUMN uid uid BIGINT NOT NULL");
}
if ($db->get_type() == DB::MYSQL && checkIfTableExists($db, "name_history") && getColumnType($db, 'name_history', 'charid') != 'bigint(20)') {
    upgrade($db, "ALTER TABLE name_history CHANGE COLUMN charid charid BIGINT NOT NULL");
}
// update guild ids that are blank to be 0
if ($db->get_type() == DB::SQLITE && checkIfTableExists($db, "players")) {
    upgrade($db, "UPDATE players SET guild_id = 0 WHERE guild_id = ''");
}
// update prof_title from varchar(20) to varchar(50)
if ($db->get_type() == DB::MYSQL && checkIfTableExists($db, "players") && getColumnType($db, 'players', 'prof_title') != 'varchar(50)') {
    upgrade($db, "ALTER TABLE players CHANGE COLUMN prof_title prof_title VARCHAR(50) NOT NULL DEFAULT ''");
}
// update cmd_alias.cmd from varchar(25) to varchar(255)
if ($db->get_type() == DB::MYSQL && checkIfTableExists($db, "cmd_alias_<myname>") && getColumnType($db, 'cmd_alias_<myname>', 'cmd') != 'varchar(255)') {
    upgrade($db, "ALTER TABLE cmd_alias_<myname> CHANGE COLUMN cmd cmd VARCHAR(255) NOT NULL");
}
// add timers.alerts column
if (!checkIfColumnExists($db, "timers_<myname>", 'alerts')) {
    upgrade($db, "ALTER TABLE timers_<myname> ADD COLUMN alerts TEXT");
}
Ejemplo n.º 2
0
    return str_replace("_RC", ".0.", str_replace("_GA", ".1", $version));
}
function minRequiredVersion($db, $minVersion)
{
    if (checkIfTableExists($db, "settings_<myname>")) {
        $row = $db->queryRow("SELECT * FROM settings_<myname> WHERE name = ?", 'version');
        if ($row !== null) {
            global $version;
            if (version_compare(normalizeVersion($version), normalizeVersion($minVersion), '<')) {
                throw new Exception("Current required version is too old; you must upgrade to version {$minVersion} first before upgrading to {$version}");
            }
        }
    }
}
minRequiredVersion($db, "3.3_GA");
// set default items db to central
if (checkIfTableExists($db, "settings_<myname>")) {
    $row = $db->queryRow("SELECT * FROM settings_<myname> WHERE name = ?", 'cidb_url');
    if ($row === null) {
        $db->exec("UPDATE settings_<myname> SET value = ? WHERE name = ?", 'central', 'items_database');
    }
}
if (checkIfTableExists($db, "cmd_alias_<myname>")) {
    $db->exec("DELETE FROM cmd_alias_<myname> WHERE cmd = ?", 'guides buffs');
}
if (checkIfTableExists($db, "timers_<myname>") && checkIfColumnExists($db, 'timers_<myname>', 'callback_param')) {
    $db->exec("ALTER TABLE timers_<myname> RENAME TO timers_backup_<myname>");
    $db->exec("CREATE TABLE IF NOT EXISTS `timers_<myname>` (`name` VARCHAR(255), `owner` VARCHAR(25), `mode` VARCHAR(50), `timer` int, `settime` int, `callback` VARCHAR(255), `data` VARCHAR(255), `alerts` TEXT)");
    $db->exec("INSERT INTO timers_<myname> SELECT * FROM timers_backup_<myname>");
    $db->exec("DROP TABLE timers_backup_<myname>");
}