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> /// Checks if the user's .db file has all the columns from the database model. /// </summary> /// <returns></returns> public static bool HasAllColumns() { return(DLDatabase.HasAllColumns()); }