2 require_once("boot.php");
3 require_once("include/text.php");
5 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
8 * send the email and do what is needed to do on update fails
10 * @param update_id (int) number of failed update
11 * @param error_message (str) error message
13 function update_fail($update_id, $error_message){
14 //send the administrators an e-mail
15 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
16 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
20 // every admin could had different language
22 foreach ($adminlist as $admin) {
23 $lang = (($admin['language'])?$admin['language']:'en');
26 $preamble = deindent(t("
27 The friendica developers released update %s recently,
28 but when I tried to install it, something went terribly wrong.
29 This needs to be fixed soon and I can't do it alone. Please contact a
30 friendica developer if you can not help me on your own. My database might be invalid."));
31 $body = t("The error message is\n[pre]%s[/pre]");
32 $preamble = sprintf($preamble, $update_id);
33 $body = sprintf($body, $error_message);
36 'type' => "SYSTEM_EMAIL",
37 'to_email' => $admin['email'],
38 'preamble' => $preamble,
48 $email_tpl = get_intltext_template("update_fail_eml.tpl");
49 $email_msg = replace_macros($email_tpl, array(
50 '$sitename' => $a->config['sitename'],
51 '$siteurl' => $a->get_baseurl(),
52 '$update' => DB_UPDATE_VERSION,
53 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
55 $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
56 require_once('include/email.php');
57 $subject = email_header_encode($subject,'UTF-8');
58 mail($a->config['admin_email'], $subject, $email_msg,
59 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
60 .'Content-type: text/plain; charset=UTF-8'."\n"
61 .'Content-transfer-encoding: 8bit');
64 logger("CRITICAL: Database structure update failed: ".$retval);
69 function table_structure($table) {
70 $structures = q("DESCRIBE `%s`", $table);
72 $indexes = q("SHOW INDEX FROM `%s`", $table);
77 if (is_array($indexes))
78 foreach ($indexes AS $index) {
79 if ($index["Index_type"] == "FULLTEXT")
82 $column = $index["Column_name"];
83 if ($index["Sub_part"] != "")
84 $column .= "(".$index["Sub_part"].")";
86 $indexdata[$index["Key_name"]][] = $column;
89 if (is_array($structures)) {
90 foreach($structures AS $field) {
91 $fielddata[$field["Field"]]["type"] = $field["Type"];
92 if ($field["Null"] == "NO")
93 $fielddata[$field["Field"]]["not null"] = true;
95 if (isset($field["Default"]))
96 $fielddata[$field["Field"]]["default"] = $field["Default"];
98 if ($field["Extra"] != "")
99 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
101 if ($field["Key"] == "PRI")
102 $fielddata[$field["Field"]]["primary"] = true;
105 return(array("fields"=>$fielddata, "indexes"=>$indexdata));
108 function print_structure($database) {
109 echo "-- ------------------------------------------\n";
110 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
111 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
112 echo "-- ------------------------------------------\n\n\n";
113 foreach ($database AS $name => $structure) {
115 echo "-- TABLE $name\n";
117 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
123 function update_structure($verbose, $action, $tables=null, $definition=null) {
128 logger('updating structure', LOGGER_DEBUG);
130 // Get the current structure
133 if (is_null($tables))
134 $tables = q("show tables");
136 foreach ($tables AS $table) {
137 $table = current($table);
139 $database[$table] = table_structure($table);
142 // Get the definition
143 if (is_null($definition))
144 $definition = db_definition();
147 foreach ($definition AS $name => $structure) {
149 if (!isset($database[$name])) {
150 $r = db_create_table($name, $structure["fields"], $verbose, $action);
152 $errors .= t('Errors encountered creating database tables.').$name.EOL;
154 // Drop the index if it isn't present in the definition and index name doesn't start with "local_"
155 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
156 if (!isset($structure["indexes"][$indexname]) && substr($indexname, 0, 6) != 'local_') {
157 $sql2=db_drop_index($indexname);
159 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
164 // Compare the field structure field by field
165 foreach ($structure["fields"] AS $fieldname => $parameters) {
166 if (!isset($database[$name]["fields"][$fieldname])) {
167 $sql2=db_add_table_field($fieldname, $parameters);
169 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
173 // Compare the field definition
174 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
175 $new_field_definition = implode(",",$parameters);
176 if ($current_field_definition != $new_field_definition) {
177 $sql2=db_modify_table_field($fieldname, $parameters);
179 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
189 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
190 if (!isset($database[$name]["indexes"][$indexname])) {
191 $sql2=db_create_index($indexname, $fieldnames);
194 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
210 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
218 function db_field_command($parameters, $create = true) {
219 $fieldstruct = $parameters["type"];
221 if ($parameters["not null"])
222 $fieldstruct .= " NOT NULL";
224 if (isset($parameters["default"])){
225 if (strpos(strtolower($parameters["type"]),"int")!==false) {
226 $fieldstruct .= " DEFAULT ".$parameters["default"];
228 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
231 if ($parameters["extra"] != "")
232 $fieldstruct .= " ".$parameters["extra"];
234 if (($parameters["primary"] != "") AND $create)
235 $fieldstruct .= " PRIMARY KEY";
237 return($fieldstruct);
240 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
247 foreach($fields AS $fieldname => $field) {
248 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
251 if (!is_null($indexes)) {
253 foreach ($indexes AS $indexname => $fieldnames) {
254 $sql_index = db_create_index($indexname, $fieldnames, "");
255 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
259 $sql = implode(",\n\t", $sql_rows);
261 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
272 function db_add_table_field($fieldname, $parameters) {
273 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
277 function db_modify_table_field($fieldname, $parameters) {
278 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
282 function db_drop_index($indexname) {
283 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
287 function db_create_index($indexname, $fieldnames, $method="ADD") {
289 if ($indexname == "PRIMARY")
293 foreach ($fieldnames AS $fieldname) {
297 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
298 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
300 $names .= "`".dbesc($fieldname)."`";
303 $method = strtoupper(trim($method));
304 if ($method!="" && $method!="ADD") {
305 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
309 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
313 function db_definition() {
317 $database["addon"] = array(
319 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
320 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
321 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
322 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
323 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
324 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
325 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
328 "PRIMARY" => array("id"),
331 $database["attach"] = array(
333 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
334 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
335 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
336 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
337 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
338 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
339 "data" => array("type" => "longblob", "not null" => "1"),
340 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
341 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
342 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
343 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
344 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
345 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
348 "PRIMARY" => array("id"),
351 $database["auth_codes"] = array(
353 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
354 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
355 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
356 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
357 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
360 "PRIMARY" => array("id"),
363 $database["cache"] = array(
365 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
366 "v" => array("type" => "text", "not null" => "1"),
367 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
368 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
371 "PRIMARY" => array("k"),
372 "updated" => array("updated"),
375 $database["challenge"] = array(
377 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
378 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
379 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
380 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
381 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
382 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
385 "PRIMARY" => array("id"),
388 $database["clients"] = array(
390 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
391 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
392 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
393 "name" => array("type" => "text"),
394 "icon" => array("type" => "text"),
395 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
398 "PRIMARY" => array("client_id"),
401 $database["config"] = array(
403 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
404 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
405 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
406 "v" => array("type" => "text", "not null" => "1"),
409 "PRIMARY" => array("id"),
410 "cat_k" => array("cat(30)","k(30)"),
413 $database["contact"] = array(
415 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
416 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
417 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
418 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
419 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
420 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
421 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
422 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
423 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
424 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
425 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
426 "about" => array("type" => "text", "not null" => "1"),
427 "keywords" => array("type" => "text", "not null" => "1"),
428 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
429 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
430 "photo" => array("type" => "text", "not null" => "1"),
431 "thumb" => array("type" => "text", "not null" => "1"),
432 "micro" => array("type" => "text", "not null" => "1"),
433 "site-pubkey" => array("type" => "text", "not null" => "1"),
434 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
435 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
436 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
437 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
438 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
439 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
440 "pubkey" => array("type" => "text", "not null" => "1"),
441 "prvkey" => array("type" => "text", "not null" => "1"),
442 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
443 "request" => array("type" => "text", "not null" => "1"),
444 "notify" => array("type" => "text", "not null" => "1"),
445 "poll" => array("type" => "text", "not null" => "1"),
446 "confirm" => array("type" => "text", "not null" => "1"),
447 "poco" => array("type" => "text", "not null" => "1"),
448 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
449 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
450 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
451 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
452 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
453 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
454 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
455 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
456 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
457 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
458 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
459 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
460 "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
461 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
462 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
463 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
464 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
465 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
466 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
467 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
468 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
469 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
470 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
471 "reason" => array("type" => "text", "not null" => "1"),
472 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
473 "info" => array("type" => "mediumtext", "not null" => "1"),
474 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
475 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
476 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
477 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
478 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
479 "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
482 "PRIMARY" => array("id"),
483 "uid" => array("uid"),
486 $database["conv"] = array(
488 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
489 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
490 "recips" => array("type" => "mediumtext", "not null" => "1"),
491 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
492 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
493 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
494 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
495 "subject" => array("type" => "mediumtext", "not null" => "1"),
498 "PRIMARY" => array("id"),
499 "uid" => array("uid"),
502 $database["deliverq"] = array(
504 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
505 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
506 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
507 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
510 "PRIMARY" => array("id"),
513 $database["dsprphotoq"] = array(
515 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
516 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
517 "msg" => array("type" => "mediumtext", "not null" => "1"),
518 "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
521 "PRIMARY" => array("id"),
524 $database["event"] = array(
526 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
527 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
528 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
529 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
530 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
531 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
532 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
533 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
534 "summary" => array("type" => "text", "not null" => "1"),
535 "desc" => array("type" => "text", "not null" => "1"),
536 "location" => array("type" => "text", "not null" => "1"),
537 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
538 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
539 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
540 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
541 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
542 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
543 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
544 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
547 "PRIMARY" => array("id"),
548 "uid" => array("uid"),
551 $database["fcontact"] = array(
553 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
554 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
555 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
556 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
557 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
558 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
559 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
560 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
561 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
562 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
563 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
564 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
565 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
566 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
567 "pubkey" => array("type" => "text", "not null" => "1"),
568 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
571 "PRIMARY" => array("id"),
572 "addr" => array("addr"),
575 $database["ffinder"] = array(
577 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
578 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
579 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
580 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
583 "PRIMARY" => array("id"),
586 $database["fserver"] = array(
588 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
589 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
590 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
591 "key" => array("type" => "text", "not null" => "1"),
594 "PRIMARY" => array("id"),
595 "server" => array("server"),
598 $database["fsuggest"] = array(
600 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
601 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
602 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
603 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
604 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
605 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
606 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
607 "note" => array("type" => "text", "not null" => "1"),
608 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
611 "PRIMARY" => array("id"),
614 $database["gcign"] = array(
616 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
617 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
618 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
621 "PRIMARY" => array("id"),
622 "uid" => array("uid"),
623 "gcid" => array("gcid"),
626 $database["gcontact"] = array(
628 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
629 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
630 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
631 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
633 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
634 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
635 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
636 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
637 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
638 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
639 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
640 "about" => array("type" => "text", "not null" => "1"),
641 "keywords" => array("type" => "text", "not null" => "1"),
642 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
643 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
644 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
645 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
646 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
649 "PRIMARY" => array("id"),
650 "nurl" => array("nurl"),
651 "updated" => array("updated"),
654 $database["glink"] = array(
656 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
657 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
658 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
659 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
660 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
661 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
664 "PRIMARY" => array("id"),
665 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
666 "gcid" => array("gcid"),
667 "zcid" => array("zcid"),
670 $database["group"] = array(
672 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
673 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
674 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
675 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
676 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
679 "PRIMARY" => array("id"),
680 "uid" => array("uid"),
683 $database["group_member"] = array(
685 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
686 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
687 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
688 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
691 "PRIMARY" => array("id"),
692 "uid_gid_contactid" => array("uid","gid","contact-id"),
695 $database["gserver"] = array(
697 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
698 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
700 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
701 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
702 "info" => array("type" => "text", "not null" => "1"),
703 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
704 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
705 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
706 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
707 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
708 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
709 "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
710 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
711 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
714 "PRIMARY" => array("id"),
715 "nurl" => array("nurl"),
718 $database["guid"] = array(
720 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
721 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
722 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
723 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
724 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
727 "PRIMARY" => array("id"),
728 "guid" => array("guid"),
729 "plink" => array("plink"),
730 "uri" => array("uri"),
733 $database["hook"] = array(
735 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
736 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
742 "PRIMARY" => array("id"),
743 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
746 $database["intro"] = array(
748 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
749 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
750 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
751 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
752 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
753 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
754 "note" => array("type" => "text", "not null" => "1"),
755 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
757 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
758 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
761 "PRIMARY" => array("id"),
764 $database["item"] = array(
766 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
767 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
768 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
769 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
770 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
771 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
772 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
775 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
776 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
777 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
778 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
779 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
780 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
781 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
782 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
783 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
784 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
785 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
786 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
787 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
788 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
789 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
790 "body" => array("type" => "mediumtext", "not null" => "1"),
791 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
792 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
793 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
794 "object" => array("type" => "text", "not null" => "1"),
795 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
796 "target" => array("type" => "text", "not null" => "1"),
797 "postopts" => array("type" => "text", "not null" => "1"),
798 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
799 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
800 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
801 "tag" => array("type" => "mediumtext", "not null" => "1"),
802 "attach" => array("type" => "mediumtext", "not null" => "1"),
803 "inform" => array("type" => "mediumtext", "not null" => "1"),
804 "file" => array("type" => "mediumtext", "not null" => "1"),
805 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
806 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
807 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
808 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
809 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
810 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
811 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
812 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
813 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
814 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
815 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
816 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
817 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
818 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
819 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
820 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
821 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
822 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
823 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
824 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
825 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
826 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
827 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
830 "PRIMARY" => array("id"),
831 "guid" => array("guid"),
832 "uri" => array("uri"),
833 "parent" => array("parent"),
834 "parent-uri" => array("parent-uri"),
835 "extid" => array("extid"),
836 "uid_id" => array("uid","id"),
837 "uid_created" => array("uid","created"),
838 "uid_unseen" => array("uid","unseen"),
839 "uid_network_received" => array("uid","network","received"),
840 "uid_received" => array("uid","received"),
841 "uid_network_commented" => array("uid","network","commented"),
842 "uid_commented" => array("uid","commented"),
843 "uid_title" => array("uid","title"),
844 "uid_thrparent" => array("uid","thr-parent"),
845 "uid_parenturi" => array("uid","parent-uri"),
846 "uid_contactid_created" => array("uid","contact-id","created"),
847 "wall_body" => array("wall","body(6)"),
848 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
849 "uid_uri" => array("uid","uri"),
850 "uid_wall_created" => array("uid","wall","created"),
851 "resource-id" => array("resource-id"),
852 "uid_type" => array("uid","type"),
853 "uid_starred" => array("uid","starred"),
854 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
855 "uid_wall_parent_created" => array("uid","wall","parent","created"),
856 "uid_type_changed" => array("uid","type","changed"),
857 "contactid_verb" => array("contact-id","verb"),
858 "deleted_changed" => array("deleted","changed"),
859 "uid_wall_changed" => array("uid","wall","changed"),
860 "uid_eventid" => array("uid","event-id"),
861 "uid_authorlink" => array("uid","author-link"),
862 "uid_ownerlink" => array("uid","owner-link"),
865 $database["item_id"] = array(
867 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
868 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
869 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
870 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "PRIMARY" => array("id"),
875 "uid" => array("uid"),
876 "sid" => array("sid"),
877 "service" => array("service"),
878 "iid" => array("iid"),
881 $database["locks"] = array(
883 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
884 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
885 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
886 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
889 "PRIMARY" => array("id"),
892 $database["mail"] = array(
894 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
895 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
896 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
897 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
898 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
899 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
902 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
903 "body" => array("type" => "mediumtext", "not null" => "1"),
904 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
905 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
906 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
907 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
908 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
909 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
910 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
913 "PRIMARY" => array("id"),
914 "uid" => array("uid"),
915 "guid" => array("guid"),
916 "convid" => array("convid"),
917 "reply" => array("reply"),
918 "uri" => array("uri"),
919 "parent-uri" => array("parent-uri"),
922 $database["mailacct"] = array(
924 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
925 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
926 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
927 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
928 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
929 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
930 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
931 "pass" => array("type" => "text", "not null" => "1"),
932 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
933 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
934 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
935 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
936 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
939 "PRIMARY" => array("id"),
942 $database["manage"] = array(
944 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
945 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
946 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
949 "PRIMARY" => array("id"),
950 "uid_mid" => array("uid","mid"),
953 $database["notify"] = array(
955 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
956 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
957 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
958 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
959 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
960 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
961 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
962 "msg" => array("type" => "mediumtext", "not null" => "1"),
963 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
964 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
965 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
966 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
967 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
968 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
969 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
972 "PRIMARY" => array("id"),
973 "uid" => array("uid"),
976 $database["notify-threads"] = array(
978 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
979 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
980 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
981 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
982 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
985 "PRIMARY" => array("id"),
986 "master-parent-item" => array("master-parent-item"),
987 "receiver-uid" => array("receiver-uid"),
990 $database["pconfig"] = array(
992 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
993 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
994 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
995 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
996 "v" => array("type" => "mediumtext", "not null" => "1"),
999 "PRIMARY" => array("id"),
1000 "uid_cat_k" => array("uid","cat(30)","k(30)"),
1003 $database["photo"] = array(
1005 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1006 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1007 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1008 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1009 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1010 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1011 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1012 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1013 "desc" => array("type" => "text", "not null" => "1"),
1014 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1015 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1016 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1017 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1018 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1019 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1020 "data" => array("type" => "mediumblob", "not null" => "1"),
1021 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1022 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1023 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1024 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1025 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1026 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1029 "PRIMARY" => array("id"),
1030 "uid" => array("uid"),
1031 "resource-id" => array("resource-id"),
1032 "guid" => array("guid"),
1035 $database["poll"] = array(
1037 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1038 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1039 "q0" => array("type" => "mediumtext", "not null" => "1"),
1040 "q1" => array("type" => "mediumtext", "not null" => "1"),
1041 "q2" => array("type" => "mediumtext", "not null" => "1"),
1042 "q3" => array("type" => "mediumtext", "not null" => "1"),
1043 "q4" => array("type" => "mediumtext", "not null" => "1"),
1044 "q5" => array("type" => "mediumtext", "not null" => "1"),
1045 "q6" => array("type" => "mediumtext", "not null" => "1"),
1046 "q7" => array("type" => "mediumtext", "not null" => "1"),
1047 "q8" => array("type" => "mediumtext", "not null" => "1"),
1048 "q9" => array("type" => "mediumtext", "not null" => "1"),
1051 "PRIMARY" => array("id"),
1052 "uid" => array("uid"),
1055 $database["poll_result"] = array(
1057 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1058 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1059 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1062 "PRIMARY" => array("id"),
1063 "poll_id" => array("poll_id"),
1064 "choice" => array("choice"),
1067 $database["profile"] = array(
1069 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1070 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1071 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1072 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1073 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1074 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1075 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1076 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1077 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1078 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1079 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1080 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1081 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1082 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1083 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1084 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1085 "with" => array("type" => "text", "not null" => "1"),
1086 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1087 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1088 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1089 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1090 "pub_keywords" => array("type" => "text", "not null" => "1"),
1091 "prv_keywords" => array("type" => "text", "not null" => "1"),
1092 "likes" => array("type" => "text", "not null" => "1"),
1093 "dislikes" => array("type" => "text", "not null" => "1"),
1094 "about" => array("type" => "text", "not null" => "1"),
1095 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1096 "music" => array("type" => "text", "not null" => "1"),
1097 "book" => array("type" => "text", "not null" => "1"),
1098 "tv" => array("type" => "text", "not null" => "1"),
1099 "film" => array("type" => "text", "not null" => "1"),
1100 "interest" => array("type" => "text", "not null" => "1"),
1101 "romance" => array("type" => "text", "not null" => "1"),
1102 "work" => array("type" => "text", "not null" => "1"),
1103 "education" => array("type" => "text", "not null" => "1"),
1104 "contact" => array("type" => "text", "not null" => "1"),
1105 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1107 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1108 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1109 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1112 "PRIMARY" => array("id"),
1113 "hometown" => array("hometown"),
1116 $database["profile_check"] = array(
1118 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1119 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1120 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1121 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1122 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1123 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1126 "PRIMARY" => array("id"),
1129 $database["push_subscriber"] = array(
1131 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1132 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1133 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1134 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1135 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1136 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1137 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1138 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1141 "PRIMARY" => array("id"),
1144 $database["queue"] = array(
1146 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1147 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1148 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1149 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1150 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1151 "content" => array("type" => "mediumtext", "not null" => "1"),
1152 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1155 "PRIMARY" => array("id"),
1156 "cid" => array("cid"),
1157 "created" => array("created"),
1158 "last" => array("last"),
1159 "network" => array("network"),
1160 "batch" => array("batch"),
1163 $database["register"] = array(
1165 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1166 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1167 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1168 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1169 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1170 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1173 "PRIMARY" => array("id"),
1176 $database["search"] = array(
1178 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1179 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1180 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1183 "PRIMARY" => array("id"),
1184 "uid" => array("uid"),
1185 "term" => array("term"),
1188 $database["session"] = array(
1190 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1191 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1192 "data" => array("type" => "text", "not null" => "1"),
1193 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1196 "PRIMARY" => array("id"),
1197 "sid" => array("sid"),
1198 "expire" => array("expire"),
1201 $database["sign"] = array(
1203 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1204 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1205 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1206 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1207 "signature" => array("type" => "text", "not null" => "1"),
1208 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1211 "PRIMARY" => array("id"),
1212 "iid" => array("iid"),
1213 "retract_iid" => array("retract_iid"),
1216 $database["spam"] = array(
1218 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1219 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1220 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1221 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1222 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1223 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1226 "PRIMARY" => array("id"),
1227 "uid" => array("uid"),
1228 "spam" => array("spam"),
1229 "ham" => array("ham"),
1230 "term" => array("term"),
1233 $database["term"] = array(
1235 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1236 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1237 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1238 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1239 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1240 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1241 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1242 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1243 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1244 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1245 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1246 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1249 "PRIMARY" => array("tid"),
1250 "oid_otype_type_term" => array("oid","otype","type","term"),
1251 "uid_term_tid" => array("uid","term","tid"),
1252 "type_term" => array("type","term"),
1253 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1254 "otype_type_term_tid" => array("otype","type","term","tid"),
1255 "guid" => array("guid"),
1258 $database["thread"] = array(
1260 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1261 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1262 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1263 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1264 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1265 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1266 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1267 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1268 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1269 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1270 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1271 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1272 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1273 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1274 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1275 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1276 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1277 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1278 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1279 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1280 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1281 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1282 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1285 "PRIMARY" => array("iid"),
1286 "created" => array("created"),
1287 "commented" => array("commented"),
1288 "uid_network_commented" => array("uid","network","commented"),
1289 "uid_network_created" => array("uid","network","created"),
1290 "uid_contactid_commented" => array("uid","contact-id","commented"),
1291 "uid_contactid_created" => array("uid","contact-id","created"),
1292 "wall_private_received" => array("wall","private","received"),
1293 "uid_created" => array("uid","created"),
1294 "uid_commented" => array("uid","commented"),
1297 $database["tokens"] = array(
1299 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1300 "secret" => array("type" => "text", "not null" => "1"),
1301 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1302 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1303 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1304 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1307 "PRIMARY" => array("id"),
1310 $database["unique_contacts"] = array(
1312 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1313 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1314 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1315 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1316 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1317 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1318 "about" => array("type" => "text", "not null" => "1"),
1321 "PRIMARY" => array("id"),
1322 "url" => array("url"),
1325 $database["user"] = array(
1327 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1328 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1329 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1330 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1331 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1332 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1333 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1334 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1335 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1336 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1337 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1338 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1339 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1340 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1341 "pubkey" => array("type" => "text", "not null" => "1"),
1342 "prvkey" => array("type" => "text", "not null" => "1"),
1343 "spubkey" => array("type" => "text", "not null" => "1"),
1344 "sprvkey" => array("type" => "text", "not null" => "1"),
1345 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1346 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1347 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1348 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1349 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1350 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1351 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1352 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1353 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1354 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1355 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1356 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1357 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1358 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1359 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1360 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1361 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1362 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1363 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1364 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1365 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1366 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1367 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1368 "openidserver" => array("type" => "text", "not null" => "1"),
1371 "PRIMARY" => array("uid"),
1372 "nickname" => array("nickname"),
1375 $database["userd"] = array(
1377 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1378 "username" => array("type" => "varchar(255)", "not null" => "1"),
1381 "PRIMARY" => array("id"),
1382 "username" => array("username"),
1391 * run from command line
1393 function dbstructure_run(&$argv, &$argc) {
1401 @include(".htconfig.php");
1402 require_once("include/dba.php");
1403 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1404 unset($db_host, $db_user, $db_pass, $db_data);
1410 update_structure(true, true);
1413 print_structure(db_definition());
1420 echo $argv[0]." <command>\n";
1423 echo "update update database schema\n";
1424 echo "dumpsql dump database schema\n";
1432 if (array_search(__file__,get_included_files())===0){
1433 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);