https://github.com/retrodad0001/easydbmigrator
EasyDBMigrator - making SQL and PostgreSQL database migrations and integration testing easier with legacy systems
https://github.com/retrodad0001/easydbmigrator
database microsoft migation posrgresql sql-server
Last synced: about 1 year ago
JSON representation
EasyDBMigrator - making SQL and PostgreSQL database migrations and integration testing easier with legacy systems
- Host: GitHub
- URL: https://github.com/retrodad0001/easydbmigrator
- Owner: Retrodad0001
- License: mit
- Created: 2021-09-11T08:46:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-03-23T13:19:09.000Z (about 1 year ago)
- Last Synced: 2025-04-11T20:57:48.916Z (about 1 year ago)
- Topics: database, microsoft, migation, posrgresql, sql-server
- Language: C#
- Homepage:
- Size: 1000 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# The Latest news and Roadmap
## 4.0.x (the latest release)
- add support for .net 9 and removed the not supported .net versions
- is AOT compatible
! from version 4.0.2 on EasyDBMigrator will not use the Fluent Assertions package for internal testing. The reason is that Fluent Assertions is a commercial product now. EasyDBMigration will only use non-commercial opensource software.
## 3.0.x (the latest release)
- add support for .net 8 and
- monthly updates of all packages for stability and security
## 2.0.x
- add support for .net 7
- monthly update of all packages for stability and security
# INFO:
### Action (jobs):
[](https://github.com/Retrodad0001/EasyDbMigrator/actions/workflows/BuildTestDebug.yml)
[](https://github.com/Retrodad0001/EasyDbMigrator/actions/workflows/BuildRelease.yml)
[](https://github.com/Retrodad0001/EasyDbMigrator/actions/workflows/PackageAndReleaseMasterToNuGet.yml)
[](https://github.com/Retrodad0001/EasyDbMigrator/actions/workflows/codeql.yml)
### Code statistics:
[](https://codecov.io/gh/Retrodad0001/easydbmigrator)
### More info:
[](https://www.nuget.org/packages/Retrodad.EasyDbMigrator/)
[](https://www.nuget.org/packages/Retrodad.EasyDbMigrator/)
# EasyDBMigrator - making database migrations and integration testing easier
## What is EasyDBMigrator?
EasyDBMigrator is an open-source database migration framework. It strongly favors simplicity and ease of use for automatic CI/CD strategies, integration testing scenarios and easy integration in your own code.
## What do we want to accomplish?
1. Make it easy to integrate Microsoft SQL migrations in your CI/CD flows
2. Make it easy to integrate Postgre SQL migrations in your CI/CD flows
5. Make it easy to perform manual Microsoft SQL migrations
6. Make it easy to perform manual Postgre SQL migrations
7. Make it easy to integrate this package into your own code/tool
8. Provide examples of how to write unit and integration tests (feel free to give me code feedback or for a good discussion on testing)
## Get started with EasyDBMigrator :
### using easyDbMigrator for integration 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(_testOutputHelper);
Mock datetimeHelperMock = new Mock();
DbMigrator migrator = DbMigrator.CreateForLocalIntegrationTesting(migrationConfiguration: config
, logger: loggerMock.Object
, dateTimeHelperMock: 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
}
## FAQ
## Alternatives
https://github.com/erikbra/grate
https://github.com/fluentmigrator/fluentmigrator
## License
Free to use