Block version upgrading - how to run database updates

Block version upgrading - how to run database updates

by Tony Delahunty -
Number of replies: 1

Can't seem to find this anywhere, even though it looks like it should be very intutive.  I'm writing a new version of a block, with DB changes but can't see how or when the function blockname_upgrade($oldversion) gets called.  I've got this function in a blockname/db/mysql.php and also in blockname/db/upgrade.php. I've also got parallel functions called xmldb_blockname_upgrade, but none seem to be invoked by my admin/index.php (I've put in echo-die statements just to see, but none executed)

And where would the $oldversion value be taken from when the function is called?

Average of ratings: -
In reply to Tony Delahunty

Re: Block version upgrading - how to run database updates

by Tony Delahunty -

... now delved a bit further, and to reply to my own post, I can see that the $oldversion number is the previously read in setting from $this->version value in the block_blockname.php code; but what should the 'do something' look like, in order to execute sql insert or alters when a DB-upgraded version number is present ?

Tony