PDA

View Full Version : Ruleset Version/Release Number



Sorcerer
May 21st, 2011, 12:13
the getRulesetVersion() function returns the major and minor version numbers contained in the DB root property tag "release".
This value is generated on exiting the campaign from whatever is listed in the corresponding "release" property tag of the base.xml.

If you have an extension running, which also contains a "release" property tag in root, the version number is not overridden, it still takes the value from base.xml.

the question is, is there a way to override the value in base.xml or am I stuck with it?

basically I want to check the ruleset version number in order to run some update or revert scripts, depending on the current DB situation.

Sorcerer
May 21st, 2011, 13:40
I'm still interested in an answer to this, however, having not found a way to use the "official" release numbers myself, I have opted to create a global variable in the extension with the Version number.
I then check the DB to see if it has been saved there, its not there I run the update and then write the version number to the DB.

in terms of reverting. If I find a version number in the DB which is lower than that of the extension, or no extension version number exists then I run the revert

its a bit long winded but it does the job (so far).

Moon Wizard
May 22nd, 2011, 09:04
It sounds like you have found a reasonable way to make that work.

The database version is read from the db.xml file as startup. The database version stays constant for the session. When the database is saved to disk, it gets updated to the latest client version for the next session.

Typically, when I'm writing embedded migration code, I place an onInit handler in the function. It then uses the getRulesetVersion function to determine whether an update has occurred in the ruleset, and perform a set of migration tasks to bring the database up to the current version.

Regards,
JPG

Sorcerer
May 22nd, 2011, 10:20
Thanks JPG.

Just another small comment. Using my approach above, I ran into my old nemesis "FG Floating points"

I created the Global Variable in the extension and after the update saved it to the database.
However on subsequent restarts of FG the updates kept running.

I couldn't understand why the simple logic of

if EXTENTION < DBNODE

should not stop the update from occurring.

It took me a long time until I printed to console the variable and what had been saved to the DB - the results were:

[21.05.2011 17:37:07] Script Notice: 2.11
[21.05.2011 17:37:07] Script Notice: 2.1099998950958

It was good to find the answer, but a little annoying that FG needs to approximate such small numbers.

I have switched to saving the version number as a string and using "tonumber"
when I need to do calculations on the values. That seems to work well.