mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-24 13:40:29 +01:00
upgrade added external connection option, optimized db_schema.json (views now with brackets around expressions)
This commit is contained in:
parent
68554f91c1
commit
3ea5c0e478
@ -114243,17 +114243,17 @@
|
||||
{
|
||||
"name": "belege",
|
||||
"type": "VIEW",
|
||||
"Create": "CREATE ALGORITHM=UNDEFINED DEFINER=`openxe`@`localhost` SQL SECURITY DEFINER VIEW `belege` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe` from `rechnung` where `rechnung`.`status` <> 'angelegt' union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,`gutschrift`.`umsatz_netto` * -1 AS `umsatz_netto*-1`,`gutschrift`.`erloes_netto` * -1 AS `erloes_netto*-1`,`gutschrift`.`deckungsbeitrag` * -1 AS `deckungsbeitrag*-1`,`gutschrift`.`provision_summe` * -1 AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe` from `gutschrift` where `gutschrift`.`status` <> 'angelegt'"
|
||||
"Create": "CREATE ALGORITHM=UNDEFINED DEFINER=`openxe`@`localhost` SQL SECURITY DEFINER VIEW `belege` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe` from `rechnung` where (`rechnung`.`status` <> 'angelegt') union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,(`gutschrift`.`umsatz_netto` * -(1)) AS `umsatz_netto*-1`,(`gutschrift`.`erloes_netto` * -(1)) AS `erloes_netto*-1`,(`gutschrift`.`deckungsbeitrag` * -(1)) AS `deckungsbeitrag*-1`,(`gutschrift`.`provision_summe` * -(1)) AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe` from `gutschrift` where (`gutschrift`.`status` <> 'angelegt')"
|
||||
},
|
||||
{
|
||||
"name": "belegegesamt",
|
||||
"type": "VIEW",
|
||||
"Create": "CREATE ALGORITHM=UNDEFINED DEFINER=`openxe`@`localhost` SQL SECURITY DEFINER VIEW `belegegesamt` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`soll` AS `umsatz_brutto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe`,`rechnung`.`projekt` AS `projekt` from `rechnung` union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,`gutschrift`.`umsatz_netto` * -1 AS `umsatz_netto*-1`,`gutschrift`.`soll` * -1 AS `umsatz_brutto*-1`,`gutschrift`.`erloes_netto` * -1 AS `erloes_netto*-1`,`gutschrift`.`deckungsbeitrag` * -1 AS `deckungsbeitrag*-1`,`gutschrift`.`provision_summe` * -1 AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe`,`gutschrift`.`projekt` AS `projekt` from `gutschrift` union all select `auftrag`.`id` AS `id`,`auftrag`.`adresse` AS `adresse`,`auftrag`.`datum` AS `datum`,`auftrag`.`belegnr` AS `belegnr`,`auftrag`.`status` AS `status`,`auftrag`.`land` AS `land`,'auftrag' AS `typ`,`auftrag`.`umsatz_netto` AS `umsatz_netto`,`auftrag`.`gesamtsumme` AS `umsatz_brutto`,`auftrag`.`erloes_netto` AS `erloes_netto`,`auftrag`.`deckungsbeitrag` AS `deckungsbeitrag`,`auftrag`.`provision_summe` AS `provision_summe`,`auftrag`.`vertriebid` AS `vertriebid`,`auftrag`.`gruppe` AS `gruppe`,`auftrag`.`projekt` AS `projekt` from `auftrag` union all select `bestellung`.`id` AS `id`,`bestellung`.`adresse` AS `adresse`,`bestellung`.`datum` AS `datum`,`bestellung`.`belegnr` AS `belegnr`,`bestellung`.`status` AS `status`,`bestellung`.`land` AS `land`,'bestellung' AS `typ`,`bestellung`.`gesamtsumme` AS `umsatz_netto`,`bestellung`.`gesamtsumme` AS `umsatz_brutto`,'0' AS `erloes_netto`,'0' AS `deckungsbeitrag`,'0' AS `provision_summe`,'0' AS `vertriebid`,'0' AS `gruppe`,`bestellung`.`projekt` AS `projekt` from `bestellung` union all select `lieferschein`.`id` AS `id`,`lieferschein`.`adresse` AS `adresse`,`lieferschein`.`datum` AS `datum`,`lieferschein`.`belegnr` AS `belegnr`,`lieferschein`.`status` AS `status`,`lieferschein`.`land` AS `land`,'lieferschein' AS `typ`,'0' AS `umsatz_netto`,'0' AS `umsatz_brutto`,'0' AS `erloes_netto`,'0' AS `deckungsbeitrag`,'0' AS `provision_summe`,'0' AS `vertriebid`,'0' AS `gruppe`,`lieferschein`.`projekt` AS `projekt` from `lieferschein` union all select `angebot`.`id` AS `id`,`angebot`.`adresse` AS `adresse`,`angebot`.`datum` AS `datum`,`angebot`.`belegnr` AS `belegnr`,`angebot`.`status` AS `status`,`angebot`.`land` AS `land`,'angebot' AS `typ`,`angebot`.`umsatz_netto` AS `umsatz_netto`,`angebot`.`gesamtsumme` AS `umsatz_brutto`,'0' AS `erloes_netto`,`angebot`.`deckungsbeitrag` AS `deckungsbeitrag`,'0' AS `provision_summe`,`angebot`.`vertriebid` AS `vertriebid`,'0' AS `gruppe`,`angebot`.`projekt` AS `projekt` from `angebot`"
|
||||
"Create": "CREATE ALGORITHM=UNDEFINED DEFINER=`openxe`@`localhost` SQL SECURITY DEFINER VIEW `belegegesamt` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`soll` AS `umsatz_brutto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe`,`rechnung`.`projekt` AS `projekt` from `rechnung` union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,(`gutschrift`.`umsatz_netto` * -(1)) AS `umsatz_netto*-1`,(`gutschrift`.`soll` * -(1)) AS `umsatz_brutto*-1`,(`gutschrift`.`erloes_netto` * -(1)) AS `erloes_netto*-1`,(`gutschrift`.`deckungsbeitrag` * -(1)) AS `deckungsbeitrag*-1`,(`gutschrift`.`provision_summe` * -(1)) AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe`,`gutschrift`.`projekt` AS `projekt` from `gutschrift` union all select `auftrag`.`id` AS `id`,`auftrag`.`adresse` AS `adresse`,`auftrag`.`datum` AS `datum`,`auftrag`.`belegnr` AS `belegnr`,`auftrag`.`status` AS `status`,`auftrag`.`land` AS `land`,'auftrag' AS `typ`,`auftrag`.`umsatz_netto` AS `umsatz_netto`,`auftrag`.`gesamtsumme` AS `umsatz_brutto`,`auftrag`.`erloes_netto` AS `erloes_netto`,`auftrag`.`deckungsbeitrag` AS `deckungsbeitrag`,`auftrag`.`provision_summe` AS `provision_summe`,`auftrag`.`vertriebid` AS `vertriebid`,`auftrag`.`gruppe` AS `gruppe`,`auftrag`.`projekt` AS `projekt` from `auftrag` union all select `bestellung`.`id` AS `id`,`bestellung`.`adresse` AS `adresse`,`bestellung`.`datum` AS `datum`,`bestellung`.`belegnr` AS `belegnr`,`bestellung`.`status` AS `status`,`bestellung`.`land` AS `land`,'bestellung' AS `typ`,`bestellung`.`gesamtsumme` AS `umsatz_netto`,`bestellung`.`gesamtsumme` AS `umsatz_brutto`,'0' AS `erloes_netto`,'0' AS `deckungsbeitrag`,'0' AS `provision_summe`,'0' AS `vertriebid`,'0' AS `gruppe`,`bestellung`.`projekt` AS `projekt` from `bestellung` union all select `lieferschein`.`id` AS `id`,`lieferschein`.`adresse` AS `adresse`,`lieferschein`.`datum` AS `datum`,`lieferschein`.`belegnr` AS `belegnr`,`lieferschein`.`status` AS `status`,`lieferschein`.`land` AS `land`,'lieferschein' AS `typ`,'0' AS `umsatz_netto`,'0' AS `umsatz_brutto`,'0' AS `erloes_netto`,'0' AS `deckungsbeitrag`,'0' AS `provision_summe`,'0' AS `vertriebid`,'0' AS `gruppe`,`lieferschein`.`projekt` AS `projekt` from `lieferschein` union all select `angebot`.`id` AS `id`,`angebot`.`adresse` AS `adresse`,`angebot`.`datum` AS `datum`,`angebot`.`belegnr` AS `belegnr`,`angebot`.`status` AS `status`,`angebot`.`land` AS `land`,'angebot' AS `typ`,`angebot`.`umsatz_netto` AS `umsatz_netto`,`angebot`.`gesamtsumme` AS `umsatz_brutto`,'0' AS `erloes_netto`,`angebot`.`deckungsbeitrag` AS `deckungsbeitrag`,'0' AS `provision_summe`,`angebot`.`vertriebid` AS `vertriebid`,'0' AS `gruppe`,`angebot`.`projekt` AS `projekt` from `angebot`"
|
||||
},
|
||||
{
|
||||
"name": "belegeregs",
|
||||
"type": "VIEW",
|
||||
"Create": "CREATE ALGORITHM=UNDEFINED DEFINER=`openxe`@`localhost` SQL SECURITY DEFINER VIEW `belegeregs` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe`,`rechnung`.`projekt` AS `projekt` from `rechnung` union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,`gutschrift`.`umsatz_netto` * -1 AS `umsatz_netto*-1`,`gutschrift`.`erloes_netto` * -1 AS `erloes_netto*-1`,`gutschrift`.`deckungsbeitrag` * -1 AS `deckungsbeitrag*-1`,`gutschrift`.`provision_summe` * -1 AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe`,`gutschrift`.`projekt` AS `projekt` from `gutschrift`"
|
||||
"Create": "CREATE ALGORITHM=UNDEFINED DEFINER=`openxe`@`localhost` SQL SECURITY DEFINER VIEW `belegeregs` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe`,`rechnung`.`projekt` AS `projekt` from `rechnung` union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,(`gutschrift`.`umsatz_netto` * -(1)) AS `umsatz_netto*-1`,(`gutschrift`.`erloes_netto` * -(1)) AS `erloes_netto*-1`,(`gutschrift`.`deckungsbeitrag` * -(1)) AS `deckungsbeitrag*-1`,(`gutschrift`.`provision_summe` * -(1)) AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe`,`gutschrift`.`projekt` AS `projekt` from `gutschrift`"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -94,6 +94,12 @@ if ($cli) {
|
||||
$force = false;
|
||||
}
|
||||
|
||||
if (in_array('-connection', $argv)) {
|
||||
$connection = true;
|
||||
} else {
|
||||
$connection = false;
|
||||
}
|
||||
|
||||
if (in_array('-s', $argv)) {
|
||||
$check_git = true;
|
||||
} else {
|
||||
@ -103,7 +109,7 @@ if ($cli) {
|
||||
$check_db = true;
|
||||
} else {
|
||||
}
|
||||
|
||||
|
||||
if (in_array('-do', $argv)) {
|
||||
if (!$check_git && !$check_db) {
|
||||
$do_git = true;
|
||||
@ -118,7 +124,7 @@ if ($cli) {
|
||||
}
|
||||
|
||||
if ($check_git || $check_db || $do_git || $do_db) {
|
||||
upgrade_main($directory,$verbose,$check_git,$do_git,$export_db,$check_db,$do_db,$force);
|
||||
upgrade_main($directory,$verbose,$check_git,$do_git,$export_db,$check_db,$do_db,$force,$connection);
|
||||
} else {
|
||||
info();
|
||||
}
|
||||
@ -130,21 +136,38 @@ if ($cli) {
|
||||
}
|
||||
// -------------------------------- END
|
||||
|
||||
function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force) {
|
||||
function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection) {
|
||||
|
||||
class DatabaseConnectionInfo {
|
||||
function __construct($dir) {
|
||||
require($dir."/../conf/user.inc.php");
|
||||
if ($connection) {
|
||||
$connection_file_name = $directory."/data/connection.json";
|
||||
$connection_file_contents = file_get_contents($connection_file_name);
|
||||
if (!$connection_file_contents) {
|
||||
abort("Unable to load $connection_file_name");
|
||||
return(-1);
|
||||
}
|
||||
$connection_info = json_decode($connection_file_contents, true);
|
||||
|
||||
$host = $connection_info['host'];
|
||||
$user = $connection_info['user'];
|
||||
$passwd = $connection_info['passwd'];
|
||||
$schema = $connection_info['schema'];
|
||||
|
||||
} else {
|
||||
|
||||
class DatabaseConnectionInfo {
|
||||
function __construct($dir) {
|
||||
require($dir."/../conf/user.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
$dbci = new DatabaseConnectionInfo($directory);
|
||||
|
||||
$host = $dbci->WFdbhost;
|
||||
$user = $dbci->WFdbuser;
|
||||
$passwd = $dbci->WFdbpass;
|
||||
$schema = $dbci->WFdbname;
|
||||
}
|
||||
|
||||
$dbci = new DatabaseConnectionInfo($directory);
|
||||
|
||||
$host = $dbci->WFdbhost;
|
||||
$user = $dbci->WFdbuser;
|
||||
$passwd = $dbci->WFdbpass;
|
||||
$schema = $dbci->WFdbname;
|
||||
|
||||
require_once($directory.'/../vendor/mustal/mustal_mysql_upgrade_tool.php');
|
||||
|
||||
$datafolder = $directory."/data";
|
||||
@ -435,6 +458,7 @@ function info() {
|
||||
echo_out("\t-do: execute all upgrades\n");
|
||||
echo_out("\t-v: verbose output\n");
|
||||
echo_out("\t-f: force override of existing files\n");
|
||||
echo_out("\t-connection use connection.json in data folder instead of user.inc.php\n");
|
||||
echo_out("\t-clean: (not yet implemented) create the needed SQL to remove items from the database not in the JSON\n");
|
||||
echo_out("\n");
|
||||
}
|
||||
|
2
vendor/mustal/mustal_mysql_upgrade_tool.php
vendored
2
vendor/mustal/mustal_mysql_upgrade_tool.php
vendored
@ -378,7 +378,7 @@ function mustal_compare_table_array(array $nominal, string $nominal_name, array
|
||||
|
||||
if ($found_view) {
|
||||
|
||||
if ($database_view['Create'] != $found_view['Create']) {
|
||||
if (trim($database_view['Create']) != trim($found_view['Create'])) {
|
||||
$compare_difference = array();
|
||||
$compare_difference['type'] = "View definition";
|
||||
$compare_difference[$nominal_name] = $database_view['name'];
|
||||
|
@ -38,25 +38,27 @@ class upgrade {
|
||||
$this->app->Tpl->Set('UPGRADE_VISIBLE', "hidden");
|
||||
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "hidden");
|
||||
|
||||
//function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection)
|
||||
|
||||
switch ($submit) {
|
||||
case 'check_upgrade':
|
||||
$this->app->Tpl->Set('UPGRADE_VISIBLE', "");
|
||||
unlink($logfile);
|
||||
upgrade_main("../upgrade",$verbose,true,false,true,false,$force);
|
||||
upgrade_main("../upgrade",$verbose,true,false,false,true,false,$force,false);
|
||||
break;
|
||||
case 'do_upgrade':
|
||||
unlink($logfile);
|
||||
upgrade_main("../upgrade",$verbose,true,true,true,true,$force);
|
||||
upgrade_main("../upgrade",$verbose,true,true,false,true,true,$force,false);
|
||||
break;
|
||||
case 'check_db':
|
||||
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
|
||||
unlink($logfile);
|
||||
upgrade_main("../upgrade",$db_verbose,false,false,true,false,$force);
|
||||
upgrade_main("../upgrade",$db_verbose,false,false,false,true,false,$force,false);
|
||||
break;
|
||||
case 'do_db_upgrade':
|
||||
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
|
||||
unlink($logfile);
|
||||
upgrade_main("../upgrade",$db_verbose,false,false,true,true,$force);
|
||||
upgrade_main("../upgrade",$db_verbose,false,false,false,true,true,$force,false);
|
||||
break;
|
||||
case 'refresh':
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user