error upgrading database

Game development with Board Game Arena Studio
Post Reply
User avatar
galehar
Posts: 136
Joined: 29 March 2015, 00:12

error upgrading database

Post by galehar »

So, I've read this thread and followed the instructions on the wiki. When I'm testing my upgradeTableDb function in studio I'm getting this error:

Code: Select all

Error while processing SQL request (leto.boardgamearena.com via TCP/IP): ALTER TABLE zz_savepoint_orbteam ADD team_move INT UNSIGNED NOT NULL DEFAULT 0, ADD `team_crossbarrier` tinyint(4) NOT NULL DEFAULT 0, ADD `team_crosswall` tinyint(4) NOT NULL DEFAULT 0; Table 'ebd_raceforthegalaxy_218368.zz_savepoint_orbteam' doesn't exist
I'm trying to add 3 columns to the orbteam table. When checking the database after the error, I can see that the 3 columns have been added properly. The code is failing on the 2nd line of the applyDbChangeToAllDB function. It fails to update to zz_savepoint_ table. I can't see the savepoint or replay tables in phpMyAdmin, so I'm not sure how to debug this.

Here is the code of this function by the way. Is it still up-to-date?

Code: Select all

function applyDbChangeToAllDB($sql)
    {
        self::DbQuery(str_replace('DBPREFIX_', '', $sql));
        self::DbQuery(str_replace('DBPREFIX_', 'zz_savepoint_', $sql));
        self::DbQuery(str_replace('DBPREFIX_', 'zz_replay1_', $sql));
        self::DbQuery(str_replace('DBPREFIX_', 'zz_replay2_', $sql));
        self::DbQuery(str_replace('DBPREFIX_', 'zz_replay3_', $sql));
    }
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: error upgrading database

Post by Een »

I checked this and indeed, this method is not current.

You should now use the framework method applyDbUpgradeToAllDB( $sql )

(also with DBPREFIX_ before table names)
User avatar
galehar
Posts: 136
Joined: 29 March 2015, 00:12

Re: error upgrading database

Post by galehar »

Yep, that was it, thanks! I didn't notice the change in the function name. Anyway, being able to test the DB upgrade is really really nice. Upgrading is much less stressful :)
User avatar
galehar
Posts: 136
Joined: 29 March 2015, 00:12

Re: error upgrading database

Post by galehar »

The upgrade worked fine on studio but failed on prod, because in the ugprade function I called getGameStateValue with an integer instead of a name. I fixed it, but in the meantime I broke table 131285095 (and possibly others?). It just says

Code: Select all

Error while processing Database request 
.
Can the game be deleted so that players don't lose karma?
Thanks.
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: error upgrading database

Post by Een »

galehar wrote: 19 December 2020, 00:45 The upgrade worked fine on studio but failed on prod, because in the ugprade function I called getGameStateValue with an integer instead of a name.
Strange, not sure why the behaviour was not the same on the studio.
galehar wrote: 19 December 2020, 00:45 I fixed it, but in the meantime I broke table 131285095 (and possibly others?). It just says

Code: Select all

Error while processing Database request 
.

Can the game be deleted so that players don't lose karma?
Thanks.
Actually, you can still save this game (and eventually others affected), by adding a new upgrade db to add the missing columns, inside a try/catch in order that running it on tables already upgraded don't create an error for these tables.
User avatar
galehar
Posts: 136
Joined: 29 March 2015, 00:12

Re: error upgrading database

Post by galehar »

But I'm not sure what the issue is with this game. It doesn't say that columns are missing, only "Error while processing Database request".
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: error upgrading database

Post by Een »

You can see the errors from the manage game page "Display recent errors from production (unexpected errors)" button (needs to enable popups)

Here it fails in the upgradetabledb. So this table had already been upgraded, and your code is trying to upgrade it again. If you add a try/catch around the latest upgrade, it should unlock the situation.
User avatar
galehar
Posts: 136
Joined: 29 March 2015, 00:12

Re: error upgrading database

Post by galehar »

that worked! Thanks for your help :)
Post Reply

Return to “Developers”