function date_db_integrity in Date 6
Same name and namespace in other branches
- 5.2 date/date.install \date_db_integrity()
- 5 date.install \date_db_integrity()
- 6.2 date/date.install \date_db_integrity()
2 calls to date_db_integrity()
- date_update_5102 in date/
date.install - Make sure date module loads after date_api.
- date_update_5202 in date/
date.install - Database integrity update, supercedes most previous data integrity updates.
File
- date/
date.install, line 322
Code
function date_db_integrity($name) {
$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 ($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 ($field['repeat'] == 1) {
if (!db_column_exists($table, $columns_start['rrule']['column'])) {
unset($columns_start['rrule']);
}
else {
$columns_start['rrule']['length'] = 80;
}
}
content_alter_db_field($field, $columns_start, $field, $columns_end);
$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;
}