3 use \Friendica\Core\Config;
5 require_once("boot.php");
6 require_once("include/text.php");
8 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
11 * send the email and do what is needed to do on update fails
13 * @param update_id (int) number of failed update
14 * @param error_message (str) error message
16 function update_fail($update_id, $error_message){
17 //send the administrators an e-mail
18 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
19 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
24 if (!dbm::is_result($adminlist)) {
25 logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
31 // every admin could had different language
32 foreach ($adminlist as $admin) {
33 $lang = (($admin['language'])?$admin['language']:'en');
36 $preamble = deindent(t("
37 The friendica developers released update %s recently,
38 but when I tried to install it, something went terribly wrong.
39 This needs to be fixed soon and I can't do it alone. Please contact a
40 friendica developer if you can not help me on your own. My database might be invalid."));
41 $body = t("The error message is\n[pre]%s[/pre]");
42 $preamble = sprintf($preamble, $update_id);
43 $body = sprintf($body, $error_message);
46 'type' => "SYSTEM_EMAIL",
47 'to_email' => $admin['email'],
48 'preamble' => $preamble,
58 $email_tpl = get_intltext_template("update_fail_eml.tpl");
59 $email_msg = replace_macros($email_tpl, array(
60 '$sitename' => $a->config['sitename'],
61 '$siteurl' => App::get_baseurl(),
62 '$update' => DB_UPDATE_VERSION,
63 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
65 $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
66 require_once('include/email.php');
67 $subject = email_header_encode($subject,'UTF-8');
68 mail($a->config['admin_email'], $subject, $email_msg,
69 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
70 .'Content-type: text/plain; charset=UTF-8'."\n"
71 .'Content-transfer-encoding: 8bit');
74 logger("CRITICAL: Database structure update failed: ".$retval);
78 function table_structure($table) {
79 $structures = q("DESCRIBE `%s`", $table);
81 $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
83 $indexes = q("SHOW INDEX FROM `%s`", $table);
85 $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
87 if (dbm::is_result($table_status)) {
88 $table_status = $table_status[0];
90 $table_status = array();
96 if (dbm::is_result($indexes))
97 foreach ($indexes AS $index) {
98 if ($index["Index_type"] == "FULLTEXT") {
102 if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
103 $indexdata[$index["Key_name"]] = array('UNIQUE');
106 $column = $index["Column_name"];
107 // On utf8mb4 a varchar index can only have a length of 191
108 // To avoid the need to add this to every index definition we just ignore it here.
109 // Exception are primary indexes
110 // Since there are some combindex primary indexes we use the limit of 180 here.
111 if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) {
112 $column .= "(".$index["Sub_part"].")";
115 $indexdata[$index["Key_name"]][] = $column;
117 if (dbm::is_result($structures)) {
118 foreach ($structures AS $field) {
119 $fielddata[$field["Field"]]["type"] = $field["Type"];
120 if ($field["Null"] == "NO") {
121 $fielddata[$field["Field"]]["not null"] = true;
124 if (isset($field["Default"])) {
125 $fielddata[$field["Field"]]["default"] = $field["Default"];
128 if ($field["Extra"] != "") {
129 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
132 if ($field["Key"] == "PRI") {
133 $fielddata[$field["Field"]]["primary"] = true;
137 if (dbm::is_result($full_columns)) {
138 foreach ($full_columns AS $column) {
139 $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
143 return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
146 function print_structure($database) {
147 echo "-- ------------------------------------------\n";
148 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
149 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
150 echo "-- ------------------------------------------\n\n\n";
151 foreach ($database AS $name => $structure) {
153 echo "-- TABLE $name\n";
155 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
161 function print_update_error($db, $message) {
162 echo sprintf(t("\nError %d occured during database update:\n%s\n"),
163 $db->errorno, $db->error);
165 return t('Errors encountered performing database changes: ').$message.EOL;
168 function update_structure($verbose, $action, $tables=null, $definition=null) {
172 Config::set('system', 'maintenance', 1);
173 Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
178 logger('updating structure', LOGGER_DEBUG);
180 // Get the current structure
183 if (is_null($tables)) {
184 $tables = q("SHOW TABLES");
187 if (dbm::is_result($tables)) {
188 foreach ($tables AS $table) {
189 $table = current($table);
191 logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
192 $database[$table] = table_structure($table);
196 // Get the definition
197 if (is_null($definition)) {
198 $definition = db_definition();
201 // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
202 if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
203 !(strpos($db->server_info(), 'MariaDB') !== false)) {
210 foreach ($definition AS $name => $structure) {
211 $is_new_table = False;
214 if (!isset($database[$name])) {
215 $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
216 if (!dbm::is_result($r)) {
217 $errors .= print_update_error($db, $name);
219 $is_new_table = True;
224 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
225 if (isset($database[$name]["indexes"][$indexname])) {
226 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
228 $current_index_definition = "__NOT_SET__";
230 $new_index_definition = implode(",",$fieldnames);
231 if ($current_index_definition != $new_index_definition) {
232 if ($fieldnames[0] == "UNIQUE") {
235 $temp_name = "temp-".$name;
242 * Drop the index if it isn't present in the definition
243 * or the definition differ from current status
244 * and index name doesn't start with "local_"
246 foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
247 $current_index_definition = implode(",",$fieldnames);
248 if (isset($structure["indexes"][$indexname])) {
249 $new_index_definition = implode(",",$structure["indexes"][$indexname]);
251 $new_index_definition = "__NOT_SET__";
253 if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
254 $sql2=db_drop_index($indexname);
256 $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
262 // Compare the field structure field by field
263 foreach ($structure["fields"] AS $fieldname => $parameters) {
264 if (!isset($database[$name]["fields"][$fieldname])) {
265 $sql2=db_add_table_field($fieldname, $parameters);
267 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
272 // Compare the field definition
273 $field_definition = $database[$name]["fields"][$fieldname];
275 // Define the default collation if not given
276 if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
277 $parameters['Collation'] = 'utf8mb4_general_ci';
279 $parameters['Collation'] = null;
282 $current_field_definition = implode(",", $field_definition);
283 $new_field_definition = implode(",", $parameters);
284 if ($current_field_definition != $new_field_definition) {
285 $sql2 = db_modify_table_field($fieldname, $parameters);
287 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
297 * Create the index if the index don't exists in database
298 * or the definition differ from the current status.
299 * Don't create keys if table is new
301 if (!$is_new_table) {
302 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
303 if (isset($database[$name]["indexes"][$indexname])) {
304 $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
306 $current_index_definition = "__NOT_SET__";
308 $new_index_definition = implode(",",$fieldnames);
309 if ($current_index_definition != $new_index_definition) {
310 $sql2 = db_create_index($indexname, $fieldnames);
312 // Fetch the "group by" fields for unique indexes
313 if ($fieldnames[0] == "UNIQUE") {
314 $group_by = db_group_by($indexname, $fieldnames);
318 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
326 if (isset($database[$name]["table_status"]["Collation"])) {
327 if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
328 $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
331 $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
342 // Ensure index conversion to unique removes duplicates
345 echo "SET session old_alter_table=1;\n";
347 echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
355 echo "SET session old_alter_table=0;\n";
357 echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
358 echo "DROP TABLE `".$name."`;\n";
359 echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
365 Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
367 // Ensure index conversion to unique removes duplicates
370 $db->q("SET session old_alter_table=1;");
372 $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
373 if (!dbm::is_result($r)) {
374 $errors .= print_update_error($db, $sql3);
381 if (!dbm::is_result($r)) {
382 $errors .= print_update_error($db, $sql3);
386 $db->q("SET session old_alter_table=0;");
388 $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
389 if (!dbm::is_result($r)) {
390 $errors .= print_update_error($db, $sql3);
393 $r = $db->q("DROP TABLE `".$name."`;");
394 if (!dbm::is_result($r)) {
395 $errors .= print_update_error($db, $sql3);
398 $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
399 if (!dbm::is_result($r)) {
400 $errors .= print_update_error($db, $sql3);
410 Config::set('system', 'maintenance', 0);
411 Config::set('system', 'maintenance_reason', '');
417 function db_field_command($parameters, $create = true) {
418 $fieldstruct = $parameters["type"];
420 if (!is_null($parameters["Collation"])) {
421 $fieldstruct .= " COLLATE ".$parameters["Collation"];
424 if ($parameters["not null"])
425 $fieldstruct .= " NOT NULL";
427 if (isset($parameters["default"])){
428 if (strpos(strtolower($parameters["type"]),"int")!==false) {
429 $fieldstruct .= " DEFAULT ".$parameters["default"];
431 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
434 if ($parameters["extra"] != "")
435 $fieldstruct .= " ".$parameters["extra"];
437 /*if (($parameters["primary"] != "") AND $create)
438 $fieldstruct .= " PRIMARY KEY";*/
440 return($fieldstruct);
443 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
451 $primary_keys = array();
452 foreach($fields AS $fieldname => $field) {
453 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
454 if (x($field,'primary') and $field['primary']!=''){
455 $primary_keys[] = $fieldname;
459 if (!is_null($indexes)) {
460 foreach ($indexes AS $indexname => $fieldnames) {
461 $sql_index = db_create_index($indexname, $fieldnames, "");
462 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
466 $sql = implode(",\n\t", $sql_rows);
468 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
478 function db_add_table_field($fieldname, $parameters) {
479 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
483 function db_modify_table_field($fieldname, $parameters) {
484 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
488 function db_drop_index($indexname) {
489 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
493 function db_create_index($indexname, $fieldnames, $method="ADD") {
495 $method = strtoupper(trim($method));
496 if ($method!="" && $method!="ADD") {
497 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
501 if ($fieldnames[0] == "UNIQUE") {
502 array_shift($fieldnames);
503 $method .= ' UNIQUE';
507 foreach ($fieldnames AS $fieldname) {
511 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
512 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
514 $names .= "`".dbesc($fieldname)."`";
518 if ($indexname == "PRIMARY") {
519 return sprintf("%s PRIMARY KEY(%s)", $method, $names);
523 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
527 function db_group_by($indexname, $fieldnames) {
529 if ($fieldnames[0] != "UNIQUE") {
533 array_shift($fieldnames);
536 foreach ($fieldnames AS $fieldname) {
540 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
541 $names .= "`".dbesc($matches[1])."`";
543 $names .= "`".dbesc($fieldname)."`";
547 $sql = sprintf(" GROUP BY %s", $names);
551 function db_definition() {
555 $database["addon"] = array(
557 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
558 "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
559 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
560 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
561 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
562 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
563 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
566 "PRIMARY" => array("id"),
567 "name" => array("UNIQUE", "name"),
570 $database["attach"] = array(
572 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
573 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
574 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
575 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
576 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
577 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
578 "data" => array("type" => "longblob", "not null" => "1"),
579 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
580 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
581 "allow_cid" => array("type" => "mediumtext"),
582 "allow_gid" => array("type" => "mediumtext"),
583 "deny_cid" => array("type" => "mediumtext"),
584 "deny_gid" => array("type" => "mediumtext"),
587 "PRIMARY" => array("id"),
590 $database["auth_codes"] = array(
592 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
593 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
594 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
595 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
596 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
599 "PRIMARY" => array("id"),
602 $database["cache"] = array(
604 "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
605 "v" => array("type" => "mediumtext"),
606 "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
607 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
610 "PRIMARY" => array("k"),
611 "expire_mode_updated" => array("expire_mode", "updated"),
614 $database["challenge"] = array(
616 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
617 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
618 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
619 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
620 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
621 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
624 "PRIMARY" => array("id"),
627 $database["clients"] = array(
629 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
630 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
631 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
632 "name" => array("type" => "text"),
633 "icon" => array("type" => "text"),
634 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
637 "PRIMARY" => array("client_id"),
640 $database["config"] = array(
642 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
643 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
644 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
645 "v" => array("type" => "mediumtext"),
648 "PRIMARY" => array("id"),
649 "cat_k" => array("UNIQUE", "cat", "k"),
652 $database["contact"] = array(
654 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
655 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
656 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
657 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
658 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
659 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
660 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
661 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
662 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
663 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
664 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
665 "about" => array("type" => "text"),
666 "keywords" => array("type" => "text"),
667 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
668 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
669 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
670 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
671 "photo" => array("type" => "text"),
672 "thumb" => array("type" => "text"),
673 "micro" => array("type" => "text"),
674 "site-pubkey" => array("type" => "text"),
675 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
676 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
677 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
678 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
679 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
680 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
681 "pubkey" => array("type" => "text"),
682 "prvkey" => array("type" => "text"),
683 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
684 "request" => array("type" => "text"),
685 "notify" => array("type" => "text"),
686 "poll" => array("type" => "text"),
687 "confirm" => array("type" => "text"),
688 "poco" => array("type" => "text"),
689 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
690 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
691 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
692 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
693 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
694 "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
695 "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
696 "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
697 "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
698 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
699 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
700 "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
701 "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
702 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
703 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
704 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
705 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
706 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
707 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
708 "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
709 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
710 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
711 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
712 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
713 "reason" => array("type" => "text"),
714 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
715 "info" => array("type" => "mediumtext"),
716 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
717 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
718 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
719 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
720 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
721 "ffi_keyword_blacklist" => array("type" => "text"),
724 "PRIMARY" => array("id"),
725 "uid_name" => array("uid", "name"),
726 "self_uid" => array("self", "uid"),
727 "alias_uid" => array("alias(32)", "uid"),
728 "pending_uid" => array("pending", "uid"),
729 "blocked_uid" => array("blocked", "uid"),
730 "uid_rel_network_poll" => array("uid", "rel", "network", "poll(64)", "archive"),
731 "uid_network_batch" => array("uid", "network", "batch(64)"),
732 "addr_uid" => array("addr(32)", "uid"),
733 "nurl_uid" => array("nurl(32)", "uid"),
734 "nick_uid" => array("nick(32)", "uid"),
735 "dfrn-id" => array("dfrn-id"),
736 "issued-id" => array("issued-id"),
739 $database["conv"] = array(
741 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
742 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
743 "recips" => array("type" => "text"),
744 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
745 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
747 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
748 "subject" => array("type" => "text"),
751 "PRIMARY" => array("id"),
752 "uid" => array("uid"),
755 $database["event"] = array(
757 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
758 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
760 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
761 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
762 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
763 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
764 "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
765 "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
766 "summary" => array("type" => "text"),
767 "desc" => array("type" => "text"),
768 "location" => array("type" => "text"),
769 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
770 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
771 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
772 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
773 "allow_cid" => array("type" => "mediumtext"),
774 "allow_gid" => array("type" => "mediumtext"),
775 "deny_cid" => array("type" => "mediumtext"),
776 "deny_gid" => array("type" => "mediumtext"),
779 "PRIMARY" => array("id"),
780 "uid_start" => array("uid", "start"),
783 $database["fcontact"] = array(
785 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
786 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
787 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
788 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
789 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
790 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
791 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
792 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
793 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
794 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
795 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
796 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
797 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
798 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
799 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
800 "pubkey" => array("type" => "text"),
801 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
804 "PRIMARY" => array("id"),
805 "addr" => array("addr(32)"),
806 "url" => array("url"),
809 $database["ffinder"] = array(
811 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
812 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
813 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
814 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
817 "PRIMARY" => array("id"),
820 $database["fserver"] = array(
822 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
823 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
824 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
825 "key" => array("type" => "text"),
828 "PRIMARY" => array("id"),
829 "server" => array("server(32)"),
832 $database["fsuggest"] = array(
834 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
835 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
836 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
837 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
838 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
839 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
840 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
841 "note" => array("type" => "text"),
842 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
845 "PRIMARY" => array("id"),
848 $database["gcign"] = array(
850 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
851 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
852 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
855 "PRIMARY" => array("id"),
856 "uid" => array("uid"),
857 "gcid" => array("gcid"),
860 $database["gcontact"] = array(
862 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
863 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
864 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
865 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
866 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
867 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
868 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
869 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
870 "updated" => array("type" => "datetime", "default" => NULL_DATE),
871 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
872 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
873 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
874 "about" => array("type" => "text"),
875 "keywords" => array("type" => "text"),
876 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
877 "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
878 "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
879 "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
880 "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
881 "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
882 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
883 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
884 "notify" => array("type" => "text"),
885 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
886 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
887 "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "PRIMARY" => array("id"),
891 "nurl" => array("nurl(64)"),
892 "name" => array("name(64)"),
893 "nick" => array("nick(32)"),
894 "addr" => array("addr(64)"),
895 "hide_network_updated" => array("hide", "network", "updated"),
896 "updated" => array("updated"),
899 $database["glink"] = array(
901 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
902 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
903 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
904 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
905 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
906 "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
909 "PRIMARY" => array("id"),
910 "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
911 "gcid" => array("gcid"),
914 $database["group"] = array(
916 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
917 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
918 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
919 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
920 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
923 "PRIMARY" => array("id"),
924 "uid" => array("uid"),
927 $database["group_member"] = array(
929 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
930 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
931 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
932 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
935 "PRIMARY" => array("id"),
936 "contactid" => array("contact-id"),
937 "gid_contactid" => array("gid", "contact-id"),
938 "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
941 $database["gserver"] = array(
943 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
944 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
945 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
946 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
947 "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
948 "info" => array("type" => "text"),
949 "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
950 "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
951 "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
952 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
953 "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
954 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
955 "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
956 "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
957 "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
960 "PRIMARY" => array("id"),
961 "nurl" => array("nurl(32)"),
964 $database["hook"] = array(
966 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
967 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
968 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
969 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
970 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
973 "PRIMARY" => array("id"),
974 "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
977 $database["intro"] = array(
979 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
980 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
981 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
982 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
983 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
984 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
985 "note" => array("type" => "text"),
986 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
987 "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
988 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
989 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
992 "PRIMARY" => array("id"),
995 $database["item"] = array(
997 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
998 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
999 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1000 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1001 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1002 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1003 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1004 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1005 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1006 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1007 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1008 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1009 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1010 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1011 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1012 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1013 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1014 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1015 "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1016 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1017 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1018 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1019 "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1020 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1021 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1022 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1023 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1024 "body" => array("type" => "mediumtext"),
1025 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1026 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1027 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1028 "object" => array("type" => "text"),
1029 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1030 "target" => array("type" => "text"),
1031 "postopts" => array("type" => "text"),
1032 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1033 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1034 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1035 "tag" => array("type" => "mediumtext"),
1036 "attach" => array("type" => "mediumtext"),
1037 "inform" => array("type" => "mediumtext"),
1038 "file" => array("type" => "mediumtext"),
1039 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1040 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "allow_cid" => array("type" => "mediumtext"),
1042 "allow_gid" => array("type" => "mediumtext"),
1043 "deny_cid" => array("type" => "mediumtext"),
1044 "deny_gid" => array("type" => "mediumtext"),
1045 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1046 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1047 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1048 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1049 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1050 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1051 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1052 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1053 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1054 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1055 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1056 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
1057 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1058 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1059 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1060 "rendered-html" => array("type" => "mediumtext"),
1061 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1064 "PRIMARY" => array("id"),
1065 "guid" => array("guid"),
1066 "uri" => array("uri"),
1067 "parent" => array("parent"),
1068 "parent-uri" => array("parent-uri"),
1069 "extid" => array("extid"),
1070 "uid_id" => array("uid","id"),
1071 "uid_contactid_id" => array("uid","contact-id","id"),
1072 "uid_created" => array("uid","created"),
1073 "uid_unseen_contactid" => array("uid","unseen","contact-id"),
1074 "uid_network_received" => array("uid","network","received"),
1075 "uid_network_commented" => array("uid","network","commented"),
1076 "uid_thrparent" => array("uid","thr-parent"),
1077 "uid_parenturi" => array("uid","parent-uri"),
1078 "uid_contactid_created" => array("uid","contact-id","created"),
1079 "authorid_created" => array("author-id","created"),
1080 "uid_uri" => array("uid", "uri"),
1081 "resource-id" => array("resource-id"),
1082 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
1083 "uid_type_changed" => array("uid","type","changed"),
1084 "contactid_verb" => array("contact-id","verb"),
1085 "deleted_changed" => array("deleted","changed"),
1086 "uid_wall_changed" => array("uid","wall","changed"),
1087 "uid_eventid" => array("uid","event-id"),
1088 "uid_authorlink" => array("uid","author-link"),
1089 "uid_ownerlink" => array("uid","owner-link"),
1092 $database["item_id"] = array(
1094 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1095 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1096 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1097 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1098 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1101 "PRIMARY" => array("id"),
1102 "uid" => array("uid"),
1103 "sid" => array("sid"),
1104 "service" => array("service(32)"),
1105 "iid" => array("iid"),
1108 $database["locks"] = array(
1110 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1111 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1112 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1113 "created" => array("type" => "datetime", "default" => NULL_DATE),
1116 "PRIMARY" => array("id"),
1119 $database["mail"] = array(
1121 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1122 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1123 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1124 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1125 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1126 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1127 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1128 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1129 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1130 "body" => array("type" => "mediumtext"),
1131 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1132 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1133 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1134 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1135 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1136 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1137 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1140 "PRIMARY" => array("id"),
1141 "uid_seen" => array("uid", "seen"),
1142 "convid" => array("convid"),
1143 "uri" => array("uri(64)"),
1144 "parent-uri" => array("parent-uri(64)"),
1147 $database["mailacct"] = 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 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1152 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1153 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1154 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1155 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1156 "pass" => array("type" => "text"),
1157 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1158 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1159 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1160 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1161 "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1164 "PRIMARY" => array("id"),
1167 $database["manage"] = array(
1169 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1170 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1171 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1174 "PRIMARY" => array("id"),
1175 "uid_mid" => array("UNIQUE", "uid","mid"),
1178 $database["notify"] = array(
1180 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1181 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1182 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1183 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1184 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1185 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1186 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1187 "msg" => array("type" => "mediumtext"),
1188 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1189 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1190 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1191 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1192 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1193 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1194 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1195 "name_cache" => array("type" => "tinytext"),
1196 "msg_cache" => array("type" => "mediumtext")
1199 "PRIMARY" => array("id"),
1200 "hash_uid" => array("hash", "uid"),
1201 "seen_uid_date" => array("seen", "uid", "date"),
1202 "uid_date" => array("uid", "date"),
1203 "uid_type_link" => array("uid", "type", "link"),
1206 $database["notify-threads"] = array(
1208 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1209 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1210 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1211 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1212 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1215 "PRIMARY" => array("id"),
1218 $database["oembed"] = array(
1220 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1221 "content" => array("type" => "mediumtext"),
1222 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1225 "PRIMARY" => array("url"),
1226 "created" => array("created"),
1229 $database["parsed_url"] = array(
1231 "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
1232 "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1233 "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
1234 "content" => array("type" => "mediumtext"),
1235 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1238 "PRIMARY" => array("url", "guessing", "oembed"),
1239 "created" => array("created"),
1242 $database["pconfig"] = array(
1244 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1245 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1246 "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1247 "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1248 "v" => array("type" => "mediumtext"),
1251 "PRIMARY" => array("id"),
1252 "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
1255 $database["photo"] = array(
1257 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1258 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1259 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1260 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1261 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1262 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1263 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1264 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1265 "desc" => array("type" => "text"),
1266 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1267 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1268 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
1269 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1270 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
1271 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1272 "data" => array("type" => "mediumblob", "not null" => "1"),
1273 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
1274 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1275 "allow_cid" => array("type" => "mediumtext"),
1276 "allow_gid" => array("type" => "mediumtext"),
1277 "deny_cid" => array("type" => "mediumtext"),
1278 "deny_gid" => array("type" => "mediumtext"),
1281 "PRIMARY" => array("id"),
1282 "uid_contactid" => array("uid", "contact-id"),
1283 "uid_profile" => array("uid", "profile"),
1284 "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
1285 "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
1286 "resource-id" => array("resource-id(64)"),
1289 $database["poll"] = array(
1291 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1292 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1293 "q0" => array("type" => "text"),
1294 "q1" => array("type" => "text"),
1295 "q2" => array("type" => "text"),
1296 "q3" => array("type" => "text"),
1297 "q4" => array("type" => "text"),
1298 "q5" => array("type" => "text"),
1299 "q6" => array("type" => "text"),
1300 "q7" => array("type" => "text"),
1301 "q8" => array("type" => "text"),
1302 "q9" => array("type" => "text"),
1305 "PRIMARY" => array("id"),
1306 "uid" => array("uid"),
1309 $database["poll_result"] = array(
1311 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1312 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1313 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1316 "PRIMARY" => array("id"),
1317 "poll_id" => array("poll_id"),
1318 "choice" => array("choice"),
1321 $database["process"] = array(
1323 "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
1324 "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
1325 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1328 "PRIMARY" => array("pid"),
1329 "command" => array("command"),
1332 $database["profile"] = array(
1334 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1335 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1336 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1337 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1338 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1339 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1340 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1341 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1342 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1343 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1344 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1345 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1346 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1347 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1348 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1349 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1350 "with" => array("type" => "text"),
1351 "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1352 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1353 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1354 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1355 "pub_keywords" => array("type" => "text"),
1356 "prv_keywords" => array("type" => "text"),
1357 "likes" => array("type" => "text"),
1358 "dislikes" => array("type" => "text"),
1359 "about" => array("type" => "text"),
1360 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1361 "music" => array("type" => "text"),
1362 "book" => array("type" => "text"),
1363 "tv" => array("type" => "text"),
1364 "film" => array("type" => "text"),
1365 "interest" => array("type" => "text"),
1366 "romance" => array("type" => "text"),
1367 "work" => array("type" => "text"),
1368 "education" => array("type" => "text"),
1369 "contact" => array("type" => "text"),
1370 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1371 "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1372 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1373 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1374 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1375 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1378 "PRIMARY" => array("id"),
1379 "uid_is-default" => array("uid", "is-default"),
1382 $database["profile_check"] = array(
1384 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1385 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1386 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1387 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1388 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1389 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1392 "PRIMARY" => array("id"),
1395 $database["push_subscriber"] = array(
1397 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1398 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1399 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1400 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1401 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1402 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1403 "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1404 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1407 "PRIMARY" => array("id"),
1410 $database["queue"] = array(
1412 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1413 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1414 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1415 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1416 "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1417 "content" => array("type" => "mediumtext"),
1418 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1421 "PRIMARY" => array("id"),
1422 "cid" => array("cid"),
1423 "created" => array("created"),
1424 "last" => array("last"),
1425 "network" => array("network"),
1426 "batch" => array("batch"),
1429 $database["register"] = array(
1431 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1432 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1433 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1434 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1435 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1436 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1437 "note" => array("type" => "text"),
1440 "PRIMARY" => array("id"),
1443 $database["search"] = array(
1445 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1446 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1447 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1450 "PRIMARY" => array("id"),
1451 "uid" => array("uid"),
1454 $database["session"] = array(
1456 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1457 "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
1458 "data" => array("type" => "text"),
1459 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1462 "PRIMARY" => array("id"),
1463 "sid" => array("sid(64)"),
1464 "expire" => array("expire"),
1467 $database["sign"] = array(
1469 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1470 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1471 "signed_text" => array("type" => "mediumtext"),
1472 "signature" => array("type" => "text"),
1473 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1476 "PRIMARY" => array("id"),
1477 "iid" => array("iid"),
1480 $database["spam"] = array(
1482 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1483 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1484 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1485 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1486 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1487 "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1490 "PRIMARY" => array("id"),
1491 "uid" => array("uid"),
1492 "spam" => array("spam"),
1493 "ham" => array("ham"),
1494 "term" => array("term"),
1497 $database["term"] = array(
1499 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1500 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1501 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1502 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1503 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1504 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1505 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1506 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1507 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1508 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1509 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1510 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1513 "PRIMARY" => array("tid"),
1514 "oid_otype_type_term" => array("oid","otype","type","term"),
1515 "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
1516 "uid_otype_type_url" => array("uid","otype","type","url(64)"),
1517 "guid" => array("guid(64)"),
1520 $database["thread"] = array(
1522 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1523 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1524 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1525 "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1526 "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1527 "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1528 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1529 "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1530 "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1531 "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1532 "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1533 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1534 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1535 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1536 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1537 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1538 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1539 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1540 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1541 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1542 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1543 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1544 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1545 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1546 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1547 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1550 "PRIMARY" => array("iid"),
1551 "uid_network_commented" => array("uid","network","commented"),
1552 "uid_network_created" => array("uid","network","created"),
1553 "uid_contactid_commented" => array("uid","contact-id","commented"),
1554 "uid_contactid_created" => array("uid","contact-id","created"),
1555 "uid_created" => array("uid","created"),
1556 "uid_commented" => array("uid","commented"),
1557 "uid_wall_created" => array("uid","wall","created"),
1560 $database["tokens"] = array(
1562 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1563 "secret" => array("type" => "text"),
1564 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1565 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1566 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1567 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1570 "PRIMARY" => array("id"),
1573 $database["user"] = array(
1575 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1576 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1577 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1578 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1579 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1580 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1581 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1582 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1583 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1584 "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1585 "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1586 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1587 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1588 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1589 "pubkey" => array("type" => "text"),
1590 "prvkey" => array("type" => "text"),
1591 "spubkey" => array("type" => "text"),
1592 "sprvkey" => array("type" => "text"),
1593 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1594 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1595 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1596 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1597 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1598 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1599 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1600 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1601 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1602 "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1603 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1604 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1605 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1606 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1607 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1608 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1609 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1610 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1611 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1612 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1613 "allow_cid" => array("type" => "mediumtext"),
1614 "allow_gid" => array("type" => "mediumtext"),
1615 "deny_cid" => array("type" => "mediumtext"),
1616 "deny_gid" => array("type" => "mediumtext"),
1617 "openidserver" => array("type" => "text"),
1620 "PRIMARY" => array("uid"),
1621 "nickname" => array("nickname(32)"),
1624 $database["userd"] = array(
1626 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1627 "username" => array("type" => "varchar(255)", "not null" => "1"),
1630 "PRIMARY" => array("id"),
1631 "username" => array("username(32)"),
1634 $database["workerqueue"] = array(
1636 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1637 "parameter" => array("type" => "text"),
1638 "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1639 "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1640 "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1641 "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
1644 "PRIMARY" => array("id"),
1653 * run from command line
1655 function dbstructure_run(&$argv, &$argc) {
1663 @include(".htconfig.php");
1664 require_once("include/dba.php");
1665 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1666 unset($db_host, $db_user, $db_pass, $db_data);
1672 update_structure(true, false);
1675 update_structure(true, true);
1677 $build = get_config('system','build');
1679 set_config('system','build',DB_UPDATE_VERSION);
1680 $build = DB_UPDATE_VERSION;
1683 $stored = intval($build);
1684 $current = intval(DB_UPDATE_VERSION);
1686 // run any left update_nnnn functions in update.php
1687 for($x = $stored; $x < $current; $x ++) {
1688 $r = run_update_function($x);
1692 set_config('system','build',DB_UPDATE_VERSION);
1695 print_structure(db_definition());
1702 echo $argv[0]." <command>\n";
1705 echo "dryrun show database update schema queries without running them\n";
1706 echo "update update database schema\n";
1707 echo "dumpsql dump database schema\n";
1712 if (array_search(__file__,get_included_files())===0){
1713 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);