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.

70 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. Config::load();
  18. if ($_SERVER["argc"] == 2) {
  19. switch ($_SERVER["argv"][1]) {
  20. case "dryrun":
  21. DBStructure::update(true, false);
  22. return;
  23. case "update":
  24. DBStructure::update(true, true);
  25. $build = Config::get('system','build');
  26. if (!x($build)) {
  27. Config::set('system', 'build', DB_UPDATE_VERSION);
  28. $build = DB_UPDATE_VERSION;
  29. }
  30. $stored = intval($build);
  31. $current = intval(DB_UPDATE_VERSION);
  32. // run any left update_nnnn functions in update.php
  33. for ($x = $stored; $x < $current; $x ++) {
  34. $r = run_update_function($x);
  35. if (!$r) {
  36. break;
  37. }
  38. }
  39. Config::set('system','build',DB_UPDATE_VERSION);
  40. return;
  41. case "dumpsql":
  42. DBStructure::printStructure();
  43. return;
  44. case "toinnodb":
  45. DBStructure::convertToInnoDB();
  46. return;
  47. }
  48. }
  49. // print help
  50. echo $_SERVER["argv"][0]." <command>\n";
  51. echo "\n";
  52. echo "Commands:\n";
  53. echo "dryrun show database update schema queries without running them\n";
  54. echo "update update database schema\n";
  55. echo "dumpsql dump database schema\n";
  56. echo "toinnodb convert all tables from MyISAM to InnoDB\n";
  57. killme();