Skip to content

Commit 29b2a75

Browse files
authored
Merge pull request #24 from drwatson1/net6
Support of .Net 6
2 parents 0f43942 + e34f718 commit 29b2a75

File tree

12 files changed

+67
-30
lines changed

12 files changed

+67
-30
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ The tool has almost all the features the DbUp has, but without a single line of
5959

6060
|Date|Version|Description|
6161
|-|-|-|
62+
|2022-05-10|1.6.6|Add support of .Net 6
6263
|2022-02-14|1.6.5|Support of DisableVars
6364
|2022-02-06|1.6.4|Support of drop and ensure for Azure SQL
6465
|2022-02-02|1.6.3|Support of AzureSQL integrated sequrity

src/dbup-cli.integration-tests/PostgreSqlTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public PostgreSqlTests()
2323
Env = new CliEnvironment();
2424
Logger = new CaptureLogsLogger();
2525

26-
Environment.SetEnvironmentVariable("CONNSTR", "Host=127.0.0.1;Database=dbup;Username=postgres;Password=PostgresPwd2019;Port=5432");
26+
Environment.SetEnvironmentVariable("CONNSTR", "Host=127.0.0.1;Database=dbup;Username=postgres;Password=PostgresPwd2019;Port=5432;Timeout=60;CommandTimeout=60");
2727
}
2828

2929
string GetBasePath(string subPath = "EmptyScript") =>
3030
Path.Combine(Assembly.GetExecutingAssembly().Location, $@"..\Scripts\PostgreSql\{subPath}");
3131

3232
string GetConfigPath(string name = "dbup.yml", string subPath = "EmptyScript") => new DirectoryInfo(Path.Combine(GetBasePath(subPath), name)).FullName;
3333

34-
Func<DbConnection> CreateConnection = () => new NpgsqlConnection("Host=127.0.0.1;Database=postgres;Username=postgres;Password=PostgresPwd2019;Port=5432");
34+
Func<DbConnection> CreateConnection = () => new NpgsqlConnection("Host=127.0.0.1;Database=postgres;Username=postgres;Password=PostgresPwd2019;Port=5432;Timeout=60;CommandTimeout=60");
3535

3636
[TestInitialize]
3737
public Task TestInitialize()
@@ -115,7 +115,6 @@ public void UpgradeCommand_ShouldUseConnectionTimeoutForLongrunningQueries()
115115
r.Should().Be(1);
116116
}
117117

118-
119118
[TestMethod]
120119
public void UpgradeCommand_ShouldUseASpecifiedJournal()
121120
{
@@ -125,7 +124,7 @@ public void UpgradeCommand_ShouldUseASpecifiedJournal()
125124
result.Should().Be(0);
126125

127126
using (var connection = new NpgsqlConnection(Environment.GetEnvironmentVariable("CONNSTR")))
128-
using (var command = new NpgsqlCommand("select count(*) from public.\"testTable\" where scriptname = '001.sql'", connection))
127+
using (var command = new NpgsqlCommand("select count(*) from public.journal where scriptname = '001.sql'", connection))
129128
{
130129
connection.Open();
131130
var count = command.ExecuteScalar();

src/dbup-cli.integration-tests/Scripts/PostgreSql/JournalTableScript/dbup.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ dbUp:
22
version: 1 # should be 1
33
provider: postgresql # DB provider: sqlserver
44
connectionString: $CONNSTR$ # Connection string to DB. For example, "Data Source=(localdb)\dbup;Initial Catalog=MyDb;Integrated Security=True" for sqlserver
5+
connectionTimeoutSec: 60
56
journalTo:
6-
schema: "public"
7-
table: "testTable"
7+
schema: public
8+
table: journal
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SELECT pg_sleep(60);
1+
SELECT pg_sleep(60);

src/dbup-cli.integration-tests/Scripts/PostgreSql/Timeout/dbup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ dbUp:
22
version: 1 # should be 1
33
provider: postgresql # DB provider: sqlserver
44
connectionString: $CONNSTR$ # Connection string to DB. For example, "Data Source=(localdb)\dbup;Initial Catalog=MyDb;Integrated Security=True" for sqlserver
5-
connectionTimeoutSec: 10 # Connection timeout in seconds
5+
connectionTimeoutSec: 10 # Connection timeout in seconds

src/dbup-cli.integration-tests/dbup-cli.integration-tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
5-
<RootNamespace>DbUp.Cli.IntegrationTests</RootNamespace>
4+
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
5+
<RootNamespace>DbUp.Cli.IntegrationTests</RootNamespace>
66

77
<IsPackable>false</IsPackable>
88
</PropertyGroup>

src/dbup-cli.tests.core/dbup-cli.tests.core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
5-
<RootNamespace>DbUp.Cli.Tests</RootNamespace>
4+
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
5+
<RootNamespace>DbUp.Cli.Tests</RootNamespace>
66
</PropertyGroup>
77

88
<ItemGroup>

src/dbup-cli.tests/dbup-cli.tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
5-
<RootNamespace>DbUp.Cli.Tests</RootNamespace>
4+
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
5+
<RootNamespace>DbUp.Cli.Tests</RootNamespace>
66

77
<IsPackable>false</IsPackable>
88

src/dbup-cli/ConfigurationHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static Option<bool, Error> EnsureDb(IUpgradeLog logger, Provider provider
7777
}
7878
catch (Exception ex)
7979
{
80-
return Option.None<bool, Error>(Error.Create(ex.Message));
80+
return Option.None<bool, Error>(Error.Create("EnsureDb failed: {0}", ex.Message));
8181
}
8282

8383
return Option.None<bool, Error>(Error.Create(Constants.ConsoleMessages.UnsupportedProvider, provider.ToString()));
@@ -110,7 +110,7 @@ public static Option<bool, Error> DropDb(IUpgradeLog logger, Provider provider,
110110
}
111111
catch (Exception ex)
112112
{
113-
return Option.None<bool, Error>(Error.Create(ex.Message));
113+
return Option.None<bool, Error>(Error.Create("DropDb failed: {0}", ex.Message));
114114
}
115115

116116
return Option.None<bool, Error>(Error.Create(Constants.ConsoleMessages.UnsupportedProvider, provider.ToString()));

src/dbup-cli/ResultBuilder.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Optional;
2+
using System;
3+
4+
namespace DbUp.Cli
5+
{
6+
internal class ResultBuilder
7+
{
8+
public Option<int, Error> FromUpgradeResult(Engine.DatabaseUpgradeResult result)
9+
{
10+
if (result == null)
11+
{
12+
throw new ArgumentNullException(nameof(result));
13+
}
14+
15+
if (result.Successful)
16+
{
17+
return Option.Some<int, Error>(0);
18+
}
19+
20+
var msg = "Failed to perform upgrade: ";
21+
if (result.Error == null)
22+
{
23+
msg += "Undefined error";
24+
}
25+
else
26+
{
27+
msg += result.Error.Message;
28+
if (result.Error.InnerException != null)
29+
{
30+
msg += $"{Environment.NewLine} Details: {result.Error.InnerException.Message}";
31+
}
32+
}
33+
if (result.ErrorScript != null)
34+
{
35+
msg += $"{Environment.NewLine} Script: {result.ErrorScript.Name}";
36+
}
37+
38+
return Option.None<int, Error>(Error.Create(msg));
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)