Skip to content

Commit

Permalink
Allow to set default dbms (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandevo authored Jan 24, 2022
1 parent 9cc5dc9 commit f9c3a27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Evolve/Evolve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ public class Evolve : IEvolveConfiguration
/// </summary>
/// <param name="dbConnection"> The database connection used to apply the migrations. </param>
/// <param name="logDelegate"> An optional logger. </param>
public Evolve(DbConnection dbConnection, Action<string>? logDelegate = null)
/// <param name="dbms"> Optional default dbms</param>
public Evolve(DbConnection dbConnection, Action<string>? logDelegate = null, DBMS? dbms = null)
{
_userCnn = Check.NotNull(dbConnection, nameof(dbConnection));
_log = logDelegate ?? new Action<string>((msg) => { });

using var evolveCnn = new WrappedConnection(_userCnn).Validate();
DBMS = evolveCnn.GetDatabaseServerType();
DBMS = dbms ?? evolveCnn.GetDatabaseServerType();
}

#region IEvolveConfiguration
Expand Down
3 changes: 2 additions & 1 deletion test/Evolve.Tests/Integration/PostgreSQL/MigrationTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using EvolveDb.Dialect;
using EvolveDb.Tests.Infrastructure;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -30,7 +31,7 @@ public void Run_all_PostgreSQL_migrations_work()
// Arrange
string[] locations = AppVeyor ? new[] { PostgreSQL.MigrationFolder } : new[] { PostgreSQL.MigrationFolder, PostgreSQL.Migration11Folder }; // Add specific PostgreSQL 11 scripts
var cnn = _dbContainer.CreateDbConnection();
var evolve = new Evolve(cnn, msg => _output.WriteLine(msg))
var evolve = new Evolve(cnn, msg => _output.WriteLine(msg), DBMS.PostgreSQL)
{
Schemas = new[] { "public", "unittest" },
MetadataTableSchema = "unittest",
Expand Down

0 comments on commit f9c3a27

Please sign in to comment.