}
}
-function update_structure($verbose, $action) {
+function update_structure($verbose, $action, $tables=null, $definition=null) {
global $a, $db;
$errors = false;
// Get the current structure
$database = array();
- $tables = q("show tables");
+ if (is_null($tables))
+ $tables = q("show tables");
foreach ($tables AS $table) {
$table = current($table);
}
// Get the definition
- $definition = db_definition();
+ if (is_null($definition))
+ $definition = db_definition();
// Compare it
foreach ($definition AS $name => $structure) {
if(false === $r)
$errors .= t('Errors encountered creating database tables.').$name.EOL;
} else {
- // Drop the index if it isn't present in the definition
+ // Drop the index if it isn't present in the definition and index name doesn't start with "local_"
foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
- if (!isset($structure["indexes"][$indexname])) {
+ if (!isset($structure["indexes"][$indexname]) && substring($indexname, 0, 5) != 'local_') {
$sql2=db_drop_index($indexname);
if ($sql3 == "")
$sql3 = "ALTER TABLE `".$name."` ".$sql2;
"uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
"avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
"term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
+ "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
"priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
"blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
"readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),