Hi,
I have developed a small module. After I installed it i realised that i forgot a column in the table. This should not be a problem, because of the update hook. But my module is not shown in the selection screen of the update.php file. There are some, but not mine. The following shows my install.php coding:

function productManagement_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      // the {tablename} syntax is so multisite installs can add a
      // prefix to the table name as set in the settings.php file
      
	  db_query("CREATE TABLE {productManagement_test} (
		  `id` int(11) NOT NULL auto_increment,
		  PRIMARY KEY  (`id`)
		) ENGINE=MyISAM;");
	
	return $ret;
  }
}

function productManagement_update_6001(){
	$ret = array();	
	$ret[] = update_sql("  ALTER TABLE `{productManagement_test}` ADD `pr1` INT( 1 ) NOT NULL  ;");
	return $ret;
}

function productManagement_update_6002(){
	$ret = array();	
	$ret[] = update_sql("  ALTER TABLE `{productManagement_test}` ADD `pr2` INT( 1 ) NOT NULL  ;");
	return $ret;
}

function productManagement_uninstall() {

	db_query("DROP TABLE {productManagement_test}");

	  
	  cache_clear_all('*', 'cache', TRUE);
	  cache_clear_all('*', 'cache_filter', TRUE);
	  cache_clear_all('*', 'cache_menu', TRUE);
	  cache_clear_all('*', 'cache_page', TRUE);	  
}

Thanks for your help!!!
Regards francula

Comments

jaypan’s picture

You are creating your database tables the wrong way. You should be using the Schema API, with drupal_install_schema() and drupal_uninstall_schema() and hook_schema(). I'm thinking that because you don't have a hook_schema in your file, Drupal may be ignoring your update functions. I haven't tested that, but it's my guess.

Contact me to contract me for D7 -> D10/11 migrations.

francula’s picture

Hi,thanks for your help but this dies Not Solvenz the problem. Any Other ideas?
Regstes Francula

francula’s picture

Hi,
i renamed the module from productManagement to product_management and now it works!?!?!?!
Any idea if this is a bug?
Regards