I’m pretty sure the version does not get updated automatically. I usually include something in the CP class’s constructor to test to see if the module’s version matches the one recorded in the database.
If it does not, then I update it and if there have been databases changes between versions, make the db changes accordingly. Something like:
class SelectedItems_CP {
var $version = '1.2';
function SelectedItems_CP( $switch = TRUE )
{
global $IN, $DB;
// Upgrade module if necessary
$query = $DB->query( "SELECT module_version FROM exp_modules WHERE module_name = 'Selecteditems'" );
if( $query->num_rows > 0 )
{
if( $query->row['module_version'] != $this->version )
{
$DB->query("UPDATE exp_modules SET module_version='".$this->version."' WHERE module_name='Selecteditems'");
}
if ( $query->row['module_version'] < "1.1" ) {
// Make any database changes between 1.0 and 1.1
}
if ( $query->row['module_version'] < "1.2" ) {
// Make any database changes between 1.1 and 1.2
}
}
...
Adam has it.
You can use the same process that updates the version number to make other changes as necessary (like altering a table if needed or something like that) so if someone jumps from version 1.1 to 1.6 they don’t miss any database changes that might affect them.
Jamie
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.