X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=update_db.php;h=498b24e663317d22c7044fca8d36b94637c7df99;hp=140dece629811ffa8b30a483a56b4bf387c6cfe7;hb=80f9422ddeba6ec513343cb0d4e314172d983fa3;hpb=c757506a0a598593115c377a6e4acf399f4d2b83 diff --git a/update_db.php b/update_db.php index 140dece..498b24e 100644 --- a/update_db.php +++ b/update_db.php @@ -1,4 +1,23 @@ + * + * This file is part of e-DoKo. + * + * e-DoKo is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * e-DoKo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with e-DoKo. If not, see . + * + */ + error_reporting(E_ALL); include_once("config.php"); /* needs to be first in list, since other includes use this */ @@ -9,7 +28,8 @@ include_once("./include/functions.php"); /* the rest */ config_check(); /* open the database */ -if(DB_open()<0) +$return = DB_open(); +if($return<0 && $return != -2) /* -2 = wrong DB version is ok */ exit(); /* only callable via cron or CLI */ @@ -17,7 +37,7 @@ if(isset($_SERVER['REMOTE_ADDR'])) exit(); $old_version = DB_get_version(); -$current_version = 1; +$current_version = 2; if($old_version < $current_version) echo "Will upgrade your database now:\n"; @@ -37,6 +57,17 @@ switch($old_version) " index (email))"); DB_query("UPDATE Version set version=1"); echo "Upgraded to version 1.\n"; + case 1: + /* add new rules */ + DB_query("ALTER TABLE Rulesets". + " ADD COLUMN `lowtrump` enum('poverty','cancel','none') default 'poverty' AFTER schweinchen"); + DB_query("ALTER TABLE Hand". + " MODIFY COLUMN `sickness` enum('wedding','nines','poverty','solo','lowtrump') default NULL"); + DB_query("ALTER TABLE Game". + " MODIFY COLUMN `status` enum('pre','play','gameover','cancel-timedout','cancel-nines','cancel-trump','cancel-noplay','cancel-lowtrump') default NULL"); + + DB_query("UPDATE Version set version=2"); + echo "Upgraded to version 2.\n"; } ?> \ No newline at end of file