Skip to content

Commit

Permalink
v2.3.7 (#41)
Browse files Browse the repository at this point in the history
* Fix data reset issue.

* Fix spelling.

* Include sys schemd in filter.
  • Loading branch information
chullybun committed Aug 13, 2023
1 parent 3a45b9e commit ee77a1b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

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.6</Version>
<Version>2.3.7</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
7 changes: 2 additions & 5 deletions src/DbEx.SqlServer/Migration/SqlServerMigration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
Expand Down Expand Up @@ -104,7 +100,8 @@ protected override async Task<bool> DatabaseResetAsync(CancellationToken cancell
}

/// <inheritdoc/>
protected override Func<DbTableSchema, bool> DataResetFilterPredicate => schema => !_resetBypass.Contains(schema.QualifiedName!);
protected override Func<DbTableSchema, bool> DataResetFilterPredicate =>
schema => !_resetBypass.Contains(schema.QualifiedName!) && schema.Schema != "sys" && schema.Schema != "cdc" && !(schema.Schema == "dbo" && schema.Name.StartsWith("sys"));

/// <inheritdoc/>
protected override async Task ExecuteScriptAsync(DatabaseMigrationScript script, CancellationToken cancellationToken = default)
Expand Down
10 changes: 10 additions & 0 deletions src/DbEx/Migration/MigrationArgsBaseT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public TSelf AddAssembly(params Type[] types)
/// </summary>
public TSelf AddAssembly<TAssembly>() => AddAssembly(typeof(TAssembly));

/// <summary>
/// Adds the <typeparamref name="TAssembly1"/> and <typeparamref name="TAssembly2"/> (being the underlying <see cref="Type.Assembly"/>) to <see cref="MigrationArgsBase.Assemblies"/>.
/// </summary>
public TSelf AddAssembly<TAssembly1, TAssembly2>() => AddAssembly(typeof(TAssembly1), typeof(TAssembly2));

/// <summary>
/// Adds the <typeparamref name="TAssembly1"/>, <typeparamref name="TAssembly2"/> and <typeparamref name="TAssembly3"/> (being the underlying <see cref="Type.Assembly"/>) to <see cref="MigrationArgsBase.Assemblies"/>.
/// </summary>
public TSelf AddAssembly<TAssembly1, TAssembly2, TAssembly3>() => AddAssembly(typeof(TAssembly1), typeof(TAssembly2), typeof(TAssembly3));

/// <summary>
/// Adds a parameter to the <see cref="MigrationArgsBase.Parameters"/> where it does not already exist; unless <paramref name="overrideExisting"/> is selected then it will add or override.
/// </summary>
Expand Down

0 comments on commit ee77a1b

Please sign in to comment.