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