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 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
630 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
631 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
632 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
633 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
634 "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
635 "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
636 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
637 "about" => array("type" => "text", "not null" => "1"),
638 "keywords" => array("type" => "text", "not null" => "1"),
639 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
640 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
641 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
644 "PRIMARY" => array("id"),
645 "nurl" => array("nurl"),
648 $database["glink"] = array(
650 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
651 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
652 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
653 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
654 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
655 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
658 "PRIMARY" => array("id"),
659 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
660 "gcid" => array("gcid"),
661 "zcid" => array("zcid"),
664 $database["group"] = array(
666 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
667 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
668 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
669 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
670 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
673 "PRIMARY" => array("id"),
674 "uid" => array("uid"),
677 $database["group_member"] = array(
679 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
680 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
681 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
682 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
685 "PRIMARY" => array("id"),
686 "uid_gid_contactid" => array("uid","gid","contact-id"),
689 $database["guid"] = array(
691 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
692 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
693 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
694 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
695 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
698 "PRIMARY" => array("id"),
699 "guid" => array("guid"),
700 "plink" => array("plink"),
701 "uri" => array("uri"),
704 $database["hook"] = array(
706 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
707 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
708 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
709 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
710 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
713 "PRIMARY" => array("id"),
714 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
717 $database["intro"] = array(
719 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
720 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
721 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
722 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
723 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
724 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
725 "note" => array("type" => "text", "not null" => "1"),
726 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
727 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
728 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
729 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
732 "PRIMARY" => array("id"),
735 $database["item"] = array(
737 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
738 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
739 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
740 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
741 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
742 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
743 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
744 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
745 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
746 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
750 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
751 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
752 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
753 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
754 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
755 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
757 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
758 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
761 "body" => array("type" => "mediumtext", "not null" => "1"),
762 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
763 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
764 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
765 "object" => array("type" => "text", "not null" => "1"),
766 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
767 "target" => array("type" => "text", "not null" => "1"),
768 "postopts" => array("type" => "text", "not null" => "1"),
769 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
770 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
771 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
772 "tag" => array("type" => "mediumtext", "not null" => "1"),
773 "attach" => array("type" => "mediumtext", "not null" => "1"),
774 "inform" => array("type" => "mediumtext", "not null" => "1"),
775 "file" => array("type" => "mediumtext", "not null" => "1"),
776 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
777 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
778 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
779 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
780 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
781 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
782 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
783 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
784 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
785 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
786 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
787 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
788 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
789 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
790 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
791 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
792 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
793 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
794 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
795 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
796 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
797 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
798 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
801 "PRIMARY" => array("id"),
802 "guid" => array("guid"),
803 "uri" => array("uri"),
804 "parent" => array("parent"),
805 "parent-uri" => array("parent-uri"),
806 "extid" => array("extid"),
807 "uid_id" => array("uid","id"),
808 "uid_created" => array("uid","created"),
809 "uid_unseen" => array("uid","unseen"),
810 "uid_network_received" => array("uid","network","received"),
811 "uid_received" => array("uid","received"),
812 "uid_network_commented" => array("uid","network","commented"),
813 "uid_commented" => array("uid","commented"),
814 "uid_title" => array("uid","title"),
815 "uid_thrparent" => array("uid","thr-parent"),
816 "uid_parenturi" => array("uid","parent-uri"),
817 "uid_contactid_created" => array("uid","contact-id","created"),
818 "wall_body" => array("wall","body(6)"),
819 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
820 "uid_uri" => array("uid","uri"),
821 "uid_wall_created" => array("uid","wall","created"),
822 "resource-id" => array("resource-id"),
823 "uid_type" => array("uid","type"),
824 "uid_starred" => array("uid","starred"),
825 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
826 "uid_wall_parent_created" => array("uid","wall","parent","created"),
827 "uid_type_changed" => array("uid","type","changed"),
828 "contactid_verb" => array("contact-id","verb"),
829 "deleted_changed" => array("deleted","changed"),
830 "uid_wall_changed" => array("uid","wall","changed"),
831 "uid_eventid" => array("uid","event-id"),
832 "uid_authorlink" => array("uid","author-link"),
833 "uid_ownerlink" => array("uid","owner-link"),
836 $database["item_id"] = array(
838 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
839 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
840 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
841 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
842 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
845 "PRIMARY" => array("id"),
846 "uid" => array("uid"),
847 "sid" => array("sid"),
848 "service" => array("service"),
849 "iid" => array("iid"),
852 $database["locks"] = array(
854 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
855 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
856 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
857 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
860 "PRIMARY" => array("id"),
863 $database["mail"] = array(
865 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
866 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
867 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
868 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
869 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
871 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
872 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
873 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "body" => array("type" => "mediumtext", "not null" => "1"),
875 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
876 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
877 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
878 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
879 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
880 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
881 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
884 "PRIMARY" => array("id"),
885 "uid" => array("uid"),
886 "guid" => array("guid"),
887 "convid" => array("convid"),
888 "reply" => array("reply"),
889 "uri" => array("uri"),
890 "parent-uri" => array("parent-uri"),
893 $database["mailacct"] = array(
895 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
896 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
897 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
898 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
899 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
900 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
901 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
902 "pass" => array("type" => "text", "not null" => "1"),
903 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
904 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
905 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
906 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
907 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
910 "PRIMARY" => array("id"),
913 $database["manage"] = array(
915 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
916 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
917 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
920 "PRIMARY" => array("id"),
921 "uid_mid" => array("uid","mid"),
924 $database["notify"] = array(
926 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
927 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
928 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
929 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
930 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
931 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
932 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
933 "msg" => array("type" => "mediumtext", "not null" => "1"),
934 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
935 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
936 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
937 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
938 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
939 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
940 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
943 "PRIMARY" => array("id"),
944 "uid" => array("uid"),
947 $database["notify-threads"] = array(
949 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
950 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
951 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
952 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
953 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
956 "PRIMARY" => array("id"),
957 "master-parent-item" => array("master-parent-item"),
958 "receiver-uid" => array("receiver-uid"),
961 $database["pconfig"] = array(
963 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
964 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
965 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
966 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
967 "v" => array("type" => "mediumtext", "not null" => "1"),
970 "PRIMARY" => array("id"),
971 "uid_cat_k" => array("uid","cat(30)","k(30)"),
974 $database["photo"] = array(
976 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
977 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
978 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
979 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
980 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
981 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
982 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
983 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
984 "desc" => array("type" => "text", "not null" => "1"),
985 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
986 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
987 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
988 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
989 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
990 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
991 "data" => array("type" => "mediumblob", "not null" => "1"),
992 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
993 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
994 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
995 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
996 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
997 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1000 "PRIMARY" => array("id"),
1001 "uid" => array("uid"),
1002 "resource-id" => array("resource-id"),
1003 "guid" => array("guid"),
1006 $database["poll"] = array(
1008 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1009 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1010 "q0" => array("type" => "mediumtext", "not null" => "1"),
1011 "q1" => array("type" => "mediumtext", "not null" => "1"),
1012 "q2" => array("type" => "mediumtext", "not null" => "1"),
1013 "q3" => array("type" => "mediumtext", "not null" => "1"),
1014 "q4" => array("type" => "mediumtext", "not null" => "1"),
1015 "q5" => array("type" => "mediumtext", "not null" => "1"),
1016 "q6" => array("type" => "mediumtext", "not null" => "1"),
1017 "q7" => array("type" => "mediumtext", "not null" => "1"),
1018 "q8" => array("type" => "mediumtext", "not null" => "1"),
1019 "q9" => array("type" => "mediumtext", "not null" => "1"),
1022 "PRIMARY" => array("id"),
1023 "uid" => array("uid"),
1026 $database["poll_result"] = array(
1028 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1029 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1030 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1033 "PRIMARY" => array("id"),
1034 "poll_id" => array("poll_id"),
1035 "choice" => array("choice"),
1038 $database["profile"] = array(
1040 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1041 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1042 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1043 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1044 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1045 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1046 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1048 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1050 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1051 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1052 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1053 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1054 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1055 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1056 "with" => array("type" => "text", "not null" => "1"),
1057 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1058 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1059 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1060 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1061 "pub_keywords" => array("type" => "text", "not null" => "1"),
1062 "prv_keywords" => array("type" => "text", "not null" => "1"),
1063 "likes" => array("type" => "text", "not null" => "1"),
1064 "dislikes" => array("type" => "text", "not null" => "1"),
1065 "about" => array("type" => "text", "not null" => "1"),
1066 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1067 "music" => array("type" => "text", "not null" => "1"),
1068 "book" => array("type" => "text", "not null" => "1"),
1069 "tv" => array("type" => "text", "not null" => "1"),
1070 "film" => array("type" => "text", "not null" => "1"),
1071 "interest" => array("type" => "text", "not null" => "1"),
1072 "romance" => array("type" => "text", "not null" => "1"),
1073 "work" => array("type" => "text", "not null" => "1"),
1074 "education" => array("type" => "text", "not null" => "1"),
1075 "contact" => array("type" => "text", "not null" => "1"),
1076 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1077 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1078 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1079 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1080 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1083 "PRIMARY" => array("id"),
1084 "hometown" => array("hometown"),
1087 $database["profile_check"] = array(
1089 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1090 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1091 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1092 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1097 "PRIMARY" => array("id"),
1100 $database["push_subscriber"] = array(
1102 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1103 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1104 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1105 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1106 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1107 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1108 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1109 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1112 "PRIMARY" => array("id"),
1115 $database["queue"] = array(
1117 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1118 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1119 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1120 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1121 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1122 "content" => array("type" => "mediumtext", "not null" => "1"),
1123 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1126 "PRIMARY" => array("id"),
1127 "cid" => array("cid"),
1128 "created" => array("created"),
1129 "last" => array("last"),
1130 "network" => array("network"),
1131 "batch" => array("batch"),
1134 $database["register"] = array(
1136 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1137 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1138 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1139 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1140 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1141 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1144 "PRIMARY" => array("id"),
1147 $database["search"] = array(
1149 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1150 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1151 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1154 "PRIMARY" => array("id"),
1155 "uid" => array("uid"),
1156 "term" => array("term"),
1159 $database["session"] = array(
1161 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1162 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1163 "data" => array("type" => "text", "not null" => "1"),
1164 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1167 "PRIMARY" => array("id"),
1168 "sid" => array("sid"),
1169 "expire" => array("expire"),
1172 $database["sign"] = array(
1174 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1175 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1176 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1177 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1178 "signature" => array("type" => "text", "not null" => "1"),
1179 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1182 "PRIMARY" => array("id"),
1183 "iid" => array("iid"),
1184 "retract_iid" => array("retract_iid"),
1187 $database["spam"] = array(
1189 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1190 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1191 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1192 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1193 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1194 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1197 "PRIMARY" => array("id"),
1198 "uid" => array("uid"),
1199 "spam" => array("spam"),
1200 "ham" => array("ham"),
1201 "term" => array("term"),
1204 $database["term"] = array(
1206 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1207 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1208 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1209 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1210 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1211 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1212 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1213 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1214 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1215 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1216 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1217 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1220 "PRIMARY" => array("tid"),
1221 "oid_otype_type_term" => array("oid","otype","type","term"),
1222 "uid_term_tid" => array("uid","term","tid"),
1223 "type_term" => array("type","term"),
1224 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1225 "otype_type_term_tid" => array("otype","type","term","tid"),
1226 "guid" => array("guid"),
1229 $database["thread"] = array(
1231 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1232 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1233 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1234 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1235 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1236 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1237 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1238 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1239 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1240 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1241 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1242 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1243 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1244 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1245 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1246 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1247 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1248 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1249 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1250 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1251 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1252 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1253 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1256 "PRIMARY" => array("iid"),
1257 "created" => array("created"),
1258 "commented" => array("commented"),
1259 "uid_network_commented" => array("uid","network","commented"),
1260 "uid_network_created" => array("uid","network","created"),
1261 "uid_contactid_commented" => array("uid","contact-id","commented"),
1262 "uid_contactid_created" => array("uid","contact-id","created"),
1263 "wall_private_received" => array("wall","private","received"),
1264 "uid_created" => array("uid","created"),
1265 "uid_commented" => array("uid","commented"),
1268 $database["tokens"] = array(
1270 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1271 "secret" => array("type" => "text", "not null" => "1"),
1272 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1273 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1274 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1275 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1278 "PRIMARY" => array("id"),
1281 $database["unique_contacts"] = array(
1283 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1284 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1285 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1286 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1287 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1288 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1289 "about" => array("type" => "text", "not null" => "1"),
1292 "PRIMARY" => array("id"),
1293 "url" => array("url"),
1296 $database["user"] = array(
1298 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1299 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1300 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1301 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1302 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1303 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1304 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1305 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1306 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1307 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1308 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1309 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1310 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1311 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1312 "pubkey" => array("type" => "text", "not null" => "1"),
1313 "prvkey" => array("type" => "text", "not null" => "1"),
1314 "spubkey" => array("type" => "text", "not null" => "1"),
1315 "sprvkey" => array("type" => "text", "not null" => "1"),
1316 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1317 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1318 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1319 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1320 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1321 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1322 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1323 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1324 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1325 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1326 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1327 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1328 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1329 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1330 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1331 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1332 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1333 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1334 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1335 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1336 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1337 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1338 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1339 "openidserver" => array("type" => "text", "not null" => "1"),
1342 "PRIMARY" => array("uid"),
1343 "nickname" => array("nickname"),
1346 $database["userd"] = array(
1348 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1349 "username" => array("type" => "varchar(255)", "not null" => "1"),
1352 "PRIMARY" => array("id"),
1353 "username" => array("username"),
1362 * run from command line
1364 function dbstructure_run(&$argv, &$argc) {
1372 @include(".htconfig.php");
1373 require_once("include/dba.php");
1374 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1375 unset($db_host, $db_user, $db_pass, $db_data);
1381 update_structure(true, true);
1384 print_structure(db_definition());
1391 echo $argv[0]." <command>\n";
1394 echo "update update database schema\n";
1395 echo "dumpsql dump database schema\n";
1403 if (array_search(__file__,get_included_files())===0){
1404 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);