Skip to content

Commit

Permalink
V2.3.2 (#35)
Browse files Browse the repository at this point in the history
* Version 2.3.2
  • Loading branch information
chullybun committed Feb 10, 2023
1 parent 1daec86 commit 32002ac
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Represents the **NuGet** versions.

## v2.3.2
- *Fixed:* The `DotNetType` and `SqlType` property value determination has been improved; removed explicit `Prepare` to simplify.
- *Fixed:* Added `MigrationArgsBase.AcceptPrompts` to programmatically set the equivalent of the `--accept-prompts` command-line option.

## v2.3.1
- *Fixed:* Added `IDisposable` to `DatabaseMigrationBase` to ensure underlying database connections are correctly disposed (via `IDatabase.Dispose`).
- *Fixed:* `DatabaseJournal` updated to use `DatabaseMigrationBase.ReplaceSqlRuntimeParameters` versus own limited implementation.
Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.3.1</Version>
<Version>2.3.2</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
4 changes: 2 additions & 2 deletions src/DbEx/Console/MigrationConsoleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ public async Task<int> RunAsync(string[] args, CancellationToken cancellationTok
{
if (Args.MigrationCommand.HasFlag(MigrationCommand.Drop))
{
if (!Prompt.GetYesNo("DROP: Confirm that where the specified database already exists it should be dropped?", false, ConsoleColor.Yellow))
if (!Args.AcceptPrompts && !Prompt.GetYesNo("DROP: Confirm that where the specified database already exists it should be dropped?", false, ConsoleColor.Yellow))
return new ValidationResult("Database drop was not confirmed; no execution occurred.");
}
else if (Args.MigrationCommand.HasFlag(MigrationCommand.Reset))
{
if (!Prompt.GetYesNo("RESET: Confirm that the existing data within the database should be reset (deleted)?", false, ConsoleColor.Yellow))
if (!Args.AcceptPrompts && !Prompt.GetYesNo("RESET: Confirm that the existing data within the database should be reset (deleted)?", false, ConsoleColor.Yellow))
return new ValidationResult("Data reset was not confirmed; no execution occurred.");
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/DbEx/Console/MigrationConsoleBaseT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,15 @@ public TSelf Supports(MigrationCommand supportedCommands)
SupportedCommands = supportedCommands;
return (TSelf)this;
}

/// <summary>
/// Indicates whether to automatically accept any confirmation prompts (command-line execution only).
/// </summary>
/// <returns>The current instance to supported fluent-style method-chaining.</returns>
public TSelf AcceptsPrompts()
{
Args.AcceptPrompts = true;
return (TSelf)this;
}
}
}
1 change: 0 additions & 1 deletion src/DbEx/DatabaseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public static async Task<List<DbTableSchema>> SelectSchemaAsync(this IDatabase d
tables.Add(table = dt);
var dc = databaseSchemaConfig.CreateColumnFromInformationSchema(table, dr);
dc.Prepare();
table.Columns.Add(dc);
return 0;
}, cancellationToken).ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion src/DbEx/DbEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx.Database" Version="2.0.0" />
<PackageReference Include="CoreEx.Database" Version="2.5.0" />
<PackageReference Include="dbup-sqlserver" Version="4.6.0" />
<PackageReference Include="OnRamp" Version="1.0.6" />
</ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions src/DbEx/DbSchema/DbColumnSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ public DbColumnSchema(DbTableSchema dbTable, string name, string type)
/// <summary>
/// Gets the corresponding .NET <see cref="System.Type"/> name.
/// </summary>
public string DotNetType => _dotNetType ?? throw new InvalidOperationException($"The {nameof(Prepare)} must be invoked before the {nameof(DotNetType)} property can be accessed.");
public string DotNetType => _dotNetType ?? DbTable?.Config.ToDotNetTypeName(this) ?? throw new InvalidOperationException($"The {nameof(DbTable)} must be set before the {nameof(DotNetType)} property can be accessed.");

/// <summary>
/// Gets the fully defined SQL type.
/// </summary>
public string SqlType => _sqlType ?? throw new InvalidOperationException($"The {nameof(Prepare)} must be invoked before the {nameof(DotNetType)} property can be accessed.");
public string SqlType => _sqlType ?? DbTable?.Config.ToFormattedSqlType(this) ?? throw new InvalidOperationException($"The {nameof(DbTable)} must be set before the {nameof(SqlType)} property can be accessed.");

/// <summary>
/// Prepares the schema by updating the calcuated properties: <see cref="DotNetType"/> and <see cref="SqlType"/>.
Expand Down Expand Up @@ -179,7 +179,8 @@ public void CopyFrom(DbColumnSchema column)
ForeignColumn = column.ForeignColumn;
IsForeignRefData = column.IsForeignRefData;
ForeignRefDataCodeColumn = column.ForeignRefDataCodeColumn;
Prepare();
_dotNetType = column._dotNetType;
_sqlType = column._sqlType;
}
}
}
5 changes: 5 additions & 0 deletions src/DbEx/Migration/MigrationArgsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public abstract class MigrationArgsBase : OnRamp.CodeGeneratorDbArgsBase
/// </summary>
public List<string>? ExecuteStatements { get; set; }

/// <summary>
/// Indicates whether to automatically accept any confirmation prompts (command-line execution only).
/// </summary>
public bool AcceptPrompts { get; set; }

/// <summary>
/// Gets or sets the <see cref="MigrationCommand.Reset"/> table filtering predicate.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion tests/DbEx.Test/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"EmptyDb": "Data Source=.;Initial Catalog=DbEx.Empty;Integrated Security=True;TrustServerCertificate=true",
"ErrorDb": "Data Source=.;Initial Catalog=DbEx.Error;Integrated Security=True;TrustServerCertificate=true",
"ConsoleDb": "Data Source=.;Initial Catalog=DbEx.Console;Integrated Security=True;TrustServerCertificate=true",
"MySqlDb": "Server=localhost; Port=3306; Database=dbex_test; Uid=dbuser; Pwd=dbpassword;"
"MySqlDb": "Server=localhost; Port=3306; Database=DbEx_Test; Uid=dbuser; Pwd=dbpassword;"

// WSL ...
//"NoneDb": "Data Source=localhost,1433;Initial Catalog=DbEx.None;User id=sa;Password=yourStrong(!)Password;TrustServerCertificate=true",
Expand Down

0 comments on commit 32002ac

Please sign in to comment.