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

Game development with Board Game Arena Studio
Post Reply
User avatar
bidulpik
Posts: 79
Joined: 17 November 2011, 09:02

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

Post 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 ?
User avatar
XCID
Posts: 78
Joined: 26 March 2020, 01:45

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

Post 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);
        }
User avatar
bidulpik
Posts: 79
Joined: 17 November 2011, 09:02

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

Post by bidulpik »

ty, i'll try it
Post Reply

Return to “Developers”