[chronojump] DB -> 1.18 delete negative runInterval runs



commit 6c8cca5d4caad2aab3f0890c13d26a1e19cec5ed
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Dec 17 19:13:13 2014 +0100

    DB -> 1.18 delete negative runInterval runs

 src/sqlite/main.cs       |   15 +++++++++++++--
 src/sqlite/oldConvert.cs |    9 +++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index e15eb07..6382ed0 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -72,9 +72,8 @@ class Sqlite
 
        /*
         * Important, change this if there's any update to database
-        * Important2: if database version get numbers higher than 1, check if the comparisons with 
currentVersion works ok
         */
-       static string lastChronojumpDatabaseVersion = "1.17";
+       static string lastChronojumpDatabaseVersion = "1.18";
 
        public Sqlite() {
        }
@@ -1720,6 +1719,17 @@ class Sqlite
 
                                currentVersion = "1.17";
                        }
+                       if(currentVersion == "1.17") {
+                               Sqlite.Open();
+                       
+                               Log.WriteLine("Deleted Negative runInterval runs (bug from last version)");
+
+                               SqliteOldConvert.deleteNegativeRuns();
+                               SqlitePreferences.Update ("databaseVersion", "1.18", true); 
+                               Sqlite.Close();
+
+                               currentVersion = "1.18";
+                       }
        
                }
 
@@ -1864,6 +1874,7 @@ class Sqlite
                SqliteExecuteAuto.addChronojumpProfileAndBilateral();
                
                //changes [from - to - desc]
+               //1.18 - 1.18 Converted DB to 1.18 deleted Negative runInterval runs (bug from last version)
                //1.16 - 1.17 Converted DB to 1.17 Deleted Max jump (we already have "Free")
                //1.15 - 1.16 Converted DB to 1.16 Cyprus moved to Europe
                //1.14 - 1.15 Converted DB to 1.15 added Chronojump profile and bilateral profile
diff --git a/src/sqlite/oldConvert.cs b/src/sqlite/oldConvert.cs
index bdaeeae..4e57d47 100644
--- a/src/sqlite/oldConvert.cs
+++ b/src/sqlite/oldConvert.cs
@@ -316,6 +316,15 @@ class SqliteOldConvert : Sqlite
 
                return array;
        }
+
+       //DB 1.17 -> 1.18       
+       protected internal static void deleteNegativeRuns() 
+       {
+               dbcmd.CommandText = "Delete FROM " + Constants.RunIntervalTable +
+                       " WHERE timeTotal < 0";
+               Log.WriteLine(dbcmd.CommandText.ToString());
+               dbcmd.ExecuteNonQuery();
+       }
 }
 
 //used in DB version 1.03 and before


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]