As I've released the first version of my Ace Editor for CMSMS 2.x, I have a few updates in mind. But now of course I have to use method.upgrade.php. I've studied some other versions and one function I have a question about is 'version_compare'. I see it accepts two arguments, but what does it return? And is the $oldversion variable automatically available?
Besides this, I suppose I can use any PHP and CMSMS functions I can with method.install and mehod.uninstall?
A few questions on method.upgrade.php
Re: A few questions on method.upgrade.php
Another question: When I move files to different locations in an update package, will the module manager also move these files, or just add the new ones and keep the old (double ones) in place?
Re: A few questions on method.upgrade.php
I think you won't need version_compare.
I do upgrades like this:
Variable $oldversion is available in method.upgrade.php
All existing files will be overwritten when you upgrade, not moved.
The method.upgrade.php is for everything else you need to do, e.g. create an extra column in a database table, or delete a file that is not used anymore.
I do upgrades like this:
Code: Select all
switch ($oldversion)
{
case "1.0":
// do something to upgrade to version 1.0.1
case "1.0.1":
// do something to upgrade to version 1.0.2
case "1.0.2":
// do something to upgrade to version 1.1
case "1.1":
// do something to upgrade to current version
}
YesGuido wrote:I suppose I can use any PHP and CMSMS functions I can with method.install and mehod.uninstall?
A module is just one package, for install, upgrade and uninstallGuido wrote:Another question: When I move files to different locations in an update package, will the module manager also move these files, or just add the new ones and keep the old (double ones) in place?
All existing files will be overwritten when you upgrade, not moved.
The method.upgrade.php is for everything else you need to do, e.g. create an extra column in a database table, or delete a file that is not used anymore.
Re: A few questions on method.upgrade.php
Ah, never knew version_compare was PHP native..
Okay, and new folders in the update package will also be created? I just need to use method.upgrade to remove the files in their old location?All existing files will be overwritten when you upgrade, not moved.
Re: A few questions on method.upgrade.php
that's right, or overwrite them with an empty file, but removing is cleaner.
Also note that there is no break in the switch function.
Also note that there is no break in the switch function.
Re: A few questions on method.upgrade.php
One question that comes to mind: Let's say I'm adding a column to my module table in version 2. User A already has version 1 and is upgrading, so the column will have to be made in the method.upgrade file. But if user B never installed version 1, but installs version 2 right away, you'll have to update your method.install file as well I think in version 2?
Re: A few questions on method.upgrade.php
Yes. The method.upgrade.php will not run when installing, so the new database column has to be in method.install.php too