// UpdateTo_3_4_1 forgot to add CountOrMeasure, TreeCount, and AverageHeight fields to // the Plot_Stratum table. This update checks to see if they need to be added and adds them // if missing private void UpdateTo_3_4_2(CruiseDatastore db) { var curVersion = db.DatabaseVersion; var targetVersion = "3.4.2"; if (db.CheckFieldExists("Plot_Stratum_Tombstone", "CountOrMeasure") is false) { db.BeginTransaction(); try { db.Execute("ALTER TABLE Plot_Stratum_Tombstone ADD COLUMN CountOrMeasure TEXT COLLATE NOCASE;"); db.Execute("ALTER TABLE Plot_Stratum_Tombstone ADD COLUMN TreeCount INTEGER Default 0;"); db.Execute("ALTER TABLE Plot_Stratum_Tombstone ADD COLUMN AverageHeight REAL Default 0.0;"); SetDatabaseVersion(db, targetVersion); db.CommitTransaction(); } catch (Exception e) { db.RollbackTransaction(); throw new SchemaUpdateException(curVersion, targetVersion, e); } } else { SetDatabaseVersion(db, targetVersion); } }
public static void Update_Impl(CruiseDatastore db) { var dbVersion = db.DatabaseVersion; if (string.IsNullOrWhiteSpace(dbVersion)) { throw new UpdateException("unable to determin file version"); } if (!CheckCanUpdate(dbVersion)) { throw new IncompatibleSchemaException($"The version of this cruise file ({dbVersion}) is not compatible with the version of the software you are using." + "Go to github.com/FMSC-Measurements to get the latest version of our software.", null); } if (dbVersion.StartsWith("2013") || dbVersion == "2014.01.21") { throw new IncompatibleSchemaException($"The version of this cruise file ({dbVersion}) is no longer supported." + "Go to github.com/FMSC-Measurements to get archived versions of our software.", null); } if (db.DatabaseVersion == "2014.03.12") { UpdateToVersion2014_06_04(db); } if (db.DatabaseVersion == "2014.06.04") { UpdateToVersion2014_07_02(db); } if (db.DatabaseVersion == "2014.07.02") { UpdateToVersion2014_07_07(db); } if (db.DatabaseVersion == "2014.07.07") { UpdateToVersion2014_07_17(db); } if (db.DatabaseVersion == "2014.07.17") { UpdateToVersion2014_07_24(db); } if (db.DatabaseVersion == "2014.07.24") { UpdateToVersion2014_08_20(db); } if (db.DatabaseVersion == "2014.08.20") { UpdateToVersion2014_09_02(db); } if (db.DatabaseVersion == "2014.09.02") { UpdateToVersion2014_10_01(db); } if (db.DatabaseVersion == "2014.10.01" || db.DatabaseVersion == "2015.01.05") { UpdateToVersion2015_04_28(db); } if (db.DatabaseVersion == "2015.04.28") { UpdateToVersion2015_08_03(db); } if (db.DatabaseVersion == "2015.06.01") { SetDatabaseVersion(db, "2015.08.03"); } if (db.DatabaseVersion == "2015.08.03") { UpdateToVersion2015_08_19(db); } if (db.DatabaseVersion == "2015.08.19") { UpdateToVersion2015_09_01(db); } if (db.DatabaseVersion == "2015.09.01" || db.DatabaseVersion == "2.0.0" || db.DatabaseVersion == "2.1.0") { UpdateTo_2_1_1(db); } if (db.DatabaseVersion.StartsWith("2.1.1")) { UpdateTo_2_1_2(db); } if (db.DatabaseVersion.StartsWith("2.1.2")) { UpdateTo_2_2_0(db); } // files updated to 2.5.0 may have corrupted data // attempt to patch them and set version to 2.5.1.1 if (db.DatabaseVersion.StartsWith("2.5.0")) { FixVersion_2_5_0(db); } if (db.DatabaseVersion.StartsWith("2.2.")) { UpdateTo_2_5_1(db); } if (db.DatabaseVersion.StartsWith("2.5.")) { UpdateTo_2_6_1(db); } if (db.DatabaseVersion.StartsWith("2.6.")) { UpdateTo_2_7_0(db); } if (db.DatabaseVersion == "2.7.0") { UpdateTo_2_7_1(db); } if (db.DatabaseVersion == "2.7.1" || db.DatabaseVersion == "2.7.3") { UpdateTo_2_7_3(db); } if (db.CheckFieldExists("Stratum", "HotKey") == false) { db.AddField("Stratum", new ColumnInfo("HotKey", "TEXT")); } }