Include Jobs/Single Pages in Package Upgrade

Permalink 2 users found helpful
I have recently added some new single pages and jobs to a package that I have built. These pages install fine on a fresh install of the package, but I am not sure how to get them to be included in an upgrade. I suppose I could add the appropriate code to the upgrade function, but what about when someone is upgrading from this new version to an even newer version in the future...I'm not going to want to include installation of those single pages/jobs in that upgrade. What is the appropriate way to do this? Is there some documentation on it somewhere that I have missed or an example I could check out somewhere?

jgarcia
 
Tony replied on at Permalink Best Answer Reply
Tony
I tend to have both the install and upgrade methods both call a config method, and within that I run a bunch of separate checks to see if each of the package's required pagetypes, pages, attribute keys, attribute types, etc are installed (just try to load the object), and if one of them isn't there I install it.
jgarcia replied on at Permalink Reply
jgarcia
I'll go with that. Thanks Tony.
jgarcia replied on at Permalink Reply
jgarcia
Along those same lines...I keep getting this error when I try to install a package using the upgrade function.

mysql error: [1048: Column 'pkgID' cannot be null] in EXECUTE("insert into Jobs (jName, jDescription, jDateInstalled, jNotUninstallable, jHandle, pkgID) values ('Advanced Forms - Clear Cache', 'Clear the advanced forms records cache.', '2010-06-04 09:50:25', 0, 'sixeightforms_clear_cache', NULL)")

This is the code I from my upgrade function:

parent::upgrade();
$pkg = Loader::package('sixeightforms');
Loader::model('job');
if(!Job::getByHandle('sixeightforms_clear_cache')) {
   Job::installByPackage('sixeightforms_clear_cache',$pkg);
}


My package handle is sixeightforms.
jgarcia replied on at Permalink Reply
jgarcia
Figured it out...

Loader::Package('sixeightforms') should be Package::getByHandle('sixeightforms');