Skip to content

Commit

Permalink
Version 8.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JonPSmith committed Nov 9, 2024
1 parent 3a9e29d commit cb75b06
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
6 changes: 3 additions & 3 deletions EfSchemaCompare/EfSchemaCompare.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<Description>Useful tool if you are changing the schema of your database's schema outside of EF Core' migrations, say by using SQL change scripts. See readme file on github.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>
- The ExtraInDatabase errors didn't correctly say what part of the database (e.g. "Table", "Column") was extra. This is fixed.
- NOTE: If you have ignored some ExtraInDatabase errors you our old ignored ExtraInDatabase might need updating to the new (correct format) pattern.
- New boolean 'AlwaysRunStage2' in the CompareEfSqlConfig. If set to 'true', then Stage 2 will always run, even if there are non-ignored errors.
- The ExtraInDatabase errors didn't correctly say what part of the database (e.g. "Table", "Column") was extra. This is fixed.
- NOTE: If you have ignored some ExtraInDatabase errors you our old ignored ExtraInDatabase might need updating to the new (correct format) pattern.
- New boolean 'AlwaysRunStage2' in the CompareEfSqlConfig. If set to 'true', then Stage 2 will always run, even if there are non-ignored errors. See issue #38, which made me add this new feature.
</PackageReleaseNotes>
<Copyright>Copyright (c) 2020 Jon P Smith. Licenced under MIT licence</Copyright>
<PackageTags>Entity Framework Core, Database</PackageTags>
Expand Down
36 changes: 36 additions & 0 deletions Test/UnitTests/TestExtraInDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,42 @@ public void DecodeCompareTextToCompareLog_ExtraIndexInDatabase_Test()
compareLog.Type.ShouldEqual(CompareType.Index);
}

[Theory]
[InlineData(false, 1)]
[InlineData(true, 3)]
public void TestAlwaysRunStage2(bool runStage, int numErrors)
{
//SETUP
var options = this.CreateUniqueClassOptions<BookContext>();
using var context = new BookContext(options);
context.Database.EnsureClean();

//Stage 1 error: Change Column on existing table
var filepath1 = TestData.GetFilePath("RenameColumn.sql");
context.ExecuteScriptFileInTransaction(filepath1);
//Stage 2 error: Add new table
var filepath2 = TestData.GetFilePath("AddExtraTable.sql");
context.ExecuteScriptFileInTransaction(filepath2);

//ATTEMPT
var config = new CompareEfSqlConfig
{
TablesToIgnoreCommaDelimited = "",
AlwaysRunStage2 = runStage
};
var comparer = new CompareEfSql(config);
var hasErrors = comparer.CompareEfWithDb(context);

//VERIFY
hasErrors.ShouldBeTrue();
var errors = comparer.GetAllErrors.Split("\r\n");
foreach (var error in errors)
{
_output.WriteLine(error);
}
errors.Length.ShouldEqual(numErrors);
}

[Fact]
public void TestExtraTable()
{
Expand Down

0 comments on commit cb75b06

Please sign in to comment.