- add support for .net 8 and .NET 9 (when stable version is out)
- monthly updates of all packages for stability and security
- add support for .net 7
- monthly update of all packages for stability and security
EasyDBMigrator is an open-source database migration framework. It strongly favors simplicity and ease of use for automatic CI/CD strategies and local integration testing scenarios and easy integration in its own code.
- Make it easy to integrate Microsoft SQL migrations in your CI/CD flows
- Make it easy to integrate Postgre SQL migrations in your CI/CD flows
- Make it easy to perform manual Microsoft SQL migrations
- Make it easy to perform manual Postgre SQL migrations
- Make it easy to integrate this package into your own code/tool
- Provide examples of how to write unit and integration tests (feel free to give me code feedback or for a good discussion on testing)
private async Task RunMigrations()
{
//Make sure you use the correct naming in your scripts, like:
// 20210926_001_AddEquipmentTable.sql --> script are ordered by date and then per sequence number. In this case, '001' is the sequence number.
//Make sure to set the BUILD-ACTION property of every migration SQL script to EMBEDDED RESOURCE
const string databaseName = "WorkoutIntegrationTests";
//Make sure that the 'Database = xxxx;' parameter is excluded in the connection-string
const string connectionstring = "some fancy connectionstring without database param";
MigrationConfiguration config = new MigrationConfiguration(connectionString: connectionstring, databaseName: databaseName);
//for writing the logging output from EasyDBMigrator to the test explorer output window
var logger = XUnitLoghelper.CreateLogger<DatabaseTests>(_testOutputHelper);
Mock<IDataTimeHelper> datetimeHelperMock = new Mock<IDataTimeHelper>();
DbMigrator migrator = DbMigrator.CreateForLocalIntegrationTesting(migrationConfiguration: config
, logger: loggerMock.Object
, dataTimeHelperMock: datetimeHelperMock.Object
, databaseConnector: new MicrosoftSqlConnector());
//can also use the PostgreSqlConnector to connect to PostgreSQL instead of Microsoft Sql Server
bool succeededDeletingDatabase = await migrator.TryDeleteDatabaseIfExistAsync(migrationConfiguration: config
, cancellationToken: token);
_ = succeededDeletingDatabase.Should().BeTrue();
bool succeededRunningMigrations = await migrator.TryApplyMigrationsAsync(typeOfClassWhereScriptsAreLocated: typeof(HereTheSQLServerScriptsCanBeFound)
, migrationConfiguration: config
, cancellationToken: token);
_ = succeededRunningMigrations.Should().BeTrue();
//download the code if you want to see examples of integration testing with easyDbMigrator
}
https://github.com/chucknorris/roundhouse
https://github.com/erikbra/grate
https://github.com/fluentmigrator/fluentmigrator
Free to use