updating drupal schema
I have an install file in place which create开发者_JAVA百科s a table when the module is first enabled. Halfway into the use of the module, I want to update the table with an additional column I write the code for it as
'salary' => array(
'description' => t('Salary: '),
'type' => 'int',
'unsigned'=> TRUE,
'not null' => TRUE,
),
This goes within the schema definition. Now to add it to the database , I use the update function as
function test_update_6001(){
$ret = array();
$spec = array(
'description' => t('Salary: '),
'type' => 'int',
'unsigned'=> TRUE,
'not null' => TRUE,
);
db_add_field($ret,'info','salary',$spec); //info is the tablename and salary is the column to be added
return $ret;
drupal_install_schema('stalker');
}
This is not updating the schema. Am i missing a step?
Make sure you include it in the original hook_schema() function and not just in the update function.
You don't need to call the drupal_install_schema
after the return, but it's not the cause anyway. There's no error when you run the update.php script?
精彩评论