Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

1799 linhas
83KB

  1. <?php
  2. use Friendica\Core\Config;
  3. require_once("boot.php");
  4. require_once("include/text.php");
  5. define('NEW_UPDATE_ROUTINE_VERSION', 1170);
  6. /*
  7. * Converts all tables from MyISAM to InnoDB
  8. */
  9. function convert_to_innodb() {
  10. global $db;
  11. $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
  12. dbesc($db->database_name()));
  13. if (!dbm::is_result($r)) {
  14. echo t('There are no tables on MyISAM.')."\n";
  15. return;
  16. }
  17. foreach ($r AS $table) {
  18. $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
  19. echo $sql."\n";
  20. $result = @$db->q($sql);
  21. if (!dbm::is_result($result)) {
  22. print_update_error($db, $sql);
  23. }
  24. }
  25. }
  26. /*
  27. * send the email and do what is needed to do on update fails
  28. *
  29. * @param update_id (int) number of failed update
  30. * @param error_message (str) error message
  31. */
  32. function update_fail($update_id, $error_message) {
  33. //send the administrators an e-mail
  34. $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
  35. $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
  36. $admin_mail_list
  37. );
  38. // No valid result?
  39. if (!dbm::is_result($adminlist)) {
  40. logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
  41. // Don't continue
  42. return;
  43. }
  44. // every admin could had different language
  45. foreach ($adminlist as $admin) {
  46. $lang = (($admin['language'])?$admin['language']:'en');
  47. push_lang($lang);
  48. $preamble = deindent(t("
  49. The friendica developers released update %s recently,
  50. but when I tried to install it, something went terribly wrong.
  51. This needs to be fixed soon and I can't do it alone. Please contact a
  52. friendica developer if you can not help me on your own. My database might be invalid."));
  53. $body = t("The error message is\n[pre]%s[/pre]");
  54. $preamble = sprintf($preamble, $update_id);
  55. $body = sprintf($body, $error_message);
  56. notification(array(
  57. 'type' => "SYSTEM_EMAIL",
  58. 'to_email' => $admin['email'],
  59. 'preamble' => $preamble,
  60. 'body' => $body,
  61. 'language' => $lang,
  62. ));
  63. }
  64. /*
  65. $email_tpl = get_intltext_template("update_fail_eml.tpl");
  66. $email_msg = replace_macros($email_tpl, array(
  67. '$sitename' => $a->config['sitename'],
  68. '$siteurl' => App::get_baseurl(),
  69. '$update' => DB_UPDATE_VERSION,
  70. '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
  71. ));
  72. $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
  73. require_once('include/email.php');
  74. $subject = email_header_encode($subject,'UTF-8');
  75. mail($a->config['admin_email'], $subject, $email_msg,
  76. 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
  77. .'Content-type: text/plain; charset=UTF-8'."\n"
  78. .'Content-transfer-encoding: 8bit');
  79. */
  80. //try the logger
  81. logger("CRITICAL: Database structure update failed: ".$retval);
  82. }
  83. function table_structure($table) {
  84. $structures = q("DESCRIBE `%s`", $table);
  85. $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
  86. $indexes = q("SHOW INDEX FROM `%s`", $table);
  87. $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
  88. if (dbm::is_result($table_status)) {
  89. $table_status = $table_status[0];
  90. } else {
  91. $table_status = array();
  92. }
  93. $fielddata = array();
  94. $indexdata = array();
  95. if (dbm::is_result($indexes))
  96. foreach ($indexes AS $index) {
  97. if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
  98. $indexdata[$index["Key_name"]] = array('UNIQUE');
  99. }
  100. $column = $index["Column_name"];
  101. // On utf8mb4 a varchar index can only have a length of 191
  102. // The "show index" command sometimes returns this value although this value wasn't added manually.
  103. // Because we don't want to add this number to every index, we ignore bigger numbers
  104. if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 191) OR ($index["Key_name"] == "PRIMARY"))) {
  105. $column .= "(".$index["Sub_part"].")";
  106. }
  107. $indexdata[$index["Key_name"]][] = $column;
  108. }
  109. if (dbm::is_result($structures)) {
  110. foreach ($structures AS $field) {
  111. $fielddata[$field["Field"]]["type"] = $field["Type"];
  112. if ($field["Null"] == "NO") {
  113. $fielddata[$field["Field"]]["not null"] = true;
  114. }
  115. if (isset($field["Default"])) {
  116. $fielddata[$field["Field"]]["default"] = $field["Default"];
  117. }
  118. if ($field["Extra"] != "") {
  119. $fielddata[$field["Field"]]["extra"] = $field["Extra"];
  120. }
  121. if ($field["Key"] == "PRI") {
  122. $fielddata[$field["Field"]]["primary"] = true;
  123. }
  124. }
  125. }
  126. if (dbm::is_result($full_columns)) {
  127. foreach ($full_columns AS $column) {
  128. $fielddata[$column["Field"]]["Collation"] = $column["Collation"];
  129. }
  130. }
  131. return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
  132. }
  133. function print_structure($database) {
  134. echo "-- ------------------------------------------\n";
  135. echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
  136. echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
  137. echo "-- ------------------------------------------\n\n\n";
  138. foreach ($database AS $name => $structure) {
  139. echo "--\n";
  140. echo "-- TABLE $name\n";
  141. echo "--\n";
  142. db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
  143. echo "\n";
  144. }
  145. }
  146. /**
  147. * @brief Print out database error messages
  148. *
  149. * @param object $db Database object
  150. * @param string $message Message to be added to the error message
  151. *
  152. * @return string Error message
  153. */
  154. function print_update_error($db, $message) {
  155. echo sprintf(t("\nError %d occurred during database update:\n%s\n"),
  156. $db->errorno, $db->error);
  157. return t('Errors encountered performing database changes: ').$message.EOL;
  158. }
  159. function update_structure($verbose, $action, $tables=null, $definition=null) {
  160. global $a, $db;
  161. if ($action) {
  162. Config::set('system', 'maintenance', 1);
  163. Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
  164. }
  165. $errors = false;
  166. logger('updating structure', LOGGER_DEBUG);
  167. // Get the current structure
  168. $database = array();
  169. if (is_null($tables)) {
  170. $tables = q("SHOW TABLES");
  171. }
  172. if (dbm::is_result($tables)) {
  173. foreach ($tables AS $table) {
  174. $table = current($table);
  175. logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
  176. $database[$table] = table_structure($table);
  177. }
  178. }
  179. // Get the definition
  180. if (is_null($definition)) {
  181. $definition = db_definition();
  182. }
  183. // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
  184. if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
  185. !(strpos($db->server_info(), 'MariaDB') !== false)) {
  186. $ignore = '';
  187. } else {
  188. $ignore = ' IGNORE';
  189. }
  190. // Compare it
  191. foreach ($definition AS $name => $structure) {
  192. $is_new_table = False;
  193. $group_by = "";
  194. $sql3 = "";
  195. if (!isset($database[$name])) {
  196. $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
  197. if (!dbm::is_result($r)) {
  198. $errors .= print_update_error($db, $name);
  199. }
  200. $is_new_table = True;
  201. } else {
  202. $is_unique = false;
  203. $temp_name = $name;
  204. foreach ($structure["indexes"] AS $indexname => $fieldnames) {
  205. if (isset($database[$name]["indexes"][$indexname])) {
  206. $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
  207. } else {
  208. $current_index_definition = "__NOT_SET__";
  209. }
  210. $new_index_definition = implode(",",$fieldnames);
  211. if ($current_index_definition != $new_index_definition) {
  212. if ($fieldnames[0] == "UNIQUE") {
  213. $is_unique = true;
  214. if ($ignore == "") {
  215. $temp_name = "temp-".$name;
  216. }
  217. }
  218. }
  219. }
  220. /*
  221. * Drop the index if it isn't present in the definition
  222. * or the definition differ from current status
  223. * and index name doesn't start with "local_"
  224. */
  225. foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
  226. $current_index_definition = implode(",",$fieldnames);
  227. if (isset($structure["indexes"][$indexname])) {
  228. $new_index_definition = implode(",",$structure["indexes"][$indexname]);
  229. } else {
  230. $new_index_definition = "__NOT_SET__";
  231. }
  232. if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
  233. $sql2=db_drop_index($indexname);
  234. if ($sql3 == "") {
  235. $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2;
  236. } else {
  237. $sql3 .= ", ".$sql2;
  238. }
  239. }
  240. }
  241. // Compare the field structure field by field
  242. foreach ($structure["fields"] AS $fieldname => $parameters) {
  243. if (!isset($database[$name]["fields"][$fieldname])) {
  244. $sql2=db_add_table_field($fieldname, $parameters);
  245. if ($sql3 == "") {
  246. $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
  247. } else {
  248. $sql3 .= ", ".$sql2;
  249. }
  250. } else {
  251. // Compare the field definition
  252. $field_definition = $database[$name]["fields"][$fieldname];
  253. // Remove the relation data that is used for the referential integrity
  254. unset($parameters['relation']);
  255. // We change the collation after the indexes had been changed.
  256. // This is done to avoid index length problems.
  257. // So here we always ensure that there is no need to change it.
  258. unset($parameters['Collation']);
  259. unset($field_definition['Collation']);
  260. $current_field_definition = implode(",", $field_definition);
  261. $new_field_definition = implode(",", $parameters);
  262. if ($current_field_definition != $new_field_definition) {
  263. $sql2 = db_modify_table_field($fieldname, $parameters);
  264. if ($sql3 == "") {
  265. $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
  266. } else {
  267. $sql3 .= ", ".$sql2;
  268. }
  269. }
  270. }
  271. }
  272. }
  273. /*
  274. * Create the index if the index don't exists in database
  275. * or the definition differ from the current status.
  276. * Don't create keys if table is new
  277. */
  278. if (!$is_new_table) {
  279. foreach ($structure["indexes"] AS $indexname => $fieldnames) {
  280. if (isset($database[$name]["indexes"][$indexname])) {
  281. $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
  282. } else {
  283. $current_index_definition = "__NOT_SET__";
  284. }
  285. $new_index_definition = implode(",",$fieldnames);
  286. if ($current_index_definition != $new_index_definition) {
  287. $sql2 = db_create_index($indexname, $fieldnames);
  288. // Fetch the "group by" fields for unique indexes
  289. if ($fieldnames[0] == "UNIQUE") {
  290. $group_by = db_group_by($indexname, $fieldnames);
  291. }
  292. if ($sql2 != "") {
  293. if ($sql3 == "") {
  294. $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
  295. } else {
  296. $sql3 .= ", ".$sql2;
  297. }
  298. }
  299. }
  300. }
  301. if (isset($database[$name]["table_status"]["Collation"])) {
  302. if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
  303. $sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
  304. if ($sql3 == "") {
  305. $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
  306. } else {
  307. $sql3 .= ", ".$sql2;
  308. }
  309. }
  310. }
  311. if ($sql3 != "") {
  312. $sql3 .= "; ";
  313. }
  314. // Now have a look at the field collations
  315. // Compare the field structure field by field
  316. foreach ($structure["fields"] AS $fieldname => $parameters) {
  317. // Compare the field definition
  318. $field_definition = $database[$name]["fields"][$fieldname];
  319. // Define the default collation if not given
  320. if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
  321. $parameters['Collation'] = 'utf8mb4_general_ci';
  322. } else {
  323. $parameters['Collation'] = null;
  324. }
  325. if ($field_definition['Collation'] != $parameters['Collation']) {
  326. $sql2 = db_modify_table_field($fieldname, $parameters);
  327. if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
  328. $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
  329. } else {
  330. $sql3 .= ", ".$sql2;
  331. }
  332. }
  333. }
  334. }
  335. if ($sql3 != "") {
  336. if (substr($sql3, -2, 2) != "; ") {
  337. $sql3 .= ";";
  338. }
  339. if ($verbose) {
  340. // Ensure index conversion to unique removes duplicates
  341. if ($is_unique) {
  342. if ($ignore != "") {
  343. echo "SET session old_alter_table=1;\n";
  344. } else {
  345. echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n";
  346. }
  347. }
  348. echo $sql3."\n";
  349. if ($is_unique) {
  350. if ($ignore != "") {
  351. echo "SET session old_alter_table=0;\n";
  352. } else {
  353. echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
  354. echo "DROP TABLE `".$name."`;\n";
  355. echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
  356. }
  357. }
  358. }
  359. if ($action) {
  360. Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
  361. // Ensure index conversion to unique removes duplicates
  362. if ($is_unique) {
  363. if ($ignore != "") {
  364. $db->q("SET session old_alter_table=1;");
  365. } else {
  366. $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
  367. if (!dbm::is_result($r)) {
  368. $errors .= print_update_error($db, $sql3);
  369. return $errors;
  370. }
  371. }
  372. }
  373. $r = @$db->q($sql3);
  374. if (!dbm::is_result($r)) {
  375. $errors .= print_update_error($db, $sql3);
  376. }
  377. if ($is_unique) {
  378. if ($ignore != "") {
  379. $db->q("SET session old_alter_table=0;");
  380. } else {
  381. $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
  382. if (!dbm::is_result($r)) {
  383. $errors .= print_update_error($db, $sql3);
  384. return $errors;
  385. }
  386. $r = $db->q("DROP TABLE `".$name."`;");
  387. if (!dbm::is_result($r)) {
  388. $errors .= print_update_error($db, $sql3);
  389. return $errors;
  390. }
  391. $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
  392. if (!dbm::is_result($r)) {
  393. $errors .= print_update_error($db, $sql3);
  394. return $errors;
  395. }
  396. }
  397. }
  398. }
  399. }
  400. }
  401. if ($action) {
  402. Config::set('system', 'maintenance', 0);
  403. Config::set('system', 'maintenance_reason', '');
  404. }
  405. return $errors;
  406. }
  407. function db_field_command($parameters, $create = true) {
  408. $fieldstruct = $parameters["type"];
  409. if (!is_null($parameters["Collation"])) {
  410. $fieldstruct .= " COLLATE ".$parameters["Collation"];
  411. }
  412. if ($parameters["not null"])
  413. $fieldstruct .= " NOT NULL";
  414. if (isset($parameters["default"])) {
  415. if (strpos(strtolower($parameters["type"]),"int")!==false) {
  416. $fieldstruct .= " DEFAULT ".$parameters["default"];
  417. } else {
  418. $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
  419. }
  420. }
  421. if ($parameters["extra"] != "")
  422. $fieldstruct .= " ".$parameters["extra"];
  423. /*if (($parameters["primary"] != "") AND $create)
  424. $fieldstruct .= " PRIMARY KEY";*/
  425. return($fieldstruct);
  426. }
  427. function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
  428. global $a, $db;
  429. $r = true;
  430. $sql = "";
  431. $sql_rows = array();
  432. $primary_keys = array();
  433. foreach ($fields AS $fieldname => $field) {
  434. $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
  435. if (x($field,'primary') and $field['primary']!='') {
  436. $primary_keys[] = $fieldname;
  437. }
  438. }
  439. if (!is_null($indexes)) {
  440. foreach ($indexes AS $indexname => $fieldnames) {
  441. $sql_index = db_create_index($indexname, $fieldnames, "");
  442. if (!is_null($sql_index)) $sql_rows[] = $sql_index;
  443. }
  444. }
  445. $sql = implode(",\n\t", $sql_rows);
  446. $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
  447. if ($verbose)
  448. echo $sql.";\n";
  449. if ($action)
  450. $r = @$db->q($sql);
  451. return $r;
  452. }
  453. function db_add_table_field($fieldname, $parameters) {
  454. $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
  455. return($sql);
  456. }
  457. function db_modify_table_field($fieldname, $parameters) {
  458. $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
  459. return($sql);
  460. }
  461. function db_drop_index($indexname) {
  462. $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
  463. return($sql);
  464. }
  465. function db_create_index($indexname, $fieldnames, $method="ADD") {
  466. $method = strtoupper(trim($method));
  467. if ($method!="" && $method!="ADD") {
  468. throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
  469. killme();
  470. }
  471. if ($fieldnames[0] == "UNIQUE") {
  472. array_shift($fieldnames);
  473. $method .= ' UNIQUE';
  474. }
  475. $names = "";
  476. foreach ($fieldnames AS $fieldname) {
  477. if ($names != "")
  478. $names .= ",";
  479. if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
  480. $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
  481. } else {
  482. $names .= "`".dbesc($fieldname)."`";
  483. }
  484. }
  485. if ($indexname == "PRIMARY") {
  486. return sprintf("%s PRIMARY KEY(%s)", $method, $names);
  487. }
  488. $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
  489. return($sql);
  490. }
  491. function db_group_by($indexname, $fieldnames) {
  492. if ($fieldnames[0] != "UNIQUE") {
  493. return "";
  494. }
  495. array_shift($fieldnames);
  496. $names = "";
  497. foreach ($fieldnames AS $fieldname) {
  498. if ($names != "")
  499. $names .= ",";
  500. if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
  501. $names .= "`".dbesc($matches[1])."`";
  502. } else {
  503. $names .= "`".dbesc($fieldname)."`";
  504. }
  505. }
  506. $sql = sprintf(" GROUP BY %s", $names);
  507. return $sql;
  508. }
  509. function db_definition() {
  510. $database = array();
  511. $database["addon"] = array(
  512. "fields" => array(
  513. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  514. "name" => array("type" => "varchar(190)", "not null" => "1", "default" => ""),
  515. "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  516. "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  517. "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  518. "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
  519. "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  520. ),
  521. "indexes" => array(
  522. "PRIMARY" => array("id"),
  523. "name" => array("UNIQUE", "name"),
  524. )
  525. );
  526. $database["attach"] = array(
  527. "fields" => array(
  528. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  529. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  530. "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  531. "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  532. "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  533. "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  534. "data" => array("type" => "longblob", "not null" => "1"),
  535. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  536. "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  537. "allow_cid" => array("type" => "mediumtext"),
  538. "allow_gid" => array("type" => "mediumtext"),
  539. "deny_cid" => array("type" => "mediumtext"),
  540. "deny_gid" => array("type" => "mediumtext"),
  541. ),
  542. "indexes" => array(
  543. "PRIMARY" => array("id"),
  544. )
  545. );
  546. $database["auth_codes"] = array(
  547. "fields" => array(
  548. "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
  549. "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
  550. "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
  551. "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  552. "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
  553. ),
  554. "indexes" => array(
  555. "PRIMARY" => array("id"),
  556. )
  557. );
  558. $database["cache"] = array(
  559. "fields" => array(
  560. "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
  561. "v" => array("type" => "mediumtext"),
  562. "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  563. "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  564. ),
  565. "indexes" => array(
  566. "PRIMARY" => array("k"),
  567. "expire_mode_updated" => array("expire_mode", "updated"),
  568. )
  569. );
  570. $database["challenge"] = array(
  571. "fields" => array(
  572. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  573. "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  574. "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  575. "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  576. "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  577. "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  578. ),
  579. "indexes" => array(
  580. "PRIMARY" => array("id"),
  581. )
  582. );
  583. $database["clients"] = array(
  584. "fields" => array(
  585. "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
  586. "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
  587. "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
  588. "name" => array("type" => "text"),
  589. "icon" => array("type" => "text"),
  590. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  591. ),
  592. "indexes" => array(
  593. "PRIMARY" => array("client_id"),
  594. )
  595. );
  596. $database["config"] = array(
  597. "fields" => array(
  598. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  599. "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  600. "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  601. "v" => array("type" => "mediumtext"),
  602. ),
  603. "indexes" => array(
  604. "PRIMARY" => array("id"),
  605. "cat_k" => array("UNIQUE", "cat", "k"),
  606. )
  607. );
  608. $database["contact"] = array(
  609. "fields" => array(
  610. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  611. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  612. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  613. "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  614. "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  615. "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  616. "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  617. "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  618. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  619. "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  620. "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  621. "about" => array("type" => "text"),
  622. "keywords" => array("type" => "text"),
  623. "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  624. "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  625. "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  626. "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  627. "photo" => array("type" => "text"),
  628. "thumb" => array("type" => "text"),
  629. "micro" => array("type" => "text"),
  630. "site-pubkey" => array("type" => "text"),
  631. "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  632. "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  633. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  634. "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  635. "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  636. "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  637. "pubkey" => array("type" => "text"),
  638. "prvkey" => array("type" => "text"),
  639. "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  640. "request" => array("type" => "text"),
  641. "notify" => array("type" => "text"),
  642. "poll" => array("type" => "text"),
  643. "confirm" => array("type" => "text"),
  644. "poco" => array("type" => "text"),
  645. "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  646. "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  647. "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  648. "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  649. "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  650. "last-update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  651. "success_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  652. "failure_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  653. "name-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  654. "uri-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  655. "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  656. "term-date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  657. "last-item" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  658. "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
  659. "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  660. "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  661. "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  662. "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  663. "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  664. "contact-type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  665. "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  666. "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  667. "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  668. "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  669. "reason" => array("type" => "text"),
  670. "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
  671. "info" => array("type" => "mediumtext"),
  672. "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  673. "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
  674. "bd" => array("type" => "date", "not null" => "1", "default" => "0001-01-01"),
  675. "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  676. "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  677. "ffi_keyword_blacklist" => array("type" => "text"),
  678. ),
  679. "indexes" => array(
  680. "PRIMARY" => array("id"),
  681. "uid_name" => array("uid", "name(190)"),
  682. "self_uid" => array("self", "uid"),
  683. "alias_uid" => array("alias(32)", "uid"),
  684. "pending_uid" => array("pending", "uid"),
  685. "blocked_uid" => array("blocked", "uid"),
  686. "uid_rel_network_poll" => array("uid", "rel", "network(4)", "poll(64)", "archive"),
  687. "uid_network_batch" => array("uid", "network(4)", "batch(64)"),
  688. "addr_uid" => array("addr(32)", "uid"),
  689. "nurl_uid" => array("nurl(32)", "uid"),
  690. "nick_uid" => array("nick(32)", "uid"),
  691. "dfrn-id" => array("dfrn-id"),
  692. "issued-id" => array("issued-id"),
  693. )
  694. );
  695. $database["conv"] = array(
  696. "fields" => array(
  697. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  698. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  699. "recips" => array("type" => "text"),
  700. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  701. "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  702. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  703. "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  704. "subject" => array("type" => "text"),
  705. ),
  706. "indexes" => array(
  707. "PRIMARY" => array("id"),
  708. "uid" => array("uid"),
  709. )
  710. );
  711. $database["conversation"] = array(
  712. "fields" => array(
  713. "item-uri" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
  714. "reply-to-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  715. "conversation-uri" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  716. "conversation-href" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  717. "protocol" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  718. "source" => array("type" => "mediumtext"),
  719. "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  720. ),
  721. "indexes" => array(
  722. "PRIMARY" => array("item-uri"),
  723. "conversation-uri" => array("conversation-uri"),
  724. )
  725. );
  726. $database["event"] = array(
  727. "fields" => array(
  728. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  729. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  730. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  731. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  732. "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  733. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  734. "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  735. "start" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  736. "finish" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  737. "summary" => array("type" => "text"),
  738. "desc" => array("type" => "text"),
  739. "location" => array("type" => "text"),
  740. "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  741. "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  742. "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  743. "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  744. "allow_cid" => array("type" => "mediumtext"),
  745. "allow_gid" => array("type" => "mediumtext"),
  746. "deny_cid" => array("type" => "mediumtext"),
  747. "deny_gid" => array("type" => "mediumtext"),
  748. ),
  749. "indexes" => array(
  750. "PRIMARY" => array("id"),
  751. "uid_start" => array("uid", "start"),
  752. )
  753. );
  754. $database["fcontact"] = array(
  755. "fields" => array(
  756. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  757. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  758. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  759. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  760. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  761. "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  762. "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  763. "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  764. "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  765. "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  766. "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  767. "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  768. "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  769. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  770. "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  771. "pubkey" => array("type" => "text"),
  772. "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  773. ),
  774. "indexes" => array(
  775. "PRIMARY" => array("id"),
  776. "addr" => array("addr(32)"),
  777. "url" => array("url"),
  778. )
  779. );
  780. $database["ffinder"] = array(
  781. "fields" => array(
  782. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  783. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  784. "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  785. "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
  786. ),
  787. "indexes" => array(
  788. "PRIMARY" => array("id"),
  789. )
  790. );
  791. $database["fserver"] = array(
  792. "fields" => array(
  793. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  794. "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  795. "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  796. "key" => array("type" => "text"),
  797. ),
  798. "indexes" => array(
  799. "PRIMARY" => array("id"),
  800. "server" => array("server(32)"),
  801. )
  802. );
  803. $database["fsuggest"] = array(
  804. "fields" => array(
  805. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  806. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  807. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  808. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  809. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  810. "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  811. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  812. "note" => array("type" => "text"),
  813. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  814. ),
  815. "indexes" => array(
  816. "PRIMARY" => array("id"),
  817. )
  818. );
  819. $database["gcign"] = array(
  820. "fields" => array(
  821. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  822. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  823. "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
  824. ),
  825. "indexes" => array(
  826. "PRIMARY" => array("id"),
  827. "uid" => array("uid"),
  828. "gcid" => array("gcid"),
  829. )
  830. );
  831. $database["gcontact"] = array(
  832. "fields" => array(
  833. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  834. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  835. "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  836. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  837. "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  838. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  839. "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  840. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  841. "updated" => array("type" => "datetime", "default" => NULL_DATE),
  842. "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
  843. "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
  844. "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  845. "about" => array("type" => "text"),
  846. "keywords" => array("type" => "text"),
  847. "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  848. "birthday" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
  849. "community" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  850. "contact-type" => array("type" => "tinyint(1)", "not null" => "1", "default" => "-1"),
  851. "hide" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  852. "nsfw" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  853. "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  854. "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  855. "notify" => array("type" => "text"),
  856. "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  857. "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
  858. "server_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  859. ),
  860. "indexes" => array(
  861. "PRIMARY" => array("id"),
  862. "nurl" => array("nurl(64)"),
  863. "name" => array("name(64)"),
  864. "nick" => array("nick(32)"),
  865. "addr" => array("addr(64)"),
  866. "hide_network_updated" => array("hide", "network(4)", "updated"),
  867. "updated" => array("updated"),
  868. )
  869. );
  870. $database["glink"] = array(
  871. "fields" => array(
  872. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  873. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  874. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  875. "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
  876. "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
  877. "updated" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  878. ),
  879. "indexes" => array(
  880. "PRIMARY" => array("id"),
  881. "cid_uid_gcid_zcid" => array("UNIQUE", "cid","uid","gcid","zcid"),
  882. "gcid" => array("gcid"),
  883. )
  884. );
  885. $database["group"] = array(
  886. "fields" => array(
  887. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  888. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  889. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  890. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  891. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  892. ),
  893. "indexes" => array(
  894. "PRIMARY" => array("id"),
  895. "uid" => array("uid"),
  896. )
  897. );
  898. $database["group_member"] = array(
  899. "fields" => array(
  900. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  901. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  902. "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("group" => "id")),
  903. "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  904. ),
  905. "indexes" => array(
  906. "PRIMARY" => array("id"),
  907. "contactid" => array("contact-id"),
  908. "gid_contactid" => array("gid", "contact-id"),
  909. "uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
  910. )
  911. );
  912. $database["gserver"] = array(
  913. "fields" => array(
  914. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  915. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  916. "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  917. "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  918. "site_name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  919. "info" => array("type" => "text"),
  920. "register_policy" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  921. "poco" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  922. "noscrape" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  923. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  924. "platform" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  925. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  926. "last_poco_query" => array("type" => "datetime", "default" => NULL_DATE),
  927. "last_contact" => array("type" => "datetime", "default" => NULL_DATE),
  928. "last_failure" => array("type" => "datetime", "default" => NULL_DATE),
  929. ),
  930. "indexes" => array(
  931. "PRIMARY" => array("id"),
  932. "nurl" => array("nurl(32)"),
  933. )
  934. );
  935. $database["hook"] = array(
  936. "fields" => array(
  937. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  938. "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  939. "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  940. "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  941. "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  942. ),
  943. "indexes" => array(
  944. "PRIMARY" => array("id"),
  945. "hook_file_function" => array("UNIQUE", "hook(50)","file(80)","function(60)"),
  946. )
  947. );
  948. $database["intro"] = array(
  949. "fields" => array(
  950. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  951. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  952. "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("fcontact" => "id")),
  953. "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  954. "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  955. "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  956. "note" => array("type" => "text"),
  957. "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  958. "datetime" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  959. "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  960. "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  961. ),
  962. "indexes" => array(
  963. "PRIMARY" => array("id"),
  964. )
  965. );
  966. $database["item"] = array(
  967. "fields" => array(
  968. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "relation" => array("thread" => "iid")),
  969. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  970. "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  971. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  972. "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  973. "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
  974. "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  975. "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  976. "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  977. "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
  978. "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  979. "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  980. "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  981. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  982. "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  983. "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  984. "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  985. "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  986. "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  987. "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  988. "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  989. "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  990. "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  991. "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  992. "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  993. "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  994. "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  995. "body" => array("type" => "mediumtext"),
  996. "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  997. "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  998. "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  999. "object" => array("type" => "text"),
  1000. "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1001. "target" => array("type" => "text"),
  1002. "postopts" => array("type" => "text"),
  1003. "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1004. "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1005. "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("event" => "id")),
  1006. "tag" => array("type" => "mediumtext"),
  1007. "attach" => array("type" => "mediumtext"),
  1008. "inform" => array("type" => "mediumtext"),
  1009. "file" => array("type" => "mediumtext"),
  1010. "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1011. "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1012. "allow_cid" => array("type" => "mediumtext"),
  1013. "allow_gid" => array("type" => "mediumtext"),
  1014. "deny_cid" => array("type" => "mediumtext"),
  1015. "deny_gid" => array("type" => "mediumtext"),
  1016. "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1017. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1018. "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1019. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1020. "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1021. "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1022. "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1023. "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  1024. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1025. "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1026. "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1027. "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
  1028. "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1029. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1030. "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1031. "rendered-html" => array("type" => "mediumtext"),
  1032. "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1033. ),
  1034. "indexes" => array(
  1035. "PRIMARY" => array("id"),
  1036. "guid" => array("guid"),
  1037. "uri" => array("uri"),
  1038. "parent" => array("parent"),
  1039. "parent-uri" => array("parent-uri"),
  1040. "extid" => array("extid"),
  1041. "uid_id" => array("uid","id"),
  1042. "uid_contactid_id" => array("uid","contact-id","id"),
  1043. "uid_created" => array("uid","created"),
  1044. "uid_unseen_contactid" => array("uid","unseen","contact-id"),
  1045. "uid_network_received" => array("uid","network(4)","received"),
  1046. "uid_network_commented" => array("uid","network(4)","commented"),
  1047. "uid_thrparent" => array("uid","thr-parent(190)"),
  1048. "uid_parenturi" => array("uid","parent-uri(190)"),
  1049. "uid_contactid_created" => array("uid","contact-id","created"),
  1050. "authorid_created" => array("author-id","created"),
  1051. "ownerid" => array("owner-id"),
  1052. "uid_uri" => array("uid", "uri(190)"),
  1053. "resource-id" => array("resource-id"),
  1054. "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"), //
  1055. "uid_type_changed" => array("uid","type(190)","changed"),
  1056. "contactid_verb" => array("contact-id","verb(190)"),
  1057. "deleted_changed" => array("deleted","changed"),
  1058. "uid_wall_changed" => array("uid","wall","changed"),
  1059. "uid_eventid" => array("uid","event-id"),
  1060. "uid_authorlink" => array("uid","author-link(190)"),
  1061. "uid_ownerlink" => array("uid","owner-link(190)"),
  1062. )
  1063. );
  1064. $database["item_id"] = array(
  1065. "fields" => array(
  1066. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1067. "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
  1068. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1069. "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1070. "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1071. ),
  1072. "indexes" => array(
  1073. "PRIMARY" => array("id"),
  1074. "uid" => array("uid"),
  1075. "sid" => array("sid"),
  1076. "service" => array("service(32)"),
  1077. "iid" => array("iid"),
  1078. )
  1079. );
  1080. $database["locks"] = array(
  1081. "fields" => array(
  1082. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1083. "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
  1084. "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1085. "created" => array("type" => "datetime", "default" => NULL_DATE),
  1086. ),
  1087. "indexes" => array(
  1088. "PRIMARY" => array("id"),
  1089. )
  1090. );
  1091. $database["mail"] = array(
  1092. "fields" => array(
  1093. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1094. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1095. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  1096. "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1097. "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1098. "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1099. "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => "", "relation" => array("contact" => "id")),
  1100. "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("conv" => "id")),
  1101. "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1102. "body" => array("type" => "mediumtext"),
  1103. "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1104. "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1105. "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1106. "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1107. "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1108. "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1109. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1110. ),
  1111. "indexes" => array(
  1112. "PRIMARY" => array("id"),
  1113. "uid_seen" => array("uid", "seen"),
  1114. "convid" => array("convid"),
  1115. "uri" => array("uri(64)"),
  1116. "parent-uri" => array("parent-uri(64)"),
  1117. )
  1118. );
  1119. $database["mailacct"] = array(
  1120. "fields" => array(
  1121. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1122. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1123. "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1124. "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1125. "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
  1126. "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1127. "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1128. "pass" => array("type" => "text"),
  1129. "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1130. "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1131. "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1132. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1133. "last_check" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1134. ),
  1135. "indexes" => array(
  1136. "PRIMARY" => array("id"),
  1137. )
  1138. );
  1139. $database["manage"] = array(
  1140. "fields" => array(
  1141. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1142. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1143. "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1144. ),
  1145. "indexes" => array(
  1146. "PRIMARY" => array("id"),
  1147. "uid_mid" => array("UNIQUE", "uid","mid"),
  1148. )
  1149. );
  1150. $database["notify"] = array(
  1151. "fields" => array(
  1152. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1153. "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  1154. "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1155. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1156. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1157. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1158. "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1159. "msg" => array("type" => "mediumtext"),
  1160. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1161. "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1162. "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
  1163. "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
  1164. "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1165. "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1166. "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
  1167. "name_cache" => array("type" => "tinytext"),
  1168. "msg_cache" => array("type" => "mediumtext")
  1169. ),
  1170. "indexes" => array(
  1171. "PRIMARY" => array("id"),
  1172. "hash_uid" => array("hash", "uid"),
  1173. "seen_uid_date" => array("seen", "uid", "date"),
  1174. "uid_date" => array("uid", "date"),
  1175. "uid_type_link" => array("uid", "type", "link(190)"),
  1176. )
  1177. );
  1178. $database["notify-threads"] = array(
  1179. "fields" => array(
  1180. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1181. "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("notify" => "id")),
  1182. "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
  1183. "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1184. "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1185. ),
  1186. "indexes" => array(
  1187. "PRIMARY" => array("id"),
  1188. )
  1189. );
  1190. $database["oembed"] = array(
  1191. "fields" => array(
  1192. "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
  1193. "content" => array("type" => "mediumtext"),
  1194. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1195. ),
  1196. "indexes" => array(
  1197. "PRIMARY" => array("url"),
  1198. "created" => array("created"),
  1199. )
  1200. );
  1201. $database["parsed_url"] = array(
  1202. "fields" => array(
  1203. "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"),
  1204. "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
  1205. "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"),
  1206. "content" => array("type" => "mediumtext"),
  1207. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1208. ),
  1209. "indexes" => array(
  1210. "PRIMARY" => array("url", "guessing", "oembed"),
  1211. "created" => array("created"),
  1212. )
  1213. );
  1214. $database["pconfig"] = array(
  1215. "fields" => array(
  1216. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1217. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1218. "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  1219. "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  1220. "v" => array("type" => "mediumtext"),
  1221. ),
  1222. "indexes" => array(
  1223. "PRIMARY" => array("id"),
  1224. "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"),
  1225. )
  1226. );
  1227. $database["photo"] = array(
  1228. "fields" => array(
  1229. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1230. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1231. "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  1232. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  1233. "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1234. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1235. "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1236. "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1237. "desc" => array("type" => "text"),
  1238. "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1239. "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1240. "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
  1241. "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
  1242. "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
  1243. "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1244. "data" => array("type" => "mediumblob", "not null" => "1"),
  1245. "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
  1246. "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1247. "allow_cid" => array("type" => "mediumtext"),
  1248. "allow_gid" => array("type" => "mediumtext"),
  1249. "deny_cid" => array("type" => "mediumtext"),
  1250. "deny_gid" => array("type" => "mediumtext"),
  1251. ),
  1252. "indexes" => array(
  1253. "PRIMARY" => array("id"),
  1254. "uid_contactid" => array("uid", "contact-id"),
  1255. "uid_profile" => array("uid", "profile"),
  1256. "uid_album_scale_created" => array("uid", "album(32)", "scale", "created"),
  1257. "uid_album_resource-id_created" => array("uid", "album(32)", "resource-id(64)", "created"),
  1258. "resource-id" => array("resource-id(64)"),
  1259. )
  1260. );
  1261. $database["poll"] = array(
  1262. "fields" => array(
  1263. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1264. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1265. "q0" => array("type" => "text"),
  1266. "q1" => array("type" => "text"),
  1267. "q2" => array("type" => "text"),
  1268. "q3" => array("type" => "text"),
  1269. "q4" => array("type" => "text"),
  1270. "q5" => array("type" => "text"),
  1271. "q6" => array("type" => "text"),
  1272. "q7" => array("type" => "text"),
  1273. "q8" => array("type" => "text"),
  1274. "q9" => array("type" => "text"),
  1275. ),
  1276. "indexes" => array(
  1277. "PRIMARY" => array("id"),
  1278. "uid" => array("uid"),
  1279. )
  1280. );
  1281. $database["poll_result"] = array(
  1282. "fields" => array(
  1283. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1284. "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("poll" => "id")),
  1285. "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1286. ),
  1287. "indexes" => array(
  1288. "PRIMARY" => array("id"),
  1289. "poll_id" => array("poll_id"),
  1290. "choice" => array("choice"),
  1291. )
  1292. );
  1293. $database["process"] = array(
  1294. "fields" => array(
  1295. "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"),
  1296. "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""),
  1297. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1298. ),
  1299. "indexes" => array(
  1300. "PRIMARY" => array("pid"),
  1301. "command" => array("command"),
  1302. )
  1303. );
  1304. $database["profile"] = array(
  1305. "fields" => array(
  1306. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1307. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1308. "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1309. "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1310. "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1311. "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1312. "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1313. "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0001-01-01"),
  1314. "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1315. "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1316. "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1317. "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1318. "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1319. "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1320. "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1321. "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1322. "with" => array("type" => "text"),
  1323. "howlong" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1324. "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1325. "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1326. "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1327. "pub_keywords" => array("type" => "text"),
  1328. "prv_keywords" => array("type" => "text"),
  1329. "likes" => array("type" => "text"),
  1330. "dislikes" => array("type" => "text"),
  1331. "about" => array("type" => "text"),
  1332. "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1333. "music" => array("type" => "text"),
  1334. "book" => array("type" => "text"),
  1335. "tv" => array("type" => "text"),
  1336. "film" => array("type" => "text"),
  1337. "interest" => array("type" => "text"),
  1338. "romance" => array("type" => "text"),
  1339. "work" => array("type" => "text"),
  1340. "education" => array("type" => "text"),
  1341. "contact" => array("type" => "text"),
  1342. "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1343. "xmpp" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1344. "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1345. "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1346. "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1347. "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1348. ),
  1349. "indexes" => array(
  1350. "PRIMARY" => array("id"),
  1351. "uid_is-default" => array("uid", "is-default"),
  1352. )
  1353. );
  1354. $database["profile_check"] = array(
  1355. "fields" => array(
  1356. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1357. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1358. "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  1359. "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1360. "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1361. "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1362. ),
  1363. "indexes" => array(
  1364. "PRIMARY" => array("id"),
  1365. )
  1366. );
  1367. $database["push_subscriber"] = array(
  1368. "fields" => array(
  1369. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1370. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1371. "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1372. "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1373. "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1374. "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1375. "last_update" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1376. "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1377. ),
  1378. "indexes" => array(
  1379. "PRIMARY" => array("id"),
  1380. )
  1381. );
  1382. $database["queue"] = array(
  1383. "fields" => array(
  1384. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1385. "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  1386. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1387. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1388. "last" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1389. "content" => array("type" => "mediumtext"),
  1390. "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1391. ),
  1392. "indexes" => array(
  1393. "PRIMARY" => array("id"),
  1394. "cid" => array("cid"),
  1395. "created" => array("created"),
  1396. "last" => array("last"),
  1397. "network" => array("network"),
  1398. "batch" => array("batch"),
  1399. )
  1400. );
  1401. $database["register"] = array(
  1402. "fields" => array(
  1403. "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1404. "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1405. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1406. "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1407. "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1408. "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
  1409. "note" => array("type" => "text"),
  1410. ),
  1411. "indexes" => array(
  1412. "PRIMARY" => array("id"),
  1413. )
  1414. );
  1415. $database["search"] = array(
  1416. "fields" => array(
  1417. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1418. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1419. "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1420. ),
  1421. "indexes" => array(
  1422. "PRIMARY" => array("id"),
  1423. "uid" => array("uid"),
  1424. )
  1425. );
  1426. $database["session"] = array(
  1427. "fields" => array(
  1428. "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1429. "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""),
  1430. "data" => array("type" => "text"),
  1431. "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1432. ),
  1433. "indexes" => array(
  1434. "PRIMARY" => array("id"),
  1435. "sid" => array("sid(64)"),
  1436. "expire" => array("expire"),
  1437. )
  1438. );
  1439. $database["sign"] = array(
  1440. "fields" => array(
  1441. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1442. "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
  1443. "signed_text" => array("type" => "mediumtext"),
  1444. "signature" => array("type" => "text"),
  1445. "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1446. ),
  1447. "indexes" => array(
  1448. "PRIMARY" => array("id"),
  1449. "iid" => array("iid"),
  1450. )
  1451. );
  1452. $database["spam"] = array(
  1453. "fields" => array(
  1454. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1455. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1456. "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1457. "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1458. "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1459. "date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1460. ),
  1461. "indexes" => array(
  1462. "PRIMARY" => array("id"),
  1463. "uid" => array("uid"),
  1464. "spam" => array("spam"),
  1465. "ham" => array("ham"),
  1466. "term" => array("term"),
  1467. )
  1468. );
  1469. $database["term"] = array(
  1470. "fields" => array(
  1471. "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1472. "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("item" => "id")),
  1473. "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
  1474. "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
  1475. "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1476. "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1477. "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1478. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1479. "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1480. "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1481. "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1482. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1483. ),
  1484. "indexes" => array(
  1485. "PRIMARY" => array("tid"),
  1486. "oid_otype_type_term" => array("oid","otype","type","term(32)"),
  1487. "uid_otype_type_term_global_created" => array("uid","otype","type","term(32)","global","created"),
  1488. "uid_otype_type_url" => array("uid","otype","type","url(64)"),
  1489. "guid" => array("guid(64)"),
  1490. )
  1491. );
  1492. $database["thread"] = array(
  1493. "fields" => array(
  1494. "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => array("item" => "id")),
  1495. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1496. "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  1497. "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("gcontact" => "id")),
  1498. "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  1499. "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0", "relation" => array("contact" => "id")),
  1500. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1501. "edited" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1502. "commented" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1503. "received" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1504. "changed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1505. "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1506. "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1507. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1508. "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1509. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1510. "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1511. "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1512. "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1513. "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1514. "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  1515. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1516. "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1517. "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1518. "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1519. "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1520. ),
  1521. "indexes" => array(
  1522. "PRIMARY" => array("iid"),
  1523. "uid_network_commented" => array("uid","network","commented"),
  1524. "uid_network_created" => array("uid","network","created"),
  1525. "uid_contactid_commented" => array("uid","contact-id","commented"),
  1526. "uid_contactid_created" => array("uid","contact-id","created"),
  1527. "contactid" => array("contact-id"),
  1528. "ownerid" => array("owner-id"),
  1529. "authorid" => array("author-id"),
  1530. "uid_created" => array("uid","created"),
  1531. "uid_commented" => array("uid","commented"),
  1532. "uid_wall_created" => array("uid","wall","created"),
  1533. )
  1534. );
  1535. $database["tokens"] = array(
  1536. "fields" => array(
  1537. "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
  1538. "secret" => array("type" => "text"),
  1539. "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => "", "relation" => array("clients" => "client_id")),
  1540. "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1541. "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
  1542. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
  1543. ),
  1544. "indexes" => array(
  1545. "PRIMARY" => array("id"),
  1546. )
  1547. );
  1548. $database["user"] = array(
  1549. "fields" => array(
  1550. "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1551. "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
  1552. "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1553. "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1554. "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1555. "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1556. "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1557. "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
  1558. "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
  1559. "register_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1560. "login_date" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1561. "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1562. "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1563. "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1564. "pubkey" => array("type" => "text"),
  1565. "prvkey" => array("type" => "text"),
  1566. "spubkey" => array("type" => "text"),
  1567. "sprvkey" => array("type" => "text"),
  1568. "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1569. "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1570. "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1571. "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1572. "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1573. "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1574. "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
  1575. "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
  1576. "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1577. "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1578. "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1579. "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
  1580. "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
  1581. "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1582. "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1583. "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1584. "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1585. "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1586. "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
  1587. "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1588. "allow_cid" => array("type" => "mediumtext"),
  1589. "allow_gid" => array("type" => "mediumtext"),
  1590. "deny_cid" => array("type" => "mediumtext"),
  1591. "deny_gid" => array("type" => "mediumtext"),
  1592. "openidserver" => array("type" => "text"),
  1593. ),
  1594. "indexes" => array(
  1595. "PRIMARY" => array("uid"),
  1596. "nickname" => array("nickname(32)"),
  1597. )
  1598. );
  1599. $database["userd"] = array(
  1600. "fields" => array(
  1601. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1602. "username" => array("type" => "varchar(255)", "not null" => "1"),
  1603. ),
  1604. "indexes" => array(
  1605. "PRIMARY" => array("id"),
  1606. "username" => array("username(32)"),
  1607. )
  1608. );
  1609. $database["workerqueue"] = array(
  1610. "fields" => array(
  1611. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1612. "parameter" => array("type" => "text"),
  1613. "priority" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
  1614. "created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1615. "pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1616. "executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
  1617. ),
  1618. "indexes" => array(
  1619. "PRIMARY" => array("id"),
  1620. )
  1621. );
  1622. return($database);
  1623. }
  1624. /*
  1625. * run from command line
  1626. */
  1627. function dbstructure_run(&$argv, &$argc) {
  1628. global $a, $db;
  1629. if (is_null($a)) {
  1630. $a = new App;
  1631. }
  1632. if (is_null($db)) {
  1633. @include(".htconfig.php");
  1634. require_once("include/dba.php");
  1635. $db = new dba($db_host, $db_user, $db_pass, $db_data);
  1636. unset($db_host, $db_user, $db_pass, $db_data);
  1637. }
  1638. if ($argc==2) {
  1639. switch ($argv[1]) {
  1640. case "dryrun":
  1641. update_structure(true, false);
  1642. return;
  1643. case "update":
  1644. update_structure(true, true);
  1645. $build = get_config('system','build');
  1646. if (!x($build)) {
  1647. set_config('system','build',DB_UPDATE_VERSION);
  1648. $build = DB_UPDATE_VERSION;
  1649. }
  1650. $stored = intval($build);
  1651. $current = intval(DB_UPDATE_VERSION);
  1652. // run any left update_nnnn functions in update.php
  1653. for ($x = $stored; $x < $current; $x ++) {
  1654. $r = run_update_function($x);
  1655. if (!$r) break;
  1656. }
  1657. set_config('system','build',DB_UPDATE_VERSION);
  1658. return;
  1659. case "dumpsql":
  1660. print_structure(db_definition());
  1661. return;
  1662. case "toinnodb":
  1663. convert_to_innodb();
  1664. return;
  1665. }
  1666. }
  1667. // print help
  1668. echo $argv[0]." <command>\n";
  1669. echo "\n";
  1670. echo "Commands:\n";
  1671. echo "dryrun show database update schema queries without running them\n";
  1672. echo "update update database schema\n";
  1673. echo "dumpsql dump database schema\n";
  1674. echo "toinnodb convert all tables from MyISAM to InnoDB\n";
  1675. return;
  1676. }
  1677. if (array_search(__file__,get_included_files())===0) {
  1678. dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);
  1679. killme();
  1680. }