diff --git a/src/DbEx/DbEx.csproj b/src/DbEx/DbEx.csproj index 6a4473d..eed5297 100644 --- a/src/DbEx/DbEx.csproj +++ b/src/DbEx/DbEx.csproj @@ -3,7 +3,7 @@ netstandard2.1 DbEx - 1.0.13 + 1.0.14 true DbEx Developers Avanade diff --git a/src/DbEx/Migration/DatabaseMigrationScript.cs b/src/DbEx/Migration/DatabaseMigrationScript.cs index ac82da8..901ede7 100644 --- a/src/DbEx/Migration/DatabaseMigrationScript.cs +++ b/src/DbEx/Migration/DatabaseMigrationScript.cs @@ -66,6 +66,11 @@ public DatabaseMigrationScript(string sql, string name) /// true to run always; otherwise, false to run once (default). public bool RunAlways { get; set; } + /// + /// Gets or sets additional tag text to output to the log. + /// + public string? Tag { get; set; } + /// /// Gets the resource or file . /// diff --git a/src/DbEx/Migration/SqlServer/SqlServerMigrator.cs b/src/DbEx/Migration/SqlServer/SqlServerMigrator.cs index f403e3f..d42b8a1 100644 --- a/src/DbEx/Migration/SqlServer/SqlServerMigrator.cs +++ b/src/DbEx/Migration/SqlServer/SqlServerMigrator.cs @@ -133,7 +133,7 @@ protected override async Task DatabaseSchemaAsync(List x.SchemaOrder).ThenBy(x => x.TypeOrder).ThenBy(x => x.Name)) { - ss.Add(new DatabaseMigrationScript(sor.GetSql(), sor.ScriptName) { GroupOrder = i++, RunAlways = true }); + ss.Add(new DatabaseMigrationScript(sor.GetSql(), sor.ScriptName) { GroupOrder = i++, RunAlways = true, Tag = $">> CREATE {sor.Type} [{sor.Schema}].[{sor.Name}]" }); } return await ExecuteScriptsAsync(ss, true).ConfigureAwait(false); @@ -179,20 +179,20 @@ protected override async Task DatabaseDataAsync(List dataTables public override async Task ExecuteScriptsAsync(IEnumerable scripts, bool includeExecutionLogging) { await Journal.EnsureExistsAsync().ConfigureAwait(false); - IEnumerable? previous = null; + HashSet? previous = null; bool somethingExecuted = false; foreach (var script in scripts.OrderBy(x => x.GroupOrder).ThenBy(x => x.Name)) { if (!script.RunAlways) { - previous ??= await Journal.GetExecutedScriptsAsync(default).ConfigureAwait(false); - if (previous.Any(x => x == script.Name)) + previous ??= new(await Journal.GetExecutedScriptsAsync(default).ConfigureAwait(false)); + if (previous.Contains(script.Name)) continue; } if (includeExecutionLogging) - Logger.LogInformation(" {Content}", script.Name); + Logger.LogInformation(" {Content} {Tag}", script.Name, script.Tag ?? ""); try {