modifying a block table

Permalink
so, I am updating SimpleEvent to version 2.0 which will add a new column to the tables for categories. I have this working great and updating great using the dashboard updater. no problems at all there.

however, If I just drag and drop the new package via FTP and page refresh the site, the mysql blows up.

My question is, is this just a simple matter of me adding some sort of update function to the package controller, and C5 will see that and perform the same function? I've tried this on the block level, but this seems like a less than ideal way to do it.

my primary objective is a smooth transition.

RadiantWeb
 
Remo replied on at Permalink Reply
Remo
increase the version number in your controller and go to the "update" tab in add functionality..

adodb xmlns is able to "merge" the structure automatically. No need for alter table statements!
RadiantWeb replied on at Permalink Reply
RadiantWeb
right. but as an "order of execute", as an end user, if I happen to upload that new folder with calls to the new data that isn't there yet while on a page of the site as opposed to the dashboard, then all kinds of nasty happen.

it's pretty seamless if done from the dashboard to begin with. but if you happen to load up the new files, and be on a page that uses that block...ugly shows up. I'm just wondering if there is a way to avoid that, or at least check the version number, and display a "HEY!!! GO TO YOUR DASHBOARD AND UPGRADE!"
Remo replied on at Permalink Reply
Remo
ah got ya!

Yes, this would be nice..

It might even be enough to override the view.php to print a message, in case the installed version isn't the same as the version in the controller.
RadiantWeb replied on at Permalink Reply
RadiantWeb
not a big deal really unless a block update modifies the table structure. Then it is a big deal.

As a developer, I don't want to continually have to explain.."yeah..just make sure you don't view/use your site b4 going to your dashboard and updating the package, and you won't get that mysql error."

I almost tend to think this should be a core feature...if you have uploaded a later version of a block or package, the site is not usable until you go to the dashboard and update it.
Remo replied on at Permalink Reply
Remo
go to concrete/libraries/block_view.php,

around line 200 modify the code to look like this:

$btHandle = $obj->getBlockTypeHandle();
         if (!isset($this->controller)) {
            $this->controller = Loader::controller($obj);
         }
         // begin remo
         $pkgID = $obj->pkgID;
         if($pkgID != 0) {
            $package = Package::getByID($pkgID);
            $versionInstalled = $package->getPackageVersion();
            $packageName = get_class($package);
            $packageFile = new $packageName;
            $versionFile = $packageFile->getPackageVersion();
            if ($versionInstalled != $versionFile) {
               echo 'Update needed! Dashboard link, auto update, whatever..';
               return;


It's not a complete solution but it shows you how to compare the version and output a message if they aren't equal...

I had to create my own instance of "Package", couldn't get the version in the file easier. Would be nice if there's a solution without get_class.