public static void CreateDatabaseIfNotExist() { if (!System.IO.File.Exists(IOVariables.databaseFile)) { DLDatabase.CreateDatabase(); } else { //great! the .db file exists. Now lets check if the user's .db file is up-to-date. let's see if the reminder table has all the required columns. if (DLDatabase.HasAllTables()) { if (!DLDatabase.HasAllColumns()) { DLDatabase.InsertNewColumns(); //not up to date. insert ! } } else { DLDatabase.InsertMissingTables(); //re-run the method, since the .db file **should** now have all the tables. CreateDatabaseIfNotExist(); } } }
/// <summary> /// This method will insert missing columns into the table reminder. Will only be called if HasallColumns() returns false. This means the user has an outdated .db file /// </summary> public static void InsertNewColumns() { DLDatabase.InsertNewColumns(); }