Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1575 lines
74 KiB

  1. <?php
  2. require_once("boot.php");
  3. require_once("include/text.php");
  4. define('NEW_UPDATE_ROUTINE_VERSION', 1170);
  5. /*
  6. * send the email and do what is needed to do on update fails
  7. *
  8. * @param update_id (int) number of failed update
  9. * @param error_message (str) error message
  10. */
  11. function update_fail($update_id, $error_message){
  12. //send the administrators an e-mail
  13. $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
  14. $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
  15. $admin_mail_list
  16. );
  17. // every admin could had different language
  18. foreach ($adminlist as $admin) {
  19. $lang = (($admin['language'])?$admin['language']:'en');
  20. push_lang($lang);
  21. $preamble = deindent(t("
  22. The friendica developers released update %s recently,
  23. but when I tried to install it, something went terribly wrong.
  24. This needs to be fixed soon and I can't do it alone. Please contact a
  25. friendica developer if you can not help me on your own. My database might be invalid."));
  26. $body = t("The error message is\n[pre]%s[/pre]");
  27. $preamble = sprintf($preamble, $update_id);
  28. $body = sprintf($body, $error_message);
  29. notification(array(
  30. 'type' => "SYSTEM_EMAIL",
  31. 'to_email' => $admin['email'],
  32. 'preamble' => $preamble,
  33. 'body' => $body,
  34. 'language' => $lang,
  35. ));
  36. }
  37. /*
  38. $email_tpl = get_intltext_template("update_fail_eml.tpl");
  39. $email_msg = replace_macros($email_tpl, array(
  40. '$sitename' => $a->config['sitename'],
  41. '$siteurl' => $a->get_baseurl(),
  42. '$update' => DB_UPDATE_VERSION,
  43. '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
  44. ));
  45. $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
  46. require_once('include/email.php');
  47. $subject = email_header_encode($subject,'UTF-8');
  48. mail($a->config['admin_email'], $subject, $email_msg,
  49. 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
  50. .'Content-type: text/plain; charset=UTF-8'."\n"
  51. .'Content-transfer-encoding: 8bit');
  52. */
  53. //try the logger
  54. logger("CRITICAL: Database structure update failed: ".$retval);
  55. }
  56. function table_structure($table) {
  57. $structures = q("DESCRIBE `%s`", $table);
  58. $indexes = q("SHOW INDEX FROM `%s`", $table);
  59. $fielddata = array();
  60. $indexdata = array();
  61. if (is_array($indexes))
  62. foreach ($indexes AS $index) {
  63. if ($index["Index_type"] == "FULLTEXT")
  64. continue;
  65. if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
  66. $indexdata[$index["Key_name"]] = array('UNIQUE');
  67. }
  68. $column = $index["Column_name"];
  69. // On utf8mb4 a varchar index can only have a length of 191
  70. // To avoid the need to add this to every index definition we just ignore it here.
  71. // Exception are primary indexes
  72. // Since there are some combindex primary indexes we use the limit of 180 here.
  73. if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY")))
  74. $column .= "(".$index["Sub_part"].")";
  75. $indexdata[$index["Key_name"]][] = $column;
  76. }
  77. if (is_array($structures)) {
  78. foreach($structures AS $field) {
  79. $fielddata[$field["Field"]]["type"] = $field["Type"];
  80. if ($field["Null"] == "NO")
  81. $fielddata[$field["Field"]]["not null"] = true;
  82. if (isset($field["Default"]))
  83. $fielddata[$field["Field"]]["default"] = $field["Default"];
  84. if ($field["Extra"] != "")
  85. $fielddata[$field["Field"]]["extra"] = $field["Extra"];
  86. if ($field["Key"] == "PRI")
  87. $fielddata[$field["Field"]]["primary"] = true;
  88. }
  89. }
  90. return(array("fields"=>$fielddata, "indexes"=>$indexdata));
  91. }
  92. function print_structure($database, $charset) {
  93. echo "-- ------------------------------------------\n";
  94. echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
  95. echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
  96. echo "-- ------------------------------------------\n\n\n";
  97. foreach ($database AS $name => $structure) {
  98. echo "--\n";
  99. echo "-- TABLE $name\n";
  100. echo "--\n";
  101. db_create_table($name, $structure['fields'], $charset, true, false, $structure["indexes"]);
  102. echo "\n";
  103. }
  104. }
  105. function update_structure($verbose, $action, $tables=null, $definition=null) {
  106. global $a, $db;
  107. if ($action)
  108. set_config('system', 'maintenance', 1);
  109. if (isset($a->config["system"]["db_charset"]))
  110. $charset = $a->config["system"]["db_charset"];
  111. else
  112. $charset = "utf8";
  113. $errors = false;
  114. logger('updating structure', LOGGER_DEBUG);
  115. // Get the current structure
  116. $database = array();
  117. if (is_null($tables))
  118. $tables = q("show tables");
  119. foreach ($tables AS $table) {
  120. $table = current($table);
  121. $database[$table] = table_structure($table);
  122. }
  123. // Get the definition
  124. if (is_null($definition))
  125. $definition = db_definition($charset);
  126. // Ensure index conversion to unique removes duplicates
  127. $sql_config = "SET session old_alter_table=1;";
  128. if ($verbose)
  129. echo $sql_config."\n";
  130. if ($action)
  131. @$db->q($sql_config);
  132. // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
  133. if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
  134. !(strpos($db->server_info(), 'MariaDB') !== false)) {
  135. $ignore = '';
  136. }else {
  137. $ignore = ' IGNORE';
  138. }
  139. // Compare it
  140. foreach ($definition AS $name => $structure) {
  141. $is_new_table = False;
  142. $sql3="";
  143. if (!isset($database[$name])) {
  144. $r = db_create_table($name, $structure["fields"], $charset, $verbose, $action, $structure['indexes']);
  145. if(false === $r) {
  146. $errors .= t('Errors encountered creating database tables.').$name.EOL;
  147. }
  148. $is_new_table = True;
  149. } else {
  150. // Drop the index if it isn't present in the definition
  151. // or the definition differ from current status
  152. // and index name doesn't start with "local_"
  153. foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) {
  154. $current_index_definition = implode(",",$fieldnames);
  155. if (isset($structure["indexes"][$indexname])) {
  156. $new_index_definition = implode(",",$structure["indexes"][$indexname]);
  157. } else {
  158. $new_index_definition = "__NOT_SET__";
  159. }
  160. if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
  161. $sql2=db_drop_index($indexname);
  162. if ($sql3 == "")
  163. $sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2;
  164. else
  165. $sql3 .= ", ".$sql2;
  166. }
  167. }
  168. // Compare the field structure field by field
  169. foreach ($structure["fields"] AS $fieldname => $parameters) {
  170. if (!isset($database[$name]["fields"][$fieldname])) {
  171. $sql2=db_add_table_field($fieldname, $parameters);
  172. if ($sql3 == "")
  173. $sql3 = "ALTER TABLE `".$name."` ".$sql2;
  174. else
  175. $sql3 .= ", ".$sql2;
  176. } else {
  177. // Compare the field definition
  178. $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
  179. $new_field_definition = implode(",",$parameters);
  180. if ($current_field_definition != $new_field_definition) {
  181. $sql2=db_modify_table_field($fieldname, $parameters);
  182. if ($sql3 == "")
  183. $sql3 = "ALTER TABLE `".$name."` ".$sql2;
  184. else
  185. $sql3 .= ", ".$sql2;
  186. }
  187. }
  188. }
  189. }
  190. // Create the index if the index don't exists in database
  191. // or the definition differ from the current status.
  192. // Don't create keys if table is new
  193. if (!$is_new_table) {
  194. foreach ($structure["indexes"] AS $indexname => $fieldnames) {
  195. if (isset($database[$name]["indexes"][$indexname])) {
  196. $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
  197. } else {
  198. $current_index_definition = "__NOT_SET__";
  199. }
  200. $new_index_definition = implode(",",$fieldnames);
  201. if ($current_index_definition != $new_index_definition) {
  202. $sql2=db_create_index($indexname, $fieldnames);
  203. if ($sql2 != "") {
  204. if ($sql3 == "")
  205. $sql3 = "ALTER" . $ignore . " TABLE `".$name."` ".$sql2;
  206. else
  207. $sql3 .= ", ".$sql2;
  208. }
  209. }
  210. }
  211. }
  212. if ($sql3 != "") {
  213. $sql3 .= ";";
  214. if ($verbose)
  215. echo $sql3."\n";
  216. if ($action) {
  217. $r = @$db->q($sql3);
  218. if(false === $r)
  219. $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
  220. }
  221. }
  222. }
  223. if ($action)
  224. set_config('system', 'maintenance', 0);
  225. return $errors;
  226. }
  227. function db_field_command($parameters, $create = true) {
  228. $fieldstruct = $parameters["type"];
  229. if ($parameters["not null"])
  230. $fieldstruct .= " NOT NULL";
  231. if (isset($parameters["default"])){
  232. if (strpos(strtolower($parameters["type"]),"int")!==false) {
  233. $fieldstruct .= " DEFAULT ".$parameters["default"];
  234. } else {
  235. $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
  236. }
  237. }
  238. if ($parameters["extra"] != "")
  239. $fieldstruct .= " ".$parameters["extra"];
  240. /*if (($parameters["primary"] != "") AND $create)
  241. $fieldstruct .= " PRIMARY KEY";*/
  242. return($fieldstruct);
  243. }
  244. function db_create_table($name, $fields, $charset, $verbose, $action, $indexes=null) {
  245. global $a, $db;
  246. $r = true;
  247. $sql = "";
  248. $sql_rows = array();
  249. $primary_keys = array();
  250. foreach($fields AS $fieldname => $field) {
  251. $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
  252. if (x($field,'primary') and $field['primary']!=''){
  253. $primary_keys[] = $fieldname;
  254. }
  255. }
  256. if (!is_null($indexes)) {
  257. foreach ($indexes AS $indexname => $fieldnames) {
  258. $sql_index = db_create_index($indexname, $fieldnames, "");
  259. if (!is_null($sql_index)) $sql_rows[] = $sql_index;
  260. }
  261. }
  262. $sql = implode(",\n\t", $sql_rows);
  263. $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=".$charset;
  264. if ($verbose)
  265. echo $sql.";\n";
  266. if ($action)
  267. $r = @$db->q($sql);
  268. return $r;
  269. }
  270. function db_add_table_field($fieldname, $parameters) {
  271. $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
  272. return($sql);
  273. }
  274. function db_modify_table_field($fieldname, $parameters) {
  275. $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
  276. return($sql);
  277. }
  278. function db_drop_index($indexname) {
  279. $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
  280. return($sql);
  281. }
  282. function db_create_index($indexname, $fieldnames, $method="ADD") {
  283. $method = strtoupper(trim($method));
  284. if ($method!="" && $method!="ADD") {
  285. throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
  286. killme();
  287. }
  288. if ($fieldnames[0] == "UNIQUE") {
  289. array_shift($fieldnames);
  290. $method .= ' UNIQUE';
  291. }
  292. $names = "";
  293. foreach ($fieldnames AS $fieldname) {
  294. if ($names != "")
  295. $names .= ",";
  296. if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
  297. $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
  298. else
  299. $names .= "`".dbesc($fieldname)."`";
  300. }
  301. if ($indexname == "PRIMARY") {
  302. return sprintf("%s PRIMARY KEY(%s)", $method, $names);
  303. }
  304. $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
  305. return($sql);
  306. }
  307. function db_index_suffix($charset, $reduce = 0) {
  308. if ($charset != "utf8mb4")
  309. return "";
  310. // On utf8mb4 indexes can only have a length of 191
  311. $indexlength = 191 - $reduce;
  312. return "(".$indexlength.")";
  313. }
  314. function db_definition($charset) {
  315. $database = array();
  316. $database["addon"] = array(
  317. "fields" => array(
  318. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  319. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  320. "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  321. "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  322. "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  323. "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
  324. "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  325. ),
  326. "indexes" => array(
  327. "PRIMARY" => array("id"),
  328. )
  329. );
  330. $database["attach"] = array(
  331. "fields" => array(
  332. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  333. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  334. "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  335. "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  336. "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  337. "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  338. "data" => array("type" => "longblob", "not null" => "1"),
  339. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  340. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  341. "allow_cid" => array("type" => "mediumtext"),
  342. "allow_gid" => array("type" => "mediumtext"),
  343. "deny_cid" => array("type" => "mediumtext"),
  344. "deny_gid" => array("type" => "mediumtext"),
  345. ),
  346. "indexes" => array(
  347. "PRIMARY" => array("id"),
  348. )
  349. );
  350. $database["auth_codes"] = array(
  351. "fields" => array(
  352. "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
  353. "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
  354. "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
  355. "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  356. "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
  357. ),
  358. "indexes" => array(
  359. "PRIMARY" => array("id"),
  360. )
  361. );
  362. $database["cache"] = array(
  363. "fields" => array(
  364. "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
  365. "v" => array("type" => "text"),
  366. "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  367. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  368. ),
  369. "indexes" => array(
  370. "PRIMARY" => array("k".db_index_suffix($charset)),
  371. "updated" => array("updated"),
  372. "expire_mode_updated" => array("expire_mode", "updated"),
  373. )
  374. );
  375. $database["challenge"] = array(
  376. "fields" => array(
  377. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  378. "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  379. "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  380. "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  381. "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  382. "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  383. ),
  384. "indexes" => array(
  385. "PRIMARY" => array("id"),
  386. )
  387. );
  388. $database["clients"] = array(
  389. "fields" => array(
  390. "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
  391. "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
  392. "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
  393. "name" => array("type" => "text"),
  394. "icon" => array("type" => "text"),
  395. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  396. ),
  397. "indexes" => array(
  398. "PRIMARY" => array("client_id"),
  399. )
  400. );
  401. $database["config"] = array(
  402. "fields" => array(
  403. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  404. "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  405. "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  406. "v" => array("type" => "text"),
  407. ),
  408. "indexes" => array(
  409. "PRIMARY" => array("id"),
  410. "cat_k" => array("UNIQUE", "cat(30)","k(30)"),
  411. )
  412. );
  413. $database["contact"] = array(
  414. "fields" => array(
  415. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  416. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  417. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  418. "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  419. "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  420. "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  421. "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  422. "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  423. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  424. "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  425. "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  426. "about" => array("type" => "text"),
  427. "keywords" => array("type" => "text"),
  428. "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  429. "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  430. "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  431. "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  432. "photo" => array("type" => "text"),
  433. "thumb" => array("type" => "text"),
  434. "micro" => array("type" => "text"),
  435. "site-pubkey" => array("type" => "text"),
  436. "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  437. "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  438. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  439. "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  440. "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  441. "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  442. "pubkey" => array("type" => "text"),
  443. "prvkey" => array("type" => "text"),
  444. "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  445. "request" => array("type" => "text"),
  446. "notify" => array("type" => "text"),
  447. "poll" => array("type" => "text"),
  448. "confirm" => array("type" => "text"),
  449. "poco" => array("type" => "text"),
  450. "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  451. "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  452. "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  453. "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  454. "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  455. "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  456. "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  457. "failure_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  458. "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  459. "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  460. "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  461. "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  462. "last-item" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  463. "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
  464. "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  465. "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  466. "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  467. "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  468. "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  469. "contact-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  470. "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  471. "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  472. "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  473. "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  474. "reason" => array("type" => "text"),
  475. "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
  476. "info" => array("type" => "mediumtext"),
  477. "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  478. "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
  479. "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
  480. "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  481. "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  482. "ffi_keyword_blacklist" => array("type" => "mediumtext"),
  483. ),
  484. "indexes" => array(
  485. "PRIMARY" => array("id"),
  486. "uid" => array("uid"),
  487. "addr_uid" => array("addr", "uid"),
  488. "nurl" => array("nurl"),
  489. )
  490. );
  491. $database["conv"] = array(
  492. "fields" => array(
  493. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  494. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  495. "recips" => array("type" => "mediumtext"),
  496. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  497. "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  498. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  499. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  500. "subject" => array("type" => "mediumtext"),
  501. ),
  502. "indexes" => array(
  503. "PRIMARY" => array("id"),
  504. "uid" => array("uid"),
  505. )
  506. );
  507. $database["deliverq"] = array(
  508. "fields" => array(
  509. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  510. "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  511. "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  512. "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  513. ),
  514. "indexes" => array(
  515. "PRIMARY" => array("id"),
  516. "cmd_item_contact" => array("UNIQUE", "cmd", "item", "contact"),
  517. )
  518. );
  519. $database["event"] = array(
  520. "fields" => array(
  521. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  522. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  523. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  524. "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  525. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  526. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  527. "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  528. "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  529. "summary" => array("type" => "text"),
  530. "desc" => array("type" => "text"),
  531. "location" => array("type" => "text"),
  532. "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  533. "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  534. "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  535. "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  536. "allow_cid" => array("type" => "mediumtext"),
  537. "allow_gid" => array("type" => "mediumtext"),
  538. "deny_cid" => array("type" => "mediumtext"),
  539. "deny_gid" => array("type" => "mediumtext"),
  540. ),
  541. "indexes" => array(
  542. "PRIMARY" => array("id"),
  543. "uid" => array("uid"),
  544. )
  545. );
  546. $database["fcontact"] = array(
  547. "fields" => array(
  548. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  549. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  550. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  551. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  552. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  553. "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  554. "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  555. "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  556. "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  557. "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  558. "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  559. "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  560. "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  561. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  562. "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  563. "pubkey" => array("type" => "text"),
  564. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  565. ),
  566. "indexes" => array(
  567. "PRIMARY" => array("id"),
  568. "addr" => array("addr"),
  569. )
  570. );
  571. $database["ffinder"] = array(
  572. "fields" => array(
  573. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  574. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  575. "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  576. "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  577. ),
  578. "indexes" => array(
  579. "PRIMARY" => array("id"),
  580. )
  581. );
  582. $database["fserver"] = array(
  583. "fields" => array(
  584. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  585. "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  586. "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  587. "key" => array("type" => "text"),
  588. ),
  589. "indexes" => array(
  590. "PRIMARY" => array("id"),
  591. "server" => array("server"),
  592. )
  593. );
  594. $database["fsuggest"] = array(
  595. "fields" => array(
  596. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  597. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  598. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  599. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  600. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  601. "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  602. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  603. "note" => array("type" => "text"),
  604. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  605. ),
  606. "indexes" => array(
  607. "PRIMARY" => array("id"),
  608. )
  609. );
  610. $database["gcign"] = array(
  611. "fields" => array(
  612. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  613. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  614. "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  615. ),
  616. "indexes" => array(
  617. "PRIMARY" => array("id"),
  618. "uid" => array("uid"),
  619. "gcid" => array("gcid"),
  620. )
  621. );
  622. $database["gcontact"] = array(
  623. "fields" => array(
  624. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  625. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  626. "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  627. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  628. "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  629. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  630. "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  631. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  632. "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  633. "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  634. "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  635. "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  636. "about" => array("type" => "text"),
  637. "keywords" => array("type" => "text"),
  638. "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  639. "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
  640. "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  641. "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
  642. "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  643. "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  644. "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  645. "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  646. "notify" => array("type" => "text"),
  647. "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  648. "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
  649. "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  650. ),
  651. "indexes" => array(
  652. "PRIMARY" => array("id"),
  653. "nurl" => array("nurl"),
  654. "name" => array("name"),
  655. "nick" => array("nick"),
  656. "addr" => array("addr"),
  657. "updated" => array("updated"),
  658. )
  659. );
  660. $database["glink"] = array(
  661. "fields" => array(
  662. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  663. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  664. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  665. "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  666. "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  667. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  668. ),
  669. "indexes" => array(
  670. "PRIMARY" => array("id"),
  671. "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
  672. "gcid" => array("gcid"),
  673. "zcid" => array("zcid"),
  674. )
  675. );
  676. $database["group"] = array(
  677. "fields" => array(
  678. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  679. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  680. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  681. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  682. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  683. ),
  684. "indexes" => array(
  685. "PRIMARY" => array("id"),
  686. "uid" => array("uid"),
  687. )
  688. );
  689. $database["group_member"] = array(
  690. "fields" => array(
  691. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  692. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  693. "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  694. "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  695. ),
  696. "indexes" => array(
  697. "PRIMARY" => array("id"),
  698. "uid_gid_contactid" => array("uid","gid","contact-id"),
  699. )
  700. );
  701. $database["gserver"] = array(
  702. "fields" => array(
  703. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  704. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  705. "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  706. "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  707. "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  708. "info" => array("type" => "text"),
  709. "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  710. "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  711. "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  712. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  713. "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  714. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  715. "last_poco_query" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  716. "last_contact" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  717. "last_failure" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  718. ),
  719. "indexes" => array(
  720. "PRIMARY" => array("id"),
  721. "nurl" => array("nurl"),
  722. )
  723. );
  724. $database["hook"] = array(
  725. "fields" => array(
  726. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  727. "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  728. "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  729. "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  730. "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  731. ),
  732. "indexes" => array(
  733. "PRIMARY" => array("id"),
  734. "hook_file_function" => array("hook(30)","file(60)","function(30)"),
  735. )
  736. );
  737. $database["intro"] = array(
  738. "fields" => array(
  739. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  740. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  741. "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  742. "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  743. "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  744. "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  745. "note" => array("type" => "text"),
  746. "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  747. "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  748. "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  749. "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  750. ),
  751. "indexes" => array(
  752. "PRIMARY" => array("id"),
  753. )
  754. );
  755. $database["item"] = array(
  756. "fields" => array(
  757. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  758. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  759. "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  760. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  761. "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  762. "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  763. "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  764. "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  765. "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  766. "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  767. "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  768. "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  769. "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  770. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  771. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  772. "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  773. "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  774. "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  775. "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  776. "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  777. "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  778. "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  779. "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  780. "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  781. "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  782. "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  783. "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  784. "body" => array("type" => "mediumtext"),
  785. "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  786. "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  787. "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  788. "object" => array("type" => "text"),
  789. "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  790. "target" => array("type" => "text"),
  791. "postopts" => array("type" => "text"),
  792. "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  793. "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  794. "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  795. "tag" => array("type" => "mediumtext"),
  796. "attach" => array("type" => "mediumtext"),
  797. "inform" => array("type" => "mediumtext"),
  798. "file" => array("type" => "mediumtext"),
  799. "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  800. "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  801. "allow_cid" => array("type" => "mediumtext"),
  802. "allow_gid" => array("type" => "mediumtext"),
  803. "deny_cid" => array("type" => "mediumtext"),
  804. "deny_gid" => array("type" => "mediumtext"),
  805. "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  806. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  807. "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  808. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  809. "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  810. "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  811. "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  812. "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  813. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  814. "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  815. "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  816. "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
  817. "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  818. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  819. "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  820. "rendered-html" => array("type" => "mediumtext"),
  821. "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  822. ),
  823. "indexes" => array(
  824. "PRIMARY" => array("id"),
  825. "guid" => array("guid"),
  826. "uri" => array("uri"),
  827. "parent" => array("parent"),
  828. "parent-uri" => array("parent-uri"),
  829. "extid" => array("extid"),
  830. "uid_id" => array("uid","id"),
  831. "uid_created" => array("uid","created"),
  832. "uid_unseen_contactid" => array("uid","unseen","contact-id"),
  833. "uid_network_received" => array("uid","network","received"),
  834. "uid_received" => array("uid","received"),
  835. "uid_network_commented" => array("uid","network","commented"),
  836. "uid_commented" => array("uid","commented"),
  837. "uid_title" => array("uid","title"),
  838. "uid_thrparent" => array("uid","thr-parent"),
  839. "uid_parenturi" => array("uid","parent-uri"),
  840. "uid_contactid_id" => array("uid","contact-id","id"),
  841. "uid_contactid_created" => array("uid","contact-id","created"),
  842. "gcontactid_uid_created" => array("gcontact-id","uid","created"),
  843. "authorid_created" => array("author-id","created"),
  844. "ownerid_created" => array("owner-id","created"),
  845. "wall_body" => array("wall","body(6)"),
  846. "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
  847. "uid_uri" => array("uid", "uri"),
  848. "uid_wall_created" => array("uid","wall","created"),
  849. "resource-id" => array("resource-id"),
  850. "uid_type" => array("uid","type"),
  851. "uid_starred_id" => array("uid","starred", "id"),
  852. "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
  853. "uid_wall_parent_created" => array("uid","wall","parent","created"),
  854. "uid_type_changed" => array("uid","type","changed"),
  855. "contactid_verb" => array("contact-id","verb"),
  856. "deleted_changed" => array("deleted","changed"),
  857. "uid_wall_changed" => array("uid","wall","changed"),
  858. "uid_eventid" => array("uid","event-id"),
  859. "uid_authorlink" => array("uid","author-link"),
  860. "uid_ownerlink" => array("uid","owner-link"),
  861. )
  862. );
  863. $database["item_id"] = array(
  864. "fields" => array(
  865. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  866. "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  867. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  868. "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  869. "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  870. ),
  871. "indexes" => array(
  872. "PRIMARY" => array("id"),
  873. "uid" => array("uid"),
  874. "sid" => array("sid"),
  875. "service" => array("service"),
  876. "iid" => array("iid"),
  877. )
  878. );
  879. $database["locks"] = array(
  880. "fields" => array(
  881. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  882. "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
  883. "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  884. "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
  885. ),
  886. "indexes" => array(
  887. "PRIMARY" => array("id"),
  888. )
  889. );
  890. $database["mail"] = array(
  891. "fields" => array(
  892. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  893. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  894. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  895. "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  896. "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  897. "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  898. "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  899. "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  900. "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  901. "body" => array("type" => "mediumtext"),
  902. "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  903. "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  904. "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  905. "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  906. "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  907. "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  908. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  909. ),
  910. "indexes" => array(
  911. "PRIMARY" => array("id"),
  912. "uid" => array("uid"),
  913. "guid" => array("guid"),
  914. "convid" => array("convid"),
  915. "reply" => array("reply"),
  916. "uri" => array("uri"),
  917. "parent-uri" => array("parent-uri"),
  918. )
  919. );
  920. $database["mailacct"] = array(
  921. "fields" => array(
  922. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  923. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  924. "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  925. "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  926. "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
  927. "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  928. "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  929. "pass" => array("type" => "text"),
  930. "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  931. "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  932. "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  933. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  934. "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  935. ),
  936. "indexes" => array(
  937. "PRIMARY" => array("id"),
  938. )
  939. );
  940. $database["manage"] = array(
  941. "fields" => array(
  942. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  943. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  944. "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  945. ),
  946. "indexes" => array(
  947. "PRIMARY" => array("id"),
  948. "uid_mid" => array("uid","mid"),
  949. )
  950. );
  951. $database["notify"] = array(
  952. "fields" => array(
  953. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  954. "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  955. "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  956. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  957. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  958. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  959. "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  960. "msg" => array("type" => "mediumtext"),
  961. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  962. "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  963. "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  964. "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  965. "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  966. "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  967. "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
  968. "name_cache" => array("type" => "tinytext"),
  969. "msg_cache" => array("type" => "mediumtext")
  970. ),
  971. "indexes" => array(
  972. "PRIMARY" => array("id"),
  973. "uid" => array("uid"),
  974. )
  975. );
  976. $database["notify-threads"] = array(
  977. "fields" => array(
  978. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  979. "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  980. "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  981. "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  982. "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  983. ),
  984. "indexes" => array(
  985. "PRIMARY" => array("id"),
  986. "master-parent-item" => array("master-parent-item"),
  987. "receiver-uid" => array("receiver-uid"),
  988. )
  989. );
  990. $database["oembed"] = array(
  991. "fields" => array(
  992. "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
  993. "content" => array("type" => "text"),
  994. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  995. ),
  996. "indexes" => array(
  997. "PRIMARY" => array("url".db_index_suffix($charset)),
  998. "created" => array("created"),
  999. )
  1000. );
  1001. $database["parsed_url"] = array(
  1002. "fields" => array(
  1003. "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
  1004. "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
  1005. "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
  1006. "content" => array("type" => "text"),
  1007. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1008. ),
  1009. "indexes" => array(
  1010. "PRIMARY" => array("url".db_index_suffix($charset), "guessing", "oembed"),
  1011. "created" => array("created"),
  1012. )
  1013. );
  1014. $database["pconfig"] = array(
  1015. "fields" => array(
  1016. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment