/// <summary> /// Returns the migration script path from the /// config file (if available) or the default path. /// </summary> public string GetPath(ILogger log, IScriptsDirectoryPathArgs args) { if (args == null) { throw new ArgumentNullException("args"); } string path; if (!string.IsNullOrEmpty(args.ScriptsDirectoryPath)) { path = args.ScriptsDirectoryPath; } else { path = _configurationManager.AppSettings[AppSettingKeys.MigrateFolder]; } if (string.IsNullOrEmpty(path)) { if (log != null) { log.WriteWarning( "The " + AppSettingKeys.MigrateFolder + " setting was not present in the configuration file so the default " + DefaultMigrationScriptPath + " folder will be used instead."); } path = DefaultMigrationScriptPath; } VerifyAndCreatePath(path); return(path); }
public long GetNewVersionNumber(IMigrationDirectory migrationDirectory, IScriptsDirectoryPathArgs args) { long lastNumber = 0; // get the latest number in use IEnumerable <IMigrationScriptFile> scripts = migrationDirectory.GetScripts(args); if (scripts.Count() > 0) { lastNumber = scripts.Max(script => script.Version); } // increment and return return(lastNumber + 1); }
public long GetNewVersionNumber(IMigrationDirectory migrationDirectory, IScriptsDirectoryPathArgs args) { var v = long.Parse(DateTime.UtcNow.ToString("yyyyMMddHHmmss")); return(v); }
/// <summary> /// Returns a list of all the migration script file paths /// sorted by version number (ascending). /// </summary> public IEnumerable <IMigrationScriptFile> GetScripts(IScriptsDirectoryPathArgs args) { string[] files = Directory.GetFiles(GetPath(null, args), ScriptFileNamePattern); return(files.Select(x => (IMigrationScriptFile) new MigrationScriptFile(x)).OrderBy(x => x.Version)); }