From The Mana World
Revision as of 08:15, 15 November 2010 by Hoogli (talk | contribs)


From time to time, the database model used by tmwserv will be extended or modified. To prevent inconsistencies between the database model and the account server, the database model has its own version number which has to match the known version of the account server. That means, if you upgrade you database model, you also have to update tmwserv and vice versa. If the version of your database is incompatible with you version of the account server, the account server will print out a message like this on startup:

  [FTL] Error opening the database: Database version is not supported. Needed version: '1', current version: '2'

In this case, the version of your database is newer, than the version of the account server. You have to get the latest sources of the account server.

Determine the database version

To find out which version your current database is of, try the following SELECT statement, which should work well independent of your database backend.

  SELECT value FROM tmw_world_states WHERE state_name = 'database_version';

This should give you a numeric value which represents your current database version. When using SQLite try the following statement:

  sqlite3 tmw.db "SELECT value FROM tmw_world_states WHERE state_name = 'database_version'";

How to upgrade my database

According to your chosen database backend, you will find a subdirectory called "updates" under "tmwserv/src/sql/<db_backend>". The update scripts follow a naming scheme like "update_<old_version>_to_<new_version>.sql". So if your current version is "1" and you want to upgrade to "2", find the script called "update_1_to_2.sql".

Steps to execute the script depends on your backend. For SQLite just move to the folder where your current database file "tmw.db" lies and type:

 sqlite3 tmw.db < src/sql/sqlite/updates/update_1_to_2.sql

Attention: The scripts don't matter what version you are running, so check it before running a script!