protected override PendingItem BuildClasspathItem(ItemLocation location, string itemName, Stream content) { Match matchResult = ScriptNameRegex.Match(itemName); if (!matchResult.Success) { Log.WarnFormat("File name {0} does not match migration script naming convention and will be ignored.", itemName); return(null); } ItemType type = ScriptTypeUtils.ResolveType(matchResult.Groups[1].Value); string version = string.Join(string.Empty, matchResult.Groups[2].Value.Split('.', '_')); using (var reader = new StreamReader(content, Encoding.UTF8)) { string template = reader.ReadToEnd(); var item = new PendingItem { Id = version, Type = type, Version = version, Name = itemName, Content = PreprocessScriptTemplate(location, template), Checksum = StringUtils.ByteArrayToHex(HashUtils.GetMD5Hash(Encoding.UTF8.GetBytes(template))) }; Log.DebugFormat("Adding file {0} as update script with version {1}", itemName, version); return(item); } }
private AppliedItem BuildAppliedScript(SqlDataReader reader) { ItemType type = ScriptTypeUtils.ResolveType(reader.GetString(0)); string version = reader.GetString(1); return(new AppliedItem { Id = version, Type = type, Version = version, Name = reader.GetString(2), Executed = reader.GetDateTime(3), Checksum = reader.GetString(4) }); }