DbRewinder 0.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package DbRewinder --version 0.0.2
NuGet\Install-Package DbRewinder -Version 0.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DbRewinder" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DbRewinder --version 0.0.2
#r "nuget: DbRewinder, 0.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DbRewinder as a Cake Addin
#addin nuget:?package=DbRewinder&version=0.0.2

// Install DbRewinder as a Cake Tool
#tool nuget:?package=DbRewinder&version=0.0.2

Test On Push

DbRewinder

Db Rewinder is a time machine for reverting the integration tests data changes. It can be useful if you had integration tests that changes another integration tests data causing it to fail if running it in wrong order.

How it works

  1. When you call the install method, the service will generate a table to store reversion SQL commands for every database change.
  2. Then it will generate triggers for every table. These triggers will store in the previous generated table the commands for reversion.
  3. When you call rewind all reverse commands in that table will run, reverting all previous changes.

Suported Databases and Providers

Only MySql 8 with MysqlConnector has been tested.

Using it

Setup

  • You can setup it directly using the factory:
    var rewindService = DbRewinderServiceFactory.GetSyncService(DbRewinderProviderType.MySql,
        () => ContainerInstance.GetService<ICoreDbContext>().Database.GetDbConnection());

    // Or the async version:

    var rewindService = DbRewinderServiceFactory.GetAsyncService(DbRewinderProviderType.MySql,
        () => ContainerInstance.GetService<ICoreDbContext>().Database.GetDbConnection());

  • You can use it with Dependency Injection:

    serviceCollection.ConfigureRewinder(config => config
        .AddProvider(DbRewinderProviderType.MySql, serviceProvider => serviceProvider.GetService<IMyDbContext>().Database.GetConnection())
        .AddProvider(DbRewinderProviderType.MySql, _ => new MySqlConnection(connectionString2)));

    ...

    var syncService = serviceProvider.GetService<IDbRewinderSyncService>();
    
    //or
    
    var asyncService = serviceProvider.GetService<IDbRewinderAsyncService>();

  • Before start using the service you must run the install method once

    rewindService.Install();

Using

    
    rewindService.Install();

    // Do some changes

    rewindService.CreateCheckpoint("My Checkpoint 1"); 

    // Do some more changes

    rewindService.Rewind("My Checkpoint 1"); 

    // Do some more changes

    rewindService.CreateCheckpoint("My Checkpoint 2"); 

    // Do some more changes

    rewindService.Rewind(); // this will rewind all data changes since install call, 

Licence

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.3 278 2/10/2023
0.0.2 236 2/10/2023
0.0.1 246 2/7/2023
0.0.0 17,634 2/6/2023