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.

68 lines
1.5KB

  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * @file scripts/dbstructure.php
  5. * @brief Does database updates from the command line
  6. */
  7. use Friendica\App;
  8. use Friendica\Core\Config;
  9. use Friendica\Database\DBStructure;
  10. require_once "boot.php";
  11. require_once "include/dba.php";
  12. $a = new App(dirname(__DIR__));
  13. BaseObject::setApp($a);
  14. @include ".htconfig.php";
  15. dba::connect($db_host, $db_user, $db_pass, $db_data);
  16. unset($db_host, $db_user, $db_pass, $db_data);
  17. if ($_SERVER["argc"] == 2) {
  18. switch ($_SERVER["argv"][1]) {
  19. case "dryrun":
  20. DBStructure::update(true, false);
  21. return;
  22. case "update":
  23. DBStructure::update(true, true);
  24. $build = Config::get('system','build');
  25. if (!x($build)) {
  26. Config::set('system', 'build', DB_UPDATE_VERSION);
  27. $build = DB_UPDATE_VERSION;
  28. }
  29. $stored = intval($build);
  30. $current = intval(DB_UPDATE_VERSION);
  31. // run any left update_nnnn functions in update.php
  32. for ($x = $stored; $x < $current; $x ++) {
  33. $r = run_update_function($x);
  34. if (!$r) {
  35. break;
  36. }
  37. }
  38. Config::set('system','build',DB_UPDATE_VERSION);
  39. return;
  40. case "dumpsql":
  41. DBStructure::printStructure();
  42. return;
  43. case "toinnodb":
  44. DBStructure::convertToInnoDB();
  45. return;
  46. }
  47. }
  48. // print help
  49. echo $_SERVER["argv"][0]." <command>\n";
  50. echo "\n";
  51. echo "Commands:\n";
  52. echo "dryrun show database update schema queries without running them\n";
  53. echo "update update database schema\n";
  54. echo "dumpsql dump database schema\n";
  55. echo "toinnodb convert all tables from MyISAM to InnoDB\n";
  56. killme();