Skip to content

Commit

Permalink
Deprecate dbup dependency (#21)
Browse files Browse the repository at this point in the history
* Initial deprecation.

* Further tweaks.

* Update version and tests.

* Update CI

* Update documentation and dbup references.

* Update version no.
Hash name for perf.

Signed-off-by: Eric Sibly [chullybun] <[email protected]>
  • Loading branch information
chullybun committed Sep 6, 2022
1 parent e2a80e9 commit 3c930d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/DbEx/DbEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>DbEx</RootNamespace>
<Version>1.0.13</Version>
<Version>1.0.14</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>DbEx Developers</Authors>
<Company>Avanade</Company>
Expand Down
5 changes: 5 additions & 0 deletions src/DbEx/Migration/DatabaseMigrationScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public DatabaseMigrationScript(string sql, string name)
/// <remarks><c>true</c> to run always; otherwise, <c>false</c> to run once (default).</remarks>
public bool RunAlways { get; set; }

/// <summary>
/// Gets or sets additional tag text to output to the log.
/// </summary>
public string? Tag { get; set; }

/// <summary>
/// Gets the resource or file <see cref="System.IO.StreamReader"/>.
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions src/DbEx/Migration/SqlServer/SqlServerMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected override async Task<bool> DatabaseSchemaAsync(List<DatabaseMigrationSc
Logger.LogInformation(" Create known schema objects...");
foreach (var sor in list.OrderBy(x => 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);
Expand Down Expand Up @@ -179,20 +179,20 @@ protected override async Task<bool> DatabaseDataAsync(List<DataTable> dataTables
public override async Task<bool> ExecuteScriptsAsync(IEnumerable<DatabaseMigrationScript> scripts, bool includeExecutionLogging)
{
await Journal.EnsureExistsAsync().ConfigureAwait(false);
IEnumerable<string>? previous = null;
HashSet<string>? 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
{
Expand Down

0 comments on commit 3c930d1

Please sign in to comment.