Skip to content

Commit c465253

Browse files
droyadscrocqueselcampbellhardingdeasonshokurovnvierge-addactis
authored
Release 6.0 (#18)
* Add NpgsqlDataSource support to PostgresqlConnectionManager * Used new GHA workflows * Updated to dbup-core 6.0 beta, targeted netstandard2 and update Npgsql reference * Bump to the next beta of dbup-core * Merge fix * Removed stray #If * fix: #680 PostgreSQL statements split implemented (#19) * fix: #680 PostgreSQL statements split implemented Co-authored-by: shokurov <egor.shokurov@gmail.com> * Updated approval file --------- Co-authored-by: shokurov <egor.shokurov@gmail.com> Co-authored-by: Robert Wagner <robert@wagner.id.au> * Update of libs * File scoped namespaces and primary ctors * Target `net8` so we can use the latest version of Npgsql (#24) * Target net8 so we can use the latest version of Npgsql * Used new APIs * Added Npgsql licence information (#25) * fix(#26): avoid NullReferenceException when creating database (#27) * fix(#26): avoid NullReferenceException when creating database * Updated approval file --------- Co-authored-by: Robert Wagner <robert@wagner.id.au> * fix: fix delimiter parsing (#28) * Lowered Connection string printing to debug, resolves #30 --------- Co-authored-by: Sébastien Crocquesel <88554524+scrocquesel@users.noreply.github.com> Co-authored-by: Campbell Harding-Deason <campbell.harding-deason@firstaml.com> Co-authored-by: shokurov <egor.shokurov@gmail.com> Co-authored-by: nvierge-addactis <151941872+nvierge-addactis@users.noreply.github.com>
1 parent a544ae5 commit c465253

25 files changed

+719
-353
lines changed

.github/workflows/main.yml

+4-69
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,12 @@ name: CI
22

33
on:
44
push:
5+
branches:
6+
- '**' # Ignores pushes of tags
57
pull_request:
68
workflow_dispatch:
79

810
jobs:
911
build:
10-
runs-on: windows-latest # Use Ubuntu in v5.0
11-
12-
env:
13-
DOTNET_NOLOGO: true
14-
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Avoid pre-populating the NuGet package cache
15-
16-
steps:
17-
- uses: actions/checkout@v3
18-
with:
19-
fetch-depth: 0 # all
20-
21-
- name: Setup .NET 2.0 # Remove in v5.0
22-
uses: actions/setup-dotnet@v1
23-
with:
24-
dotnet-version: 2.0.x
25-
26-
- name: Setup .NET 8.0
27-
uses: actions/setup-dotnet@v1
28-
with:
29-
dotnet-version: 8.0.x
30-
31-
- name: Install GitVersion
32-
uses: gittools/actions/gitversion/setup@v0
33-
with:
34-
versionSpec: '5.x'
35-
36-
- name: Run GitVersion
37-
id: gitversion
38-
uses: gittools/actions/gitversion/execute@v0
39-
40-
- name: Display SemVer
41-
run: |
42-
echo "SemVer: $env:GitVersion_SemVer"
43-
44-
- name: Add DbUp NuGet Source
45-
run: dotnet nuget add source --name DbUp --username DbUp --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text https://nuget.pkg.github.com/DbUp/index.json
46-
47-
- name: Restore
48-
run: dotnet restore
49-
working-directory: src
50-
51-
- name: Build
52-
run: dotnet build -c Release --no-restore /p:Version=$env:GitVersion_SemVer
53-
working-directory: src
54-
55-
- name: Test
56-
run: dotnet test --no-build -c Release --logger trx --logger "console;verbosity=detailed" --results-directory ../artifacts
57-
working-directory: src
58-
59-
- name: Pack
60-
run: dotnet pack --no-build -c Release -o ../artifacts /p:Version=$env:GitVersion_SemVer
61-
working-directory: src
62-
63-
- name: Push NuGet packages to GitHub Packages ⬆️
64-
working-directory: artifacts
65-
run: dotnet nuget push *.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/DbUp/index.json"
66-
67-
- name: Push NuGet packages to NuGet ⬆️
68-
if: ${{ steps.gitversion.outputs.preReleaseLabel == '' }}
69-
working-directory: artifacts
70-
run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json
71-
72-
- name: Test Report 🧪
73-
uses: dorny/test-reporter@v1
74-
if: ${{ always() }}
75-
with:
76-
name: Tests
77-
path: artifacts/*.trx
78-
reporter: dotnet-trx
12+
name: Build
13+
uses: DbUp/Universe/.github/workflows/build.yml@main

.github/workflows/publish-release.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Publish DbUp Packages to NuGet
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
name: Publish Package
11+
uses: DbUp/Universe/.github/workflows/publish-release.yml@main
12+
secrets: inherit

.github/workflows/test-report.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Test Report
2+
run-name: Generate Test Report for run `${{ github.event.workflow_run.run_number }}` branch `${{ github.event.workflow_run.head_branch }}`
3+
4+
on:
5+
workflow_run:
6+
workflows: ["CI", "build"]
7+
types: [completed]
8+
9+
jobs:
10+
report:
11+
name: Test Report 🧪
12+
uses: DbUp/Universe/.github/workflows/test-report.yml@main

src/Directory.Build.props

-14
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,4 @@
1010
<LangVersion>latest</LangVersion>
1111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1212
</PropertyGroup>
13-
14-
<PropertyGroup Condition="'$(TF_BUILD)' == 'true' Or '$(CI)' == 'true'">
15-
16-
<!-- Perform a deterministic build, so our binaries aren't impacted by build server environmental factors (e.g. file paths). -->
17-
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
18-
19-
<!-- Embed source files that are not tracked by the source control manager in the PDB -->
20-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
21-
22-
<!-- Recommended: Embed symbols containing Source Link in the main file (exe/dll) -->
23-
<DebugType>embedded</DebugType>
24-
25-
</PropertyGroup>
26-
2713
</Project>

src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
DB Operation: Open connection
22
Info: Beginning database upgrade
3-
Info: Checking whether journal table exists..
3+
Info: Checking whether journal table exists
44
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
55
DB Operation: Dispose command
66
Info: Journal table does not exist
77
Info: Executing Database Server script 'Script0001.sql'
8-
Info: Checking whether journal table exists..
8+
Info: Checking whether journal table exists
99
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
1010
DB Operation: Dispose command
1111
Info: Creating the "schemaversions" table

src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
DB Operation: Open connection
22
Info: Beginning database upgrade
3-
Info: Checking whether journal table exists..
3+
Info: Checking whether journal table exists
44
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
55
DB Operation: Dispose command
66
Info: Journal table does not exist
77
Info: Executing Database Server script 'Script0001.sql'
8-
Info: Checking whether journal table exists..
8+
Info: Checking whether journal table exists
99
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
1010
DB Operation: Dispose command
1111
Info: Creating the "test"."TestSchemaVersions" table

src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
DB Operation: Open connection
22
Info: Beginning database upgrade
3-
Info: Checking whether journal table exists..
3+
Info: Checking whether journal table exists
44
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
55
DB Operation: Dispose command
66
Info: Journal table does not exist
77
Info: Executing Database Server script 'Script0001.sql'
8-
Info: Checking whether journal table exists..
8+
Info: Checking whether journal table exists
99
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
1010
DB Operation: Dispose command
1111
Info: Creating the "schemaversions" table

src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs

-58
This file was deleted.

src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[assembly: System.CLSCompliantAttribute(true)]
1+
[assembly: System.CLSCompliantAttribute(false)]
22
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
33
[assembly: System.Runtime.InteropServices.GuidAttribute("5ddc04cc-0bd3-421e-9ae4-9fd0e4f4ef04")]
44

@@ -16,20 +16,25 @@ public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatab
1616
public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
1717
public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { }
1818
public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger) { }
19+
public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
20+
public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { }
1921
}
2022
namespace DbUp.Postgresql
2123
{
2224
public class PostgresqlConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager, DbUp.Engine.Transactions.IConnectionManager
2325
{
2426
public PostgresqlConnectionManager(string connectionString) { }
27+
public PostgresqlConnectionManager(Npgsql.NpgsqlDataSource datasource) { }
2528
public PostgresqlConnectionManager(string connectionString, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
2629
public PostgresqlConnectionManager(string connectionString, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { }
30+
public bool StandardConformingStrings { get; set; }
2731
public override System.Collections.Generic.IEnumerable<string> SplitScriptIntoCommands(string scriptContents) { }
2832
}
2933
public class PostgresqlConnectionOptions
3034
{
3135
public PostgresqlConnectionOptions() { }
3236
public System.Security.Cryptography.X509Certificates.X509Certificate2 ClientCertificate { get; set; }
37+
public string MasterDatabaseName { get; set; }
3338
public System.Net.Security.RemoteCertificateValidationCallback UserCertificateValidationCallback { get; set; }
3439
}
3540
public class PostgresqlObjectParser : DbUp.Support.SqlObjectParser, DbUp.Engine.ISqlObjectParser

src/Tests/DatabaseSupportTests.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#if !NETCORE
2-
using System;
3-
using DbUp.Builder;
1+
using DbUp.Builder;
42
using DbUp.Tests.Common;
53

64
namespace DbUp.Postgresql.Tests;
@@ -21,4 +19,3 @@ protected override UpgradeEngineBuilder AddCustomNamedJournalToBuilder(UpgradeEn
2119
=> new PostgresqlTableJournal(connectionManagerFactory, logFactory, schema, tableName)
2220
);
2321
}
24-
#endif

src/Tests/NoPublicApiChanges.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if !NETCORE
2-
using DbUp.Tests.Common;
1+
using DbUp.Tests.Common;
32

43
namespace DbUp.Postgresql.Tests;
54

@@ -10,4 +9,3 @@ public NoPublicApiChanges()
109
{
1110
}
1211
}
13-
#endif

src/Tests/PostgresTableJournalTests.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@ namespace DbUp.Postgresql.Tests;
1111

1212
public class PostgresTableJournalTests : IDisposable
1313
{
14-
[Fact]
14+
[Fact]
1515
public void uses_positional_parameters_when_sql_rewriting_disabled()
1616
{
1717
AppContext.SetSwitch("Npgsql.EnableSqlRewriting", false);
1818

1919
var dbConnection = Substitute.For<IDbConnection>();
20-
var connectionManager = new TestConnectionManager(dbConnection, true);
20+
var connectionManager = new TestConnectionManager(dbConnection);
2121
var command = Substitute.For<IDbCommand>();
2222
var param1 = Substitute.For<IDbDataParameter>();
2323
var param2 = Substitute.For<IDbDataParameter>();
2424
dbConnection.CreateCommand().Returns(command);
2525
command.CreateParameter().Returns(param1, param2);
2626
command.ExecuteScalar().Returns(x => 0);
2727
var consoleUpgradeLog = new ConsoleUpgradeLog();
28-
var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public", "SchemaVersions");
28+
var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public",
29+
"SchemaVersions");
2930

3031
// Act
3132
journal.StoreExecutedScript(new SqlScript("test", "select 1"), () => command);
@@ -45,15 +46,16 @@ public void uses_named_parameters_when_sql_rewriting_enabled()
4546
AppContext.SetSwitch("Npgsql.EnableSqlRewriting", true);
4647

4748
var dbConnection = Substitute.For<IDbConnection>();
48-
var connectionManager = new TestConnectionManager(dbConnection, true);
49+
var connectionManager = new TestConnectionManager(dbConnection);
4950
var command = Substitute.For<IDbCommand>();
5051
var param1 = Substitute.For<IDbDataParameter>();
5152
var param2 = Substitute.For<IDbDataParameter>();
5253
dbConnection.CreateCommand().Returns(command);
5354
command.CreateParameter().Returns(param1, param2);
5455
command.ExecuteScalar().Returns(x => 0);
5556
var consoleUpgradeLog = new ConsoleUpgradeLog();
56-
var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public", "SchemaVersions");
57+
var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public",
58+
"SchemaVersions");
5759

5860
// Act
5961
journal.StoreExecutedScript(new SqlScript("test", "select 1"), () => command);
@@ -62,7 +64,8 @@ public void uses_named_parameters_when_sql_rewriting_enabled()
6264
command.Received(2).CreateParameter();
6365
param1.ParameterName.ShouldBe("scriptName");
6466
param2.ParameterName.ShouldBe("applied");
65-
command.CommandText.ShouldBe("""insert into "public"."SchemaVersions" (ScriptName, Applied) values (@scriptName, @applied)""");
67+
command.CommandText.ShouldBe(
68+
"""insert into "public"."SchemaVersions" (ScriptName, Applied) values (@scriptName, @applied)""");
6669
command.Received().ExecuteNonQuery();
6770
}
6871

0 commit comments

Comments
 (0)