function date_db_integrity in Date 6.2
Same name and namespace in other branches
- 5.2 date/date.install \date_db_integrity()
- 5 date.install \date_db_integrity()
- 6 date/date.install \date_db_integrity()
File
- date/
date.install, line 386
Code
function date_db_integrity($name) {
$ret = array();
if (!module_exists('content') || !module_exists('date_api')) {
return $ret;
}
drupal_load('module', 'content');
require_once './' . drupal_get_path('module', 'content') . '/includes/content.admin.inc';
$ret = array();
$fields = content_fields();
foreach ($fields as $field) {
$db_info = content_database_info($field);
if ($field['type'] == 'date' || $field['type'] == 'datestamp') {
$table = $db_info['table'];
// start with the new column patterns.
$columns_start = $db_info['columns'];
$columns_end = $db_info['columns'];
// alter the start column values to invalid or empty
// values to force the new columns to be reset.
$columns_start['value']['length'] = 90;
if (!empty($field['todate'])) {
if (!db_column_exists($table, $columns_start['value2']['column'])) {
unset($columns_start['value2']);
}
else {
$columns_start['value2']['length'] = 80;
}
}
if ($field['tz_handling'] == 'date') {
if (!db_column_exists($table, $columns_start['timezone']['column'])) {
unset($columns_start['timezone']);
}
else {
$columns_start['timezone']['length'] = 80;
}
if (!db_column_exists($table, $columns_start['offset']['column'])) {
unset($columns_start['offset']);
}
else {
$columns_start['offset']['length'] = 80;
}
if ($field['todate']) {
if (!db_column_exists($table, $columns_start['offset2']['column'])) {
unset($columns_start['offset2']);
}
else {
$columns_start['offset2']['length'] = 80;
}
}
}
if (!empty($field['repeat'])) {
if (!db_column_exists($table, $columns_start['rrule']['column'])) {
unset($columns_start['rrule']);
}
else {
$columns_start['rrule']['length'] = 80;
}
}
$start_field = $field;
$start_field['columns'] = $columns_start;
$end_field = $field;
$end_field['columns'] = $columns_end;
content_alter_db($start_field, $end_field);
$message = 'Date database integrity check. Updated table ' . $table . ' to set all columns to accept NULL values.';
$ret[] = array(
'success' => TRUE,
'query' => $message,
);
}
}
content_clear_type_cache();
return $ret;
}