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);
68 function table_structure($table) {
69 $structures = q("DESCRIBE `%s`", $table);
71 $indexes = q("SHOW INDEX FROM `%s`", $table);
76 if (is_array($indexes))
77 foreach ($indexes AS $index) {
78 if ($index["Index_type"] == "FULLTEXT")
81 $column = $index["Column_name"];
82 if ($index["Sub_part"] != "")
83 $column .= "(".$index["Sub_part"].")";
85 $indexdata[$index["Key_name"]][] = $column;
88 if (is_array($structures)) {
89 foreach($structures AS $field) {
90 $fielddata[$field["Field"]]["type"] = $field["Type"];
91 if ($field["Null"] == "NO")
92 $fielddata[$field["Field"]]["not null"] = true;
94 if (isset($field["Default"]))
95 $fielddata[$field["Field"]]["default"] = $field["Default"];
97 if ($field["Extra"] != "")
98 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
100 if ($field["Key"] == "PRI")
101 $fielddata[$field["Field"]]["primary"] = true;
104 return(array("fields"=>$fielddata, "indexes"=>$indexdata));
107 function print_structure($database) {
108 echo "-- ------------------------------------------\n";
109 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
110 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
111 echo "-- ------------------------------------------\n\n\n";
112 foreach ($database AS $name => $structure) {
114 echo "-- TABLE $name\n";
116 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
122 function update_structure($verbose, $action, $tables=null, $definition=null) {
127 logger('updating structure', LOGGER_DEBUG);
129 // Get the current structure
132 if (is_null($tables))
133 $tables = q("show tables");
135 foreach ($tables AS $table) {
136 $table = current($table);
138 $database[$table] = table_structure($table);
141 // Get the definition
142 if (is_null($definition))
143 $definition = db_definition();
146 foreach ($definition AS $name => $structure) {
148 if (!isset($database[$name])) {
149 $r = db_create_table($name, $structure["fields"], $verbose, $action);
151 $errors .= t('Errors encountered creating database tables.').$name.EOL;
153 // Drop the index if it isn't present in the definition and index name doesn't start with "local_"
154 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
155 if (!isset($structure["indexes"][$indexname]) && substr($indexname, 0, 6) != 'local_') {
156 $sql2=db_drop_index($indexname);
158 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
163 // Compare the field structure field by field
164 foreach ($structure["fields"] AS $fieldname => $parameters) {
165 if (!isset($database[$name]["fields"][$fieldname])) {
166 $sql2=db_add_table_field($fieldname, $parameters);
168 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
172 // Compare the field definition
173 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
174 $new_field_definition = implode(",",$parameters);
175 if ($current_field_definition != $new_field_definition) {
176 $sql2=db_modify_table_field($fieldname, $parameters);
178 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
188 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
189 if (!isset($database[$name]["indexes"][$indexname])) {
190 $sql2=db_create_index($indexname, $fieldnames);
193 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
209 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
217 function db_field_command($parameters, $create = true) {
218 $fieldstruct = $parameters["type"];
220 if ($parameters["not null"])
221 $fieldstruct .= " NOT NULL";
223 if (isset($parameters["default"])){
224 if (strpos(strtolower($parameters["type"]),"int")!==false) {
225 $fieldstruct .= " DEFAULT ".$parameters["default"];
227 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
230 if ($parameters["extra"] != "")
231 $fieldstruct .= " ".$parameters["extra"];
233 if (($parameters["primary"] != "") AND $create)
234 $fieldstruct .= " PRIMARY KEY";
236 return($fieldstruct);
239 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
246 foreach($fields AS $fieldname => $field) {
247 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
250 if (!is_null($indexes)) {
252 foreach ($indexes AS $indexname => $fieldnames) {
253 $sql_index = db_create_index($indexname, $fieldnames, "");
254 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
258 $sql = implode(",\n\t", $sql_rows);
260 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
271 function db_add_table_field($fieldname, $parameters) {
272 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
276 function db_modify_table_field($fieldname, $parameters) {
277 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
281 function db_drop_index($indexname) {
282 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
286 function db_create_index($indexname, $fieldnames, $method="ADD") {
288 if ($indexname == "PRIMARY")
292 foreach ($fieldnames AS $fieldname) {
296 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
297 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
299 $names .= "`".dbesc($fieldname)."`";
302 $method = strtoupper(trim($method));
303 if ($method!="" && $method!="ADD") {
304 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
308 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
312 function db_definition() {
316 $database["addon"] = array(
318 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
319 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
320 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
321 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
322 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
323 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
324 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
327 "PRIMARY" => array("id"),
330 $database["attach"] = array(
332 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
333 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
334 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
335 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
336 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
337 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
338 "data" => array("type" => "longblob", "not null" => "1"),
339 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
340 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
341 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
342 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
343 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
344 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
347 "PRIMARY" => array("id"),
350 $database["auth_codes"] = array(
352 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
353 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
354 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
355 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
356 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
359 "PRIMARY" => array("id"),
362 $database["cache"] = array(
364 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
365 "v" => array("type" => "text", "not null" => "1"),
366 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
367 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
370 "PRIMARY" => array("k"),
371 "updated" => array("updated"),
374 $database["challenge"] = array(
376 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
377 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
378 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
379 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
380 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
381 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
384 "PRIMARY" => array("id"),
387 $database["clients"] = array(
389 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
390 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
391 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
392 "name" => array("type" => "text"),
393 "icon" => array("type" => "text"),
394 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
397 "PRIMARY" => array("client_id"),
400 $database["config"] = array(
402 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
403 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
404 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
405 "v" => array("type" => "text", "not null" => "1"),
408 "PRIMARY" => array("id"),
409 "cat_k" => array("cat(30)","k(30)"),
412 $database["contact"] = array(
414 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
415 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
416 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
417 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
418 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
419 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
420 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
421 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
422 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
423 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
424 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
425 "about" => array("type" => "text", "not null" => "1"),
426 "keywords" => array("type" => "text", "not null" => "1"),
427 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
428 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
429 "photo" => array("type" => "text", "not null" => "1"),
430 "thumb" => array("type" => "text", "not null" => "1"),
431 "micro" => array("type" => "text", "not null" => "1"),
432 "site-pubkey" => array("type" => "text", "not null" => "1"),
433 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
434 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
435 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
436 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
437 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
438 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
439 "pubkey" => array("type" => "text", "not null" => "1"),
440 "prvkey" => array("type" => "text", "not null" => "1"),
441 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
442 "request" => array("type" => "text", "not null" => "1"),
443 "notify" => array("type" => "text", "not null" => "1"),
444 "poll" => array("type" => "text", "not null" => "1"),
445 "confirm" => array("type" => "text", "not null" => "1"),
446 "poco" => array("type" => "text", "not null" => "1"),
447 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
448 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
449 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
450 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
451 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
452 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
453 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
454 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
455 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
456 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
457 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
458 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
459 "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
460 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
461 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
462 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
463 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
464 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
465 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
466 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
467 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
468 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
469 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
470 "reason" => array("type" => "text", "not null" => "1"),
471 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
472 "info" => array("type" => "mediumtext", "not null" => "1"),
473 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
474 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
475 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
476 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
477 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
478 "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
481 "PRIMARY" => array("id"),
482 "uid" => array("uid"),
485 $database["conv"] = array(
487 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
488 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
489 "recips" => array("type" => "mediumtext", "not null" => "1"),
490 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
491 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
492 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
493 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
494 "subject" => array("type" => "mediumtext", "not null" => "1"),
497 "PRIMARY" => array("id"),
498 "uid" => array("uid"),
501 $database["deliverq"] = array(
503 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
504 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
505 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
506 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
509 "PRIMARY" => array("id"),
512 $database["dsprphotoq"] = array(
514 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
515 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
516 "msg" => array("type" => "mediumtext", "not null" => "1"),
517 "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
520 "PRIMARY" => array("id"),
523 $database["event"] = array(
525 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
526 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
527 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
528 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
529 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
530 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
531 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
532 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
533 "summary" => array("type" => "text", "not null" => "1"),
534 "desc" => array("type" => "text", "not null" => "1"),
535 "location" => array("type" => "text", "not null" => "1"),
536 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
537 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
538 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
539 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
540 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
541 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
542 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
543 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
546 "PRIMARY" => array("id"),
547 "uid" => array("uid"),
550 $database["fcontact"] = array(
552 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
553 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
554 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
555 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
556 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
557 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
558 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
559 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
560 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
561 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
562 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
563 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
564 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
565 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
566 "pubkey" => array("type" => "text", "not null" => "1"),
567 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
570 "PRIMARY" => array("id"),
571 "addr" => array("addr"),
574 $database["ffinder"] = array(
576 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
577 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
578 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
579 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
582 "PRIMARY" => array("id"),
585 $database["fserver"] = array(
587 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
588 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
589 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
590 "key" => array("type" => "text", "not null" => "1"),
593 "PRIMARY" => array("id"),
594 "server" => array("server"),
597 $database["fsuggest"] = array(
599 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
600 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
601 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
602 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
603 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
604 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
605 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
606 "note" => array("type" => "text", "not null" => "1"),
607 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
610 "PRIMARY" => array("id"),
613 $database["gcign"] = array(
615 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
616 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
617 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
620 "PRIMARY" => array("id"),
621 "uid" => array("uid"),
622 "gcid" => array("gcid"),
625 $database["gcontact"] = array(
627 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
628 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
629 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
630 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
631 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
633 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
634 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
635 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
636 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
637 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
638 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
639 "about" => array("type" => "text", "not null" => "1"),
640 "keywords" => array("type" => "text", "not null" => "1"),
641 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
642 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
643 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
644 "addr" => 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"),
1385 $database["workerqueue"] = array(
1387 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1388 "parameter" => array("type" => "text", "not null" => "1"),
1389 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1390 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1391 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1392 "executed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1395 "PRIMARY" => array("id"),
1396 "created" => array("created"),
1405 * run from command line
1407 function dbstructure_run(&$argv, &$argc) {
1415 @include(".htconfig.php");
1416 require_once("include/dba.php");
1417 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1418 unset($db_host, $db_user, $db_pass, $db_data);
1424 update_structure(true, true);
1427 print_structure(db_definition());
1434 echo $argv[0]." <command>\n";
1437 echo "update update database schema\n";
1438 echo "dumpsql dump database schema\n";
1446 if (array_search(__file__,get_included_files())===0){
1447 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);