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 "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 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
643 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
644 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
647 "PRIMARY" => array("id"),
648 "nurl" => array("nurl"),
651 $database["glink"] = array(
653 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
654 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
655 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
656 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
657 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
658 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
661 "PRIMARY" => array("id"),
662 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
663 "gcid" => array("gcid"),
664 "zcid" => array("zcid"),
667 $database["group"] = array(
669 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
670 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
671 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
672 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
673 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
676 "PRIMARY" => array("id"),
677 "uid" => array("uid"),
680 $database["group_member"] = array(
682 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
683 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
684 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
685 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
688 "PRIMARY" => array("id"),
689 "uid_gid_contactid" => array("uid","gid","contact-id"),
692 $database["gserver"] = array(
694 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
695 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
696 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
697 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
698 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "info" => array("type" => "text", "not null" => "1"),
700 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
701 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
702 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
703 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
704 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
705 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
706 "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
707 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
708 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
711 "PRIMARY" => array("id"),
712 "nurl" => array("nurl"),
715 $database["guid"] = array(
717 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
718 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
719 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
720 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
721 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
724 "PRIMARY" => array("id"),
725 "guid" => array("guid"),
726 "plink" => array("plink"),
727 "uri" => array("uri"),
730 $database["hook"] = array(
732 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
733 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
734 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
735 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
739 "PRIMARY" => array("id"),
740 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
743 $database["intro"] = array(
745 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
746 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
747 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
748 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
749 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
750 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
751 "note" => array("type" => "text", "not null" => "1"),
752 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
753 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
754 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
755 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
758 "PRIMARY" => array("id"),
761 $database["item"] = array(
763 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
764 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
765 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
766 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
767 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
768 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
769 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
770 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
772 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
773 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
774 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
775 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
776 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
777 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
778 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
779 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
780 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
781 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
782 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
783 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
784 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
785 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
786 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
787 "body" => array("type" => "mediumtext", "not null" => "1"),
788 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
789 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
790 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
791 "object" => array("type" => "text", "not null" => "1"),
792 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
793 "target" => array("type" => "text", "not null" => "1"),
794 "postopts" => array("type" => "text", "not null" => "1"),
795 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
796 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
797 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
798 "tag" => array("type" => "mediumtext", "not null" => "1"),
799 "attach" => array("type" => "mediumtext", "not null" => "1"),
800 "inform" => array("type" => "mediumtext", "not null" => "1"),
801 "file" => array("type" => "mediumtext", "not null" => "1"),
802 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
803 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
804 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
805 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
806 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
807 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
808 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
809 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
810 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
811 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
812 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
813 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
814 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
815 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
816 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
817 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
818 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
819 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
820 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
821 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
822 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
823 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
824 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
827 "PRIMARY" => array("id"),
828 "guid" => array("guid"),
829 "uri" => array("uri"),
830 "parent" => array("parent"),
831 "parent-uri" => array("parent-uri"),
832 "extid" => array("extid"),
833 "uid_id" => array("uid","id"),
834 "uid_created" => array("uid","created"),
835 "uid_unseen" => array("uid","unseen"),
836 "uid_network_received" => array("uid","network","received"),
837 "uid_received" => array("uid","received"),
838 "uid_network_commented" => array("uid","network","commented"),
839 "uid_commented" => array("uid","commented"),
840 "uid_title" => array("uid","title"),
841 "uid_thrparent" => array("uid","thr-parent"),
842 "uid_parenturi" => array("uid","parent-uri"),
843 "uid_contactid_created" => array("uid","contact-id","created"),
844 "wall_body" => array("wall","body(6)"),
845 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
846 "uid_uri" => array("uid","uri"),
847 "uid_wall_created" => array("uid","wall","created"),
848 "resource-id" => array("resource-id"),
849 "uid_type" => array("uid","type"),
850 "uid_starred" => array("uid","starred"),
851 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
852 "uid_wall_parent_created" => array("uid","wall","parent","created"),
853 "uid_type_changed" => array("uid","type","changed"),
854 "contactid_verb" => array("contact-id","verb"),
855 "deleted_changed" => array("deleted","changed"),
856 "uid_wall_changed" => array("uid","wall","changed"),
857 "uid_eventid" => array("uid","event-id"),
858 "uid_authorlink" => array("uid","author-link"),
859 "uid_ownerlink" => array("uid","owner-link"),
862 $database["item_id"] = array(
864 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
865 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
866 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
867 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
868 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "PRIMARY" => array("id"),
872 "uid" => array("uid"),
873 "sid" => array("sid"),
874 "service" => array("service"),
875 "iid" => array("iid"),
878 $database["locks"] = array(
880 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
881 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
882 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
883 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
886 "PRIMARY" => array("id"),
889 $database["mail"] = array(
891 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
892 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
893 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
894 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
895 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
896 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
897 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
898 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
899 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
900 "body" => array("type" => "mediumtext", "not null" => "1"),
901 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
902 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
903 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
904 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
905 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
906 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
907 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
910 "PRIMARY" => array("id"),
911 "uid" => array("uid"),
912 "guid" => array("guid"),
913 "convid" => array("convid"),
914 "reply" => array("reply"),
915 "uri" => array("uri"),
916 "parent-uri" => array("parent-uri"),
919 $database["mailacct"] = array(
921 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
922 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
923 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
924 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
925 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
926 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
927 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
928 "pass" => array("type" => "text", "not null" => "1"),
929 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
930 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
931 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
932 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
933 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
936 "PRIMARY" => array("id"),
939 $database["manage"] = array(
941 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
942 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
943 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
946 "PRIMARY" => array("id"),
947 "uid_mid" => array("uid","mid"),
950 $database["notify"] = array(
952 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
953 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
954 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
955 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
956 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
957 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
958 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
959 "msg" => array("type" => "mediumtext", "not null" => "1"),
960 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
961 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
962 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
963 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
964 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
965 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
966 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
969 "PRIMARY" => array("id"),
970 "uid" => array("uid"),
973 $database["notify-threads"] = array(
975 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
976 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
977 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
978 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
979 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
982 "PRIMARY" => array("id"),
983 "master-parent-item" => array("master-parent-item"),
984 "receiver-uid" => array("receiver-uid"),
987 $database["pconfig"] = array(
989 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
990 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
991 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
992 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
993 "v" => array("type" => "mediumtext", "not null" => "1"),
996 "PRIMARY" => array("id"),
997 "uid_cat_k" => array("uid","cat(30)","k(30)"),
1000 $database["photo"] = array(
1002 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1003 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1004 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1005 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1006 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1007 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1008 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1009 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1010 "desc" => array("type" => "text", "not null" => "1"),
1011 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1012 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1013 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1014 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1015 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1016 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1017 "data" => array("type" => "mediumblob", "not null" => "1"),
1018 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1019 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1020 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1021 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1022 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1023 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1026 "PRIMARY" => array("id"),
1027 "uid" => array("uid"),
1028 "resource-id" => array("resource-id"),
1029 "guid" => array("guid"),
1032 $database["poll"] = array(
1034 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1035 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1036 "q0" => array("type" => "mediumtext", "not null" => "1"),
1037 "q1" => array("type" => "mediumtext", "not null" => "1"),
1038 "q2" => array("type" => "mediumtext", "not null" => "1"),
1039 "q3" => array("type" => "mediumtext", "not null" => "1"),
1040 "q4" => array("type" => "mediumtext", "not null" => "1"),
1041 "q5" => array("type" => "mediumtext", "not null" => "1"),
1042 "q6" => array("type" => "mediumtext", "not null" => "1"),
1043 "q7" => array("type" => "mediumtext", "not null" => "1"),
1044 "q8" => array("type" => "mediumtext", "not null" => "1"),
1045 "q9" => array("type" => "mediumtext", "not null" => "1"),
1048 "PRIMARY" => array("id"),
1049 "uid" => array("uid"),
1052 $database["poll_result"] = array(
1054 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1055 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1056 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1059 "PRIMARY" => array("id"),
1060 "poll_id" => array("poll_id"),
1061 "choice" => array("choice"),
1064 $database["profile"] = array(
1066 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1067 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1068 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1069 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1070 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1071 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1072 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1073 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1074 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1075 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1076 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1077 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1078 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1079 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1080 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1081 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1082 "with" => array("type" => "text", "not null" => "1"),
1083 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1084 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1085 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1086 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1087 "pub_keywords" => array("type" => "text", "not null" => "1"),
1088 "prv_keywords" => array("type" => "text", "not null" => "1"),
1089 "likes" => array("type" => "text", "not null" => "1"),
1090 "dislikes" => array("type" => "text", "not null" => "1"),
1091 "about" => array("type" => "text", "not null" => "1"),
1092 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "music" => array("type" => "text", "not null" => "1"),
1094 "book" => array("type" => "text", "not null" => "1"),
1095 "tv" => array("type" => "text", "not null" => "1"),
1096 "film" => array("type" => "text", "not null" => "1"),
1097 "interest" => array("type" => "text", "not null" => "1"),
1098 "romance" => array("type" => "text", "not null" => "1"),
1099 "work" => array("type" => "text", "not null" => "1"),
1100 "education" => array("type" => "text", "not null" => "1"),
1101 "contact" => array("type" => "text", "not null" => "1"),
1102 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1103 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1104 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1106 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1109 "PRIMARY" => array("id"),
1110 "hometown" => array("hometown"),
1113 $database["profile_check"] = array(
1115 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1116 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1117 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1118 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1119 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1120 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1123 "PRIMARY" => array("id"),
1126 $database["push_subscriber"] = array(
1128 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1129 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1130 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1131 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1132 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1133 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1134 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1135 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1138 "PRIMARY" => array("id"),
1141 $database["queue"] = array(
1143 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1144 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1145 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1146 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1147 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1148 "content" => array("type" => "mediumtext", "not null" => "1"),
1149 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1152 "PRIMARY" => array("id"),
1153 "cid" => array("cid"),
1154 "created" => array("created"),
1155 "last" => array("last"),
1156 "network" => array("network"),
1157 "batch" => array("batch"),
1160 $database["register"] = array(
1162 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1163 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1164 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1165 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1166 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1167 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1170 "PRIMARY" => array("id"),
1173 $database["search"] = array(
1175 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1176 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1177 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1180 "PRIMARY" => array("id"),
1181 "uid" => array("uid"),
1182 "term" => array("term"),
1185 $database["session"] = array(
1187 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1188 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1189 "data" => array("type" => "text", "not null" => "1"),
1190 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1193 "PRIMARY" => array("id"),
1194 "sid" => array("sid"),
1195 "expire" => array("expire"),
1198 $database["sign"] = array(
1200 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1201 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1202 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1203 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1204 "signature" => array("type" => "text", "not null" => "1"),
1205 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1208 "PRIMARY" => array("id"),
1209 "iid" => array("iid"),
1210 "retract_iid" => array("retract_iid"),
1213 $database["spam"] = array(
1215 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1216 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1217 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1218 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1219 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1220 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1223 "PRIMARY" => array("id"),
1224 "uid" => array("uid"),
1225 "spam" => array("spam"),
1226 "ham" => array("ham"),
1227 "term" => array("term"),
1230 $database["term"] = array(
1232 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1233 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1234 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1235 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1236 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1237 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1238 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1239 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1240 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1241 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1242 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1243 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1246 "PRIMARY" => array("tid"),
1247 "oid_otype_type_term" => array("oid","otype","type","term"),
1248 "uid_term_tid" => array("uid","term","tid"),
1249 "type_term" => array("type","term"),
1250 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1251 "otype_type_term_tid" => array("otype","type","term","tid"),
1252 "guid" => array("guid"),
1255 $database["thread"] = array(
1257 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1258 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1259 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1260 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1261 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1262 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1263 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1264 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1265 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1266 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1267 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1268 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1269 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1270 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1271 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1272 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1273 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1274 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1275 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1276 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1277 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1278 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1279 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1282 "PRIMARY" => array("iid"),
1283 "created" => array("created"),
1284 "commented" => array("commented"),
1285 "uid_network_commented" => array("uid","network","commented"),
1286 "uid_network_created" => array("uid","network","created"),
1287 "uid_contactid_commented" => array("uid","contact-id","commented"),
1288 "uid_contactid_created" => array("uid","contact-id","created"),
1289 "wall_private_received" => array("wall","private","received"),
1290 "uid_created" => array("uid","created"),
1291 "uid_commented" => array("uid","commented"),
1294 $database["tokens"] = array(
1296 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1297 "secret" => array("type" => "text", "not null" => "1"),
1298 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1299 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1300 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1301 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1304 "PRIMARY" => array("id"),
1307 $database["unique_contacts"] = array(
1309 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1310 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1311 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1312 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1313 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1314 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1315 "about" => array("type" => "text", "not null" => "1"),
1318 "PRIMARY" => array("id"),
1319 "url" => array("url"),
1322 $database["user"] = array(
1324 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1325 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1326 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1327 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1328 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1329 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1330 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1331 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1332 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1333 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1334 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1335 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1336 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1337 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1338 "pubkey" => array("type" => "text", "not null" => "1"),
1339 "prvkey" => array("type" => "text", "not null" => "1"),
1340 "spubkey" => array("type" => "text", "not null" => "1"),
1341 "sprvkey" => array("type" => "text", "not null" => "1"),
1342 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1343 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1344 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1345 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1346 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1347 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1348 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1349 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1350 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1351 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1352 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1353 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1354 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1355 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1356 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1357 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1358 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1359 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1360 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1361 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1362 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1363 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1364 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1365 "openidserver" => array("type" => "text", "not null" => "1"),
1368 "PRIMARY" => array("uid"),
1369 "nickname" => array("nickname"),
1372 $database["userd"] = array(
1374 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1375 "username" => array("type" => "varchar(255)", "not null" => "1"),
1378 "PRIMARY" => array("id"),
1379 "username" => array("username"),
1388 * run from command line
1390 function dbstructure_run(&$argv, &$argc) {
1398 @include(".htconfig.php");
1399 require_once("include/dba.php");
1400 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1401 unset($db_host, $db_user, $db_pass, $db_data);
1407 update_structure(true, true);
1410 print_structure(db_definition());
1417 echo $argv[0]." <command>\n";
1420 echo "update update database schema\n";
1421 echo "dumpsql dump database schema\n";
1429 if (array_search(__file__,get_included_files())===0){
1430 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);