Wiki source for AutomateDatabaseUpgrades

Show raw source

=====Automating Database Upgrades=====

This logic has been implemented in V 4.00

Nicholas Less suggested why don't we make it so when a user logs in - the system compares a database config variable with the config.php $Version and where the two are not equal apply the necessary database upgrade scripts in sequence. Nicholas has put up a bounty for this work so his wish - which seems quite benifical to the betterment of webERP is my command!

I will add a new config record for DatabaseVersion and make changes to to do the comparison after the config table is read into session variables.

The upgrade scripts naming convention is to call each sql file


where X.XX is the version to upgrade from and Y.YY is the version upgrading to.

I will make an array of the upgrade script files and in a while loop compare the version number of the database with these file names looking for the version number immediately after the text ""pgrade"" parsing the upgrade file name will also reveal the version to upgrade to and I will update the config DatabaseVersion with this value. The upgrade file will be read in and the sql statements run one at a time in the same way as we currently do in the Z_MakeNewCompany.php script running weberp-new.sql

In this way database upgrades will be completely seemless having just a small pause on login when the scripts have been upgraded to a later version.

This logic chokes when the DatabaseVersion variable shows a higher version number than the database scripts - perhaps this should be trapped and a message returned.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki