[chronojump] DB to 2.18 Person77 ALTER TABLE added field: linkServerImage (for networks)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] DB to 2.18 Person77 ALTER TABLE added field: linkServerImage (for networks)
- Date: Thu, 15 Apr 2021 10:37:28 +0000 (UTC)
commit a996de3bdb7abb1452fb974025eb6a6b61541d01
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Apr 15 12:36:32 2021 +0200
DB to 2.18 Person77 ALTER TABLE added field: linkServerImage (for networks)
src/gui/person/addModify.cs | 4 ++--
src/gui/person/addMultiple.cs | 3 ++-
src/person.cs | 19 +++++++++++++-----
src/sqlite/forceSensor.cs | 3 ++-
src/sqlite/main.cs | 46 ++++++++++++++++++++++++++++++++++++++++---
src/sqlite/person.cs | 19 +++++++++++-------
src/sqlite/personSession.cs | 8 +++++---
7 files changed, 80 insertions(+), 22 deletions(-)
---
diff --git a/src/gui/person/addModify.cs b/src/gui/person/addModify.cs
index 0ca75955..01972a00 100644
--- a/src/gui/person/addModify.cs
+++ b/src/gui/person/addModify.cs
@@ -1217,7 +1217,7 @@ public class PersonAddModifyWindow
Convert.ToInt32(Util.FindOnArray(':', 2, 0,
UtilGtk.ComboGetActive(combo_countries), countries)),
textview_description.Buffer.Text,
"", clubID, //future1: rfid; future2: clubID
- Constants.ServerUndefinedID, false); //dbconOpened
+ Constants.ServerUndefinedID, "", false); //dbconOpened
LogB.Information("Going to insert personSession");
currentPersonSession = new PersonSession (
@@ -1257,7 +1257,7 @@ public class PersonAddModifyWindow
Convert.ToInt32(Util.FindOnArray(':', 2, 0,
UtilGtk.ComboGetActive(combo_countries), countries)),
textview_description.Buffer.Text,
"", clubID, //future1: rfid; future2: clubID
- serverUniqueID);
+ serverUniqueID, currentPerson.LinkServerImage);
SqlitePerson.Update (currentPerson);
//we only need to update personSession
diff --git a/src/gui/person/addMultiple.cs b/src/gui/person/addMultiple.cs
index 44ab7e56..6e76dc2e 100644
--- a/src/gui/person/addMultiple.cs
+++ b/src/gui/person/addMultiple.cs
@@ -594,7 +594,8 @@ public class PersonAddMultipleWindow
Constants.RaceUndefinedID,
Constants.CountryUndefinedID,
"", "", "", //description, future1: rfid,
future2: clubID
- Constants.ServerUndefinedID
+ Constants.ServerUndefinedID,
+ "" //linkServerImage
);
persons.Add(currentPerson);
diff --git a/src/person.cs b/src/person.cs
index e99eb080..e34a71e9 100644
--- a/src/person.cs
+++ b/src/person.cs
@@ -36,6 +36,7 @@ public class Person {
private string future1; //rfid
private string future2; //club ID, is an integer
private int serverUniqueID; //not on server
+ private string linkServerImage;
public Person() {
}
@@ -58,6 +59,7 @@ public class Person {
this.future1 = rfid;
//TODO: this.future2 = clubID;
this.serverUniqueID = Constants.ServerUndefinedID;
+ this.linkServerImage = "";
/*
* Before insertion check that uniqueID exists locally
@@ -66,14 +68,15 @@ public class Person {
if(insertPerson)
SqlitePerson.Insert(false,
uniqueID.ToString(), name, sex, dateBorn, race, countryID,
- description, future1, future2, serverUniqueID);
+ description, future1, future2, serverUniqueID, linkServerImage);
}
//suitable when we load a person from the database for being the current Person
//we know uniqueID
//used also in class PersonSessionTransaction where we define the uniqueID
public Person(int uniqueID, string name, string sex, DateTime dateBorn,
- int race, int countryID, string description, string future1, string future2, int
serverUniqueID)
+ int race, int countryID, string description,
+ string future1, string future2, int serverUniqueID, string linkServerImage)
{
//needed by the return of gui/personAddModifyWindow
name = Util.RemoveTildeAndColon(name);
@@ -89,13 +92,14 @@ public class Person {
this.future1 = future1;
this.future2 = future2;
this.serverUniqueID = serverUniqueID; //remember don't do this on server
+ this.linkServerImage = linkServerImage;
}
//typical constructor
//used when we create new person
//we don't know uniqueID
public Person(string name, string sex, DateTime dateBorn, int race, int countryID, string description,
- string future1, string future2, int serverUniqueID, bool dbconOpened)
+ string future1, string future2, int serverUniqueID, string linkServerImage, bool
dbconOpened)
{
name = Util.RemoveTildeAndColon(name);
description = Util.RemoveTildeAndColon(description);
@@ -109,6 +113,7 @@ public class Person {
this.future1 = future1;
this.future2 = future2;
this.serverUniqueID = serverUniqueID; //remember don't do this on server
+ this.linkServerImage = linkServerImage;
//insert in the person table
//when insert as person we don't know uniqueID
@@ -124,7 +129,7 @@ public class Person {
public int InsertAtDB (bool dbconOpened, string tableName) {
int myID = SqlitePerson.Insert(dbconOpened,
uniqueID.ToString(), name, sex, dateBorn, race, countryID,
- description, future1, future2, serverUniqueID);
+ description, future1, future2, serverUniqueID, linkServerImage);
return myID;
}
@@ -150,7 +155,7 @@ public class Person {
return uniqueID.ToString() + ", '" + name + "', '" + sex + "', '" +
UtilDate.ToSql(dateBorn) + "', " + race + ", " + countryID + ", '" +
description + "', '" + future1 + "', '" + future2 + "', " +
- serverUniqueID;
+ serverUniqueID + ", '" + linkServerImage + "'";
}
@@ -213,6 +218,10 @@ public class Person {
set { serverUniqueID = value; }
}
+ public string LinkServerImage {
+ get { return linkServerImage; }
+ }
+
public int UniqueID {
get { return uniqueID; }
set { uniqueID = value; }
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index a81aa6d3..c6a35c04 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -320,7 +320,8 @@ class SqliteForceSensor : Sqlite
Constants.RaceUndefinedID,
Constants.CountryUndefinedID,
"", "", "", //description; future1: rfid;
future2: clubID
- Constants.ServerUndefinedID, true);
//dbconOpened
+ Constants.ServerUndefinedID, "",
//linkServerImage
+ true); //dbconOpened
unknownPersonID = pUnknown.UniqueID;
}
p.UniqueID = unknownPersonID;
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 0f2791f8..e87aedf5 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -129,7 +129,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "2.17";
+ static string lastChronojumpDatabaseVersion = "2.18";
public Sqlite()
{
@@ -1173,13 +1173,25 @@ class Sqlite
Sqlite.Close();
currentVersion = "0.76";
}
+
+ bool person77AddedLinkServerImage = false;
+
if(currentVersion == "0.76") {
Sqlite.Open();
+
+ //but first add migration from 2.17 to 2.18
+ LogB.SQL("Person77 adding field: linkServerImage (for networks)");
+ try {
+ executeSQL("ALTER TABLE " + Constants.PersonTable + " ADD COLUMN
linkServerImage TEXT;");
+ } catch {
+ LogB.SQL("Catched. maybe person77.linkServerImage already exists.");
+ }
+ person77AddedLinkServerImage = true;
convertPersonAndPersonSessionTo77();
SqlitePreferences.Update ("databaseVersion", "0.77", true);
LogB.SQL("Converted DB to 0.77 (person77, personSession77)");
-
+
Sqlite.Close();
currentVersion = "0.77";
}
@@ -2458,6 +2470,18 @@ class Sqlite
}
if(currentVersion == "1.68")
{
+ if(! person77AddedLinkServerImage)
+ {
+ //but first add migration from 2.17 to 2.18
+ LogB.SQL("Person77 adding field: linkServerImage (for networks)");
+ try {
+ executeSQL("ALTER TABLE " + Constants.PersonTable + " ADD
COLUMN linkServerImage TEXT;");
+ } catch {
+ LogB.SQL("Catched. maybe person77.linkServerImage already
exists.");
+ }
+ person77AddedLinkServerImage = true;
+ }
+
LogB.SQL("Imported force sensor text files into SQL");
SqliteForceSensor.import_from_1_68_to_1_69();
@@ -2927,7 +2951,21 @@ class Sqlite
currentVersion = updateVersion("2.17");
}
+ if(currentVersion == "2.17")
+ {
+ if(! person77AddedLinkServerImage)
+ {
+ LogB.SQL("Person77 adding field: linkServerImage (for networks)");
+ try {
+ executeSQL("ALTER TABLE " + Constants.PersonTable + " ADD
COLUMN linkServerImage TEXT;");
+ } catch {
+ LogB.SQL("Catched. maybe person77.linkServerImage already
exists.");
+ }
+ }
+
+ currentVersion = updateVersion("2.18");
+ }
@@ -3150,6 +3188,7 @@ class Sqlite
//just testing: 1.79 - 1.80 Converted DB to 1.80 Created table ForceSensorElasticBandGlue and moved
stiffnessString records there
+ //2.17 - 2.18 Converted DB to 2.18 Person77 ALTER TABLE added field: linkServerImage (for
networks)
//2.16 - 2.17 Converted DB to 2.17 Created table lastJumpRjTypeParams
//2.15 - 2.16 Converted DB to 2.16 Created table lastJumpSimpleTypeParams
//2.14 - 2.15 Converted DB to 2.15 Inserted into preferences: SessionLoadDisplay
@@ -3527,7 +3566,8 @@ class Sqlite
pOld.CountryID,
pOld.Description,
"", "", //future1: rfid; future2: clubID
- pOld.ServerUniqueID
+ pOld.ServerUniqueID,
+ "" //linkServerImage
);
p.InsertAtDB(true, Constants.PersonTable);
diff --git a/src/sqlite/person.cs b/src/sqlite/person.cs
index 7d1a2403..ea85988d 100644
--- a/src/sqlite/person.cs
+++ b/src/sqlite/person.cs
@@ -48,12 +48,13 @@ class SqlitePerson : Sqlite
"description TEXT, " +
"future1 TEXT, " + //rfid
"future2 TEXT, " + //clubID
- "serverUniqueID INT ) ";
+ "serverUniqueID INT, " +
+ "linkServerImage TEXT ) "; //for networks
dbcmd.ExecuteNonQuery();
}
public static int Insert(bool dbconOpened, string uniqueID, string name, string sex, DateTime
dateBorn,
- int race, int countryID, string description, string future1, string future2, int
serverUniqueID)
+ int race, int countryID, string description, string future1, string future2, int
serverUniqueID, string linkServerImage)
{
LogB.SQL("going to insert");
if(! dbconOpened)
@@ -66,9 +67,10 @@ class SqlitePerson : Sqlite
//ATTENTION: if this changes, change the Person.ToSQLInsertString()
// -----------------------
string myString = "INSERT INTO " + Constants.PersonTable +
- " (uniqueID, name, sex, dateBorn, race, countryID, description, future1, future2,
serverUniqueID) VALUES (" + uniqueID + ", \"" +
+ " (uniqueID, name, sex, dateBorn, race, countryID, description, future1, future2,
serverUniqueID, linkServerImage) VALUES (" + uniqueID + ", \"" +
name + "\", \"" + sex + "\", \"" + UtilDate.ToSql(dateBorn) + "\", " +
- race + ", " + countryID + ", \"" + description + "\", \"" + future1 + "\", \"" +
future2 + "\", " + serverUniqueID + ")";
+ race + ", " + countryID + ", \"" + description + "\", \"" +
+ future1 + "\", \"" + future2 + "\", " + serverUniqueID + ", \"" + linkServerImage +
"\")";
dbcmd.CommandText = myString;
LogB.SQL(dbcmd.CommandText.ToString());
@@ -125,7 +127,8 @@ class SqlitePerson : Sqlite
reader[6].ToString(), //description
reader[7].ToString(), //future1: rfid
reader[8].ToString(), //future2: clubID
- Convert.ToInt32(reader[9].ToString()) //serverUniqueID
+ Convert.ToInt32(reader[9].ToString()), //serverUniqueID
+ reader[10].ToString() //linkServerImage
);
}
reader.Close();
@@ -270,7 +273,8 @@ finishForeach:
reader2[6].ToString(), //description
reader2[7].ToString(), //future1: rfid
reader2[8].ToString(), //future2: clubID
- Convert.ToInt32(reader2[9].ToString()) //serverUniqueID
+ Convert.ToInt32(reader2[9].ToString()), //serverUniqueID
+ reader2[10].ToString() //linkServerImage
);
arrayReturn.Add(p);
}
@@ -635,7 +639,8 @@ finishForeach:
"\", future1 = \"" + myPerson.Future1 + //rfid
"\", future2 = \"" + myPerson.Future2 + //clubID
"\", serverUniqueID = " + myPerson.ServerUniqueID +
- " WHERE uniqueID == " + myPerson.UniqueID;
+ ", linkServerImage = \"" + myPerson.LinkServerImage + //linkServerImage
+ "\" WHERE uniqueID == " + myPerson.UniqueID;
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
Sqlite.Close();
diff --git a/src/sqlite/personSession.cs b/src/sqlite/personSession.cs
index 8dc4a957..7a335451 100644
--- a/src/sqlite/personSession.cs
+++ b/src/sqlite/personSession.cs
@@ -291,7 +291,8 @@ class SqlitePersonSession : Sqlite
reader[6].ToString(), //description
reader[7].ToString(), //future1: rfid
reader[8].ToString(), //future2: clubID
- Convert.ToInt32(reader[9].ToString()) //serverUniqueID
+ Convert.ToInt32(reader[9].ToString()), //serverUniqueID
+ reader[10].ToString() //linkServerImage
);
person_l.Add(person);
}
@@ -336,7 +337,8 @@ class SqlitePersonSession : Sqlite
reader[6].ToString(), //description
reader[7].ToString(), //future1: rfid
reader[8].ToString(), //future2: clubID
- Convert.ToInt32(reader[9].ToString()) //serverUniqueID
+ Convert.ToInt32(reader[9].ToString()), //serverUniqueID
+ reader[10].ToString() //linkServerImage
);
if(returnPersonAndPSlist) {
@@ -600,7 +602,7 @@ class SqlitePersonSessionTransaction : Sqlite
foreach(Person p in persons) {
dbcmdTr.CommandText =
"INSERT INTO " + Constants.PersonTable +
- " (uniqueID, name, sex, dateBorn, race, countryID,
description, future1, future2, serverUniqueID) " +
+ " (uniqueID, name, sex, dateBorn, race, countryID,
description, future1, future2, serverUniqueID, linkServerImage) " +
" VALUES (" + p.ToSQLInsertString() + ")";
LogB.SQL(dbcmdTr.CommandText.ToString());
dbcmdTr.ExecuteNonQuery();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]