diff --git a/CHANGELOG.md b/CHANGELOG.md index e050866..8430b98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ Represents the **NuGet** versions. +## v2.3.7 +- *Fixed:* `SqlServerMigration` updated to correct the `DataResetFilterPredicate` to exclude all tables within schema `cdc`, and exclude all tables within the `dbo` schema where the table name starts with `sys`. This is to ensure that the internal Change Data tables are not reset, and that any SQL Server system tables are not inadvertently reset. + ## v2.3.6 - *Enhancement:* Updated `CoreEx` to version `3.3.0`. diff --git a/Common.targets b/Common.targets index 8366021..39a4e91 100644 --- a/Common.targets +++ b/Common.targets @@ -1,6 +1,6 @@ - 2.3.6 + 2.3.7 preview Avanade Avanade diff --git a/src/DbEx.SqlServer/Migration/SqlServerMigration.cs b/src/DbEx.SqlServer/Migration/SqlServerMigration.cs index 9c503b6..f95e16a 100644 --- a/src/DbEx.SqlServer/Migration/SqlServerMigration.cs +++ b/src/DbEx.SqlServer/Migration/SqlServerMigration.cs @@ -48,10 +48,6 @@ public SqlServerMigration(MigrationArgsBase args) : base(args) // Add this assembly for probing. Args.AddAssemblyAfter(typeof(DatabaseMigrationBase).Assembly, typeof(SqlServerMigration).Assembly); - // Where no data reset predicate filter added then default to exclude 'dbo' and 'cdc'; where a dev needs to do all then they can override with following predicate: schema => true; - if (Args.DataResetFilterPredicate == null) - Args.DataResetFilterPredicate = schema => schema.Schema != "dbo" || schema.Schema != "cdc"; - // Defaults the schema object types unless already specified. if (SchemaObjectTypes.Length == 0) SchemaObjectTypes = new string[] { "TYPE", "FUNCTION", "VIEW", "PROCEDURE", "PROC" }; @@ -104,7 +100,8 @@ protected override async Task DatabaseResetAsync(CancellationToken cancell } /// - protected override Func DataResetFilterPredicate => schema => !_resetBypass.Contains(schema.QualifiedName!); + protected override Func DataResetFilterPredicate => + schema => !_resetBypass.Contains(schema.QualifiedName!) && schema.Schema != "sys" && schema.Schema != "cdc" && !(schema.Schema == "dbo" && schema.Name.StartsWith("sys")); /// protected override async Task ExecuteScriptAsync(DatabaseMigrationScript script, CancellationToken cancellationToken = default) diff --git a/src/DbEx/Migration/MigrationArgsBaseT.cs b/src/DbEx/Migration/MigrationArgsBaseT.cs index 362affd..9f707b2 100644 --- a/src/DbEx/Migration/MigrationArgsBaseT.cs +++ b/src/DbEx/Migration/MigrationArgsBaseT.cs @@ -45,6 +45,16 @@ public TSelf AddAssembly(params Type[] types) /// public TSelf AddAssembly() => AddAssembly(typeof(TAssembly)); + /// + /// Adds the and (being the underlying ) to . + /// + public TSelf AddAssembly() => AddAssembly(typeof(TAssembly1), typeof(TAssembly2)); + + /// + /// Adds the , and (being the underlying ) to . + /// + public TSelf AddAssembly() => AddAssembly(typeof(TAssembly1), typeof(TAssembly2), typeof(TAssembly3)); + /// /// Adds a parameter to the where it does not already exist; unless is selected then it will add or override. ///