Page 1 of 1

When is function upgradeTableDb launched ? Go issue with my Alpha game

Posted: 30 April 2021, 09:41
by bidulpik
Hi,

in my Alpha game, I've modified DB model adding 2 columns.

To save previous games, I've add in my game.php

function upgradeTableDb( $from_version ) {

$sql = "ALTER TABLE matchgame ADD COLUMN IF NOT EXISTS player_forfeit_id INT(10) UNSIGNED DEFAULT 0";
self::DbQuery( $sql );

$sql = "ALTER TABLE matchgame ADD COLUMN IF NOT EXISTS player_forfeit_type INT(10) UNSIGNED DEFAULT 0";
self::DbQuery( $sql );

}

But players who start game before my PHP change still have DB error .

Any idea ?

Re: When is function upgradeTableDb launched ? Go issue with my Alpha game

Posted: 30 April 2021, 11:46
by XCID
Don't forget to add "DBPREFIX_" before the table name. You should also check for the version number. Like this:

Code: Select all

        if ($from_version <= 2008251128) {
            $sql = "ALTER TABLE DBPREFIX_player ADD `selected_card` INT(11) UNSIGNED NOT NULL DEFAULT '0'";
            self::applyDbUpgradeToAllDB($sql);
        }

Re: When is function upgradeTableDb launched ? Go issue with my Alpha game

Posted: 30 April 2021, 16:32
by bidulpik
ty, i'll try it