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