/// <summary> /// migrate the DB to the latest version as determined by SQL scripts in FW\DataMigration. /// </summary> static public bool MigrateDB(string sDatabaseName) { if (!Globals.DatabaseExists(sDatabaseName)) { return(false); // Error message already handled. } int dstVer = 0; int srcVer = 0; // Get current version of database. string ssql = "select DbVer from [" + sDatabaseName + "].dbo.Version$"; using (SqlConnection oConn = Globals.Conn) using (SqlCommand oCommand = new SqlCommand(ssql, oConn)) using (SqlDataReader oReader = oCommand.ExecuteReader()) { while (oReader.Read()) { srcVer = Int32.Parse(oReader[0].ToString()); } } // Find highest migration destination version possible with current scripts. string sFolder = Globals.MigrationFolder; string[] files = Directory.GetFiles(sFolder, "200???To200???.sql"); foreach (string file in files) { int n = Int32.Parse(file.Substring(file.Length - 10, 6)); dstVer = n > dstVer ? n : dstVer; } // MigrateData gives error message if migration not needed, so avoid this. if (srcVer >= dstVer) { return(true); // No conversion needed. } try { IMigrateData migrateData = MigrateDataClass.Create(); migrateData.Migrate(sDatabaseName, dstVer, null); } catch { Console.WriteLine("Something went wrong during the migration."); return(false); } return(true); }
public MigrationConverter(IMigrateData <JToken> dataMigrator) { DataMigrator = dataMigrator; }
public VerifyingJsonDataMigrator(IMigrateData <JToken> inner) { _Inner = inner; }