Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

gui-based database version upgrade

  • Loading branch information...
commit bacbd02bc9cfb1f046b17bc68e90ec839e36c0ae 1 parent 32d56b9
Spiros Ioannou authored
View
4 index.php
@@ -3,7 +3,7 @@
//sivann at gmail.com 2008-2012
$version="1.6";
-$dbversion=2;
+$fordbversion=2;
/***********************************************************************/
$itdb_start=getmicrotime();
@@ -196,7 +196,7 @@ function getmicrotime() {
require('php/header.php');
-if (0 && $authstatus && (dbversion() != $dbversion)) {
+if ($authstatus && (dbversion() != $fordbversion)) {
echo "<body>";
require ("php/itdbupdate.php");
echo "</body>\n</html>\n";
View
1  init.php
@@ -101,6 +101,7 @@
$error = $dbh->errorInfo();
if($error[0] && isset($error[2])) echo "Error 00: ".$error[2]."<br>";
+//$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
//some configuration
$ret = $dbh->exec("PRAGMA case_sensitive_like = 0;");
View
85 php/itdbupdate.php
@@ -0,0 +1,85 @@
+<script>
+ $(document).ready(function() {
+
+ $('#updtbtn').click(function(){
+ $.ajax({
+ type: "POST",
+ cache: false,
+ //url: "itdbupdate.php",
+ //data: $('#profilesfrm').serialize(),
+ data: {update: '1'},
+ success: function(msg){
+ $('#messagetxt').html(msg);
+ }
+ });
+
+ });
+
+ });
+</script>
+
+<?php
+if (!isset($_POST['update'])) {
+?>
+ <div id=messagetxt style='margin-left:auto;margin-right:auto;width:800px;'>
+ <div style='background-color:#eee;border:1px solid #aaa;padding:5px;'>
+ <?php
+ if ($fordbversion < dbversion() ) {
+ echo "It seems that you have replaced the ITDB installation with an older version, but not the the database which is newer version than the software. This will probably lead to data corruption. Please update ITDB files to the newest version<br>\n";
+ }
+ else {
+ ?>
+ You have updated your ITDB installation (files). To complete the upgrade, database to the same version.<br>
+ Please take a backup of your database if you haven't done so yet right now, by downloading the file:
+ <a style='font-size:12px;' title='<?php te("Download DataBase file. Contains all data except uploaded files/documents");?>' href='getdb.php'>
+ <img src='images/database_save.png'> Download Database (SQLite)</a><br>
+ When finished, click <button id='updtbtn' type=submit>update</button> to update the database to the latest version.
+ <br>
+ </div>
+
+ <div style='background-color:#fee;margin-top:10px;border:1px solid #aaa;padding:5px;' >
+ <?php
+ echo "Database version=".dbversion()."<br>";
+ echo "Installation version=$fordbversion";
+ echo "</div>";
+ echo "</div>";
+
+ }
+ ?>
+<?php
+}
+else {
+
+ $updtdir="updates/db/";
+ $startversion=dbversion();
+
+ echo "Starting update process\n<ul>\n";
+ for ($v=$startversion+1 ; $v<=$fordbversion ; $v++) {
+ echo "<li>Updating to version $v:</li>";
+ $updtfile=$updtdir.($v-1)."_${v}.sql";
+ $sql = file_get_contents($updtfile);
+ $b=strlen($sql);
+ echo "<li>Reading update file: $updtfile ($b bytes)</li>\n";
+ if (!$b) exit;
+ //$dbh->beginTransaction(); //not here , some statements auto-commit
+ echo "<li>Applying updates</li>\n";
+ db_exec($dbh,$sql);
+ }
+ echo "</ul>\n";
+
+ if (dbversion()==$fordbversion) {
+ $s="Success!";
+ $c="#dfd";
+ }
+ else {
+ $s="Version Mismatch";
+ $c="#fdd";
+ }
+
+ echo "<div style='background-color:$c;margin-top:10px;border:1px solid #aaa;padding:5px;' >";
+ echo "$s<br>Database version=".dbversion()."<br>";
+ echo "Installation version=$fordbversion";
+ echo "</div>";
+ echo "<a href=''>Proceed to ITDB</a>";
+}
+?>
View
3  updates/db/1_2.sql
@@ -0,0 +1,3 @@
+begin transaction;
+update settings set dbversion=2;
+commit;
Please sign in to comment.
Something went wrong with that request. Please try again.