Fixed upgrade

This commit is contained in:
Lukas Metzger 2017-02-19 12:10:53 +01:00
parent a105edc4ab
commit 77fa9a926d
3 changed files with 24 additions and 3 deletions

View file

@ -94,7 +94,7 @@ CREATE TABLE IF NOT EXISTS options (
DELETE FROM options where name='schema_version';
INSERT INTO options(name,value) VALUES ('schema_version', 3);
INSERT INTO options(name,value) VALUES ('schema_version', 4);
";
$sql["pgsql"]="
@ -180,7 +180,7 @@ CREATE TABLE IF NOT EXISTS options (
DELETE FROM options where name='schema_version';
INSERT INTO options(name,value) VALUES ('schema_version', 3);
INSERT INTO options(name,value) VALUES ('schema_version', 4);
";
try {

View file

@ -129,6 +129,27 @@ if(isset($input->action) && $input->action == "requestUpgrade") {
$db->commit();
}
if($currentVersion < 4) {
$sql["mysql"] = "
RENAME TABLE user TO users;
ALTER TABLE permissions CHANGE user userid INT(11);
UPDATE options SET value=4 WHERE name='schema_version';
";
$sql["pgsql"] = "UPDATE options SET value=4 WHERE name='schema_version';";
$queries = explode(";", $sql[$dbType]);
$db->beginTransaction();
foreach ($queries as $query) {
if (preg_replace('/\s+/', '', $query) != '') {
$db->exec($query);
}
}
$db->commit();
}
$retval['status'] = "success";
}

View file

@ -17,7 +17,7 @@
*/
function getExpectedVersion() {
return 3;
return 4;
}
function checkVersion($db) {