function number_update_5 in Content Construction Kit (CCK) 5
Set the value columns to accept NULL values
File
- ./
number.install, line 131
Code
function number_update_5() {
$ret = array();
include_once './' . drupal_get_path('module', 'content') . '/content.module';
include_once './' . drupal_get_path('module', 'content') . '/content_admin.inc';
content_clear_type_cache();
$fields = content_fields();
foreach ($fields as $field) {
switch ($field['type']) {
case 'number_integer':
case 'number_decimal':
$db_info = content_database_info($field);
$columns_old = $db_info['columns'];
$columns = $columns_old;
$columns['value']['not null'] = FALSE;
$columns['value']['default'] = NULL;
// force the old values : if the db info was rebuilt before the update is run,
// it will already contain the new values, and nothing gets changed in content_alter_db_field
$columns_old['value']['not null'] = TRUE;
$columns_old['value']['default'] = 0;
content_alter_db_field($field, $columns_old, $field, $columns);
$ret[] = array(
'query' => strtr('The field %field_name has been updated to accept NULL values.', array(
'%field_name' => $field['field_name'],
)),
'success' => TRUE,
);
break;
}
}
db_query('DELETE FROM {cache}');
return $ret;
}