diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 99db373..370efc5 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -10,18 +10,4 @@
latest
true
-
-
-
-
- true
-
-
- true
-
-
- embedded
-
-
-
diff --git a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt
similarity index 92%
rename from src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt
rename to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt
index 36671a2..ac69b5d 100644
--- a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt
+++ b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt
@@ -1,11 +1,11 @@
DB Operation: Open connection
Info: Beginning database upgrade
-Info: Checking whether journal table exists..
+Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0001.sql'
-Info: Checking whether journal table exists..
+Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Creating the "schemaversions" table
diff --git a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt
similarity index 93%
rename from src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt
rename to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt
index 0a54bf4..46bee6c 100644
--- a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt
+++ b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt
@@ -1,11 +1,11 @@
DB Operation: Open connection
Info: Beginning database upgrade
-Info: Checking whether journal table exists..
+Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0001.sql'
-Info: Checking whether journal table exists..
+Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
DB Operation: Dispose command
Info: Creating the "test"."TestSchemaVersions" table
diff --git a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt
similarity index 92%
rename from src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt
rename to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt
index 496fbb6..3321b7a 100644
--- a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt
+++ b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt
@@ -1,11 +1,11 @@
DB Operation: Open connection
Info: Beginning database upgrade
-Info: Checking whether journal table exists..
+Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0001.sql'
-Info: Checking whether journal table exists..
+Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Creating the "schemaversions" table
diff --git a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs
deleted file mode 100644
index 165f98e..0000000
--- a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-[assembly: System.CLSCompliantAttribute(true)]
-[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
-[assembly: System.Runtime.InteropServices.GuidAttribute("5ddc04cc-0bd3-421e-9ae4-9fd0e4f4ef04")]
-
-public static class PostgresqlExtensions
-{
- public static DbUp.Builder.UpgradeEngineBuilder JournalToPostgresqlTable(this DbUp.Builder.UpgradeEngineBuilder builder, string schema, string table) { }
- public static DbUp.Builder.UpgradeEngineBuilder PostgresqlDatabase(DbUp.Engine.Transactions.IConnectionManager connectionManager) { }
- public static DbUp.Builder.UpgradeEngineBuilder PostgresqlDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString) { }
- public static DbUp.Builder.UpgradeEngineBuilder PostgresqlDatabase(this DbUp.Builder.SupportedDatabases supported, DbUp.Engine.Transactions.IConnectionManager connectionManager) { }
- public static DbUp.Builder.UpgradeEngineBuilder PostgresqlDatabase(DbUp.Engine.Transactions.IConnectionManager connectionManager, string schema) { }
- public static DbUp.Builder.UpgradeEngineBuilder PostgresqlDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString, string schema) { }
- public static DbUp.Builder.UpgradeEngineBuilder PostgresqlDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString, string schema, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
- public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString) { }
- public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
- public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger) { }
-}
-namespace DbUp.Postgresql
-{
- public class PostgresqlConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager, DbUp.Engine.Transactions.IConnectionManager
- {
- public PostgresqlConnectionManager(string connectionString) { }
- public PostgresqlConnectionManager(string connectionString, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
- public override System.Collections.Generic.IEnumerable SplitScriptIntoCommands(string scriptContents) { }
- }
- public class PostgresqlObjectParser : DbUp.Support.SqlObjectParser, DbUp.Engine.ISqlObjectParser
- {
- public PostgresqlObjectParser() { }
- }
- public class PostgresqlPreprocessor : DbUp.Engine.IScriptPreprocessor
- {
- public PostgresqlPreprocessor() { }
- public string Process(string contents) { }
- }
- public class PostgresqlScriptExecutor : DbUp.Support.ScriptExecutor, DbUp.Engine.IScriptExecutor
- {
- public PostgresqlScriptExecutor(System.Func connectionManagerFactory, System.Func log, string schema, System.Func variablesEnabled, System.Collections.Generic.IEnumerable scriptPreprocessors, System.Func journalFactory) { }
- protected override void ExecuteCommandsWithinExceptionHandler(int index, DbUp.Engine.SqlScript script, System.Action executeCommand) { }
- protected override string GetVerifySchemaSql(string schema) { }
- }
- public class PostgresqlTableJournal : DbUp.Support.TableJournal, DbUp.Engine.IJournal
- {
- public PostgresqlTableJournal(System.Func connectionManager, System.Func logger, string schema, string tableName) { }
- protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { }
- protected override string GetInsertJournalEntrySql(string scriptName, string applied) { }
- protected override System.Data.IDbCommand GetInsertScriptCommand(System.Func dbCommandFactory, DbUp.Engine.SqlScript script) { }
- protected override string GetJournalEntriesSql() { }
- }
-}
diff --git a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs
similarity index 100%
rename from src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs
rename to src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs
diff --git a/src/Tests/PostgresTableJournalTests.cs b/src/Tests/PostgresTableJournalTests.cs
index ab727ba..fceb301 100644
--- a/src/Tests/PostgresTableJournalTests.cs
+++ b/src/Tests/PostgresTableJournalTests.cs
@@ -11,13 +11,13 @@ namespace DbUp.Postgresql.Tests;
public class PostgresTableJournalTests : IDisposable
{
- [Fact]
+ [Fact]
public void uses_positional_parameters_when_sql_rewriting_disabled()
{
AppContext.SetSwitch("Npgsql.EnableSqlRewriting", false);
var dbConnection = Substitute.For();
- var connectionManager = new TestConnectionManager(dbConnection, true);
+ var connectionManager = new TestConnectionManager(dbConnection);
var command = Substitute.For();
var param1 = Substitute.For();
var param2 = Substitute.For();
@@ -25,7 +25,8 @@ public void uses_positional_parameters_when_sql_rewriting_disabled()
command.CreateParameter().Returns(param1, param2);
command.ExecuteScalar().Returns(x => 0);
var consoleUpgradeLog = new ConsoleUpgradeLog();
- var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public", "SchemaVersions");
+ var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public",
+ "SchemaVersions");
// Act
journal.StoreExecutedScript(new SqlScript("test", "select 1"), () => command);
@@ -45,7 +46,7 @@ public void uses_named_parameters_when_sql_rewriting_enabled()
AppContext.SetSwitch("Npgsql.EnableSqlRewriting", true);
var dbConnection = Substitute.For();
- var connectionManager = new TestConnectionManager(dbConnection, true);
+ var connectionManager = new TestConnectionManager(dbConnection);
var command = Substitute.For();
var param1 = Substitute.For();
var param2 = Substitute.For();
@@ -53,7 +54,8 @@ public void uses_named_parameters_when_sql_rewriting_enabled()
command.CreateParameter().Returns(param1, param2);
command.ExecuteScalar().Returns(x => 0);
var consoleUpgradeLog = new ConsoleUpgradeLog();
- var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public", "SchemaVersions");
+ var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public",
+ "SchemaVersions");
// Act
journal.StoreExecutedScript(new SqlScript("test", "select 1"), () => command);
@@ -62,7 +64,8 @@ public void uses_named_parameters_when_sql_rewriting_enabled()
command.Received(2).CreateParameter();
param1.ParameterName.ShouldBe("scriptName");
param2.ParameterName.ShouldBe("applied");
- command.CommandText.ShouldBe("""insert into "public"."SchemaVersions" (ScriptName, Applied) values (@scriptName, @applied)""");
+ command.CommandText.ShouldBe(
+ """insert into "public"."SchemaVersions" (ScriptName, Applied) values (@scriptName, @applied)""");
command.Received().ExecuteNonQuery();
}
diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj
index 2cbc38f..492abe6 100644
--- a/src/Tests/Tests.csproj
+++ b/src/Tests/Tests.csproj
@@ -1,19 +1,19 @@
- net462;net8
+ net8
Tests
DbUp.Postgresql.Tests
-
+ enable
enable
-
-
-
-
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/dbup-postgresql.sln.DotSettings b/src/dbup-postgresql.sln.DotSettings
index 2c78c0a..d3334fb 100644
--- a/src/dbup-postgresql.sln.DotSettings
+++ b/src/dbup-postgresql.sln.DotSettings
@@ -5,5 +5,8 @@
SQ
<Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
<Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
+ <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy>
+ <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy>
+ True
<data><IncludeFilters /><ExcludeFilters /></data>
<data />
\ No newline at end of file
diff --git a/src/dbup-postgresql/PostgresqlExtensions.cs b/src/dbup-postgresql/PostgresqlExtensions.cs
index 8ff517a..fd885df 100644
--- a/src/dbup-postgresql/PostgresqlExtensions.cs
+++ b/src/dbup-postgresql/PostgresqlExtensions.cs
@@ -153,7 +153,7 @@ private static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase
logMasterConnectionStringBuilder.Password = "******";
}
- logger.WriteInformation("Master ConnectionString => {0}", logMasterConnectionStringBuilder.ConnectionString);
+ logger.LogInformation("Master ConnectionString => {0}", logMasterConnectionStringBuilder.ConnectionString);
using (var connection = new NpgsqlConnection(masterConnectionStringBuilder.ConnectionString))
{
@@ -164,11 +164,8 @@ private static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase
}
connection.Open();
- var sqlCommandText = string.Format
- (
- @"SELECT case WHEN oid IS NOT NULL THEN 1 ELSE 0 end FROM pg_database WHERE datname = '{0}' limit 1;",
- databaseName
- );
+ var sqlCommandText =
+ $@"SELECT case WHEN oid IS NOT NULL THEN 1 ELSE 0 end FROM pg_database WHERE datname = '{databaseName}' limit 1;";
// check to see if the database already exists..
using (var command = new NpgsqlCommand(sqlCommandText, connection)
@@ -185,11 +182,7 @@ private static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase
}
}
- sqlCommandText = string.Format
- (
- "create database \"{0}\";",
- databaseName
- );
+ sqlCommandText = $"create database \"{databaseName}\";";
// Create the database...
using (var command = new NpgsqlCommand(sqlCommandText, connection)
@@ -200,7 +193,7 @@ private static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase
command.ExecuteNonQuery();
}
- logger.WriteInformation(@"Created database {0}", databaseName);
+ logger.LogInformation(@"Created database {0}", databaseName);
}
}
diff --git a/src/dbup-postgresql/PostgresqlScriptExecutor.cs b/src/dbup-postgresql/PostgresqlScriptExecutor.cs
index c8f58d3..e99555c 100644
--- a/src/dbup-postgresql/PostgresqlScriptExecutor.cs
+++ b/src/dbup-postgresql/PostgresqlScriptExecutor.cs
@@ -42,9 +42,9 @@ protected override void ExecuteCommandsWithinExceptionHandler(int index, SqlScri
catch (PostgresException exception)
#endif
{
- Log().WriteInformation("Npgsql exception has occurred in script: '{0}'", script.Name);
- Log().WriteError("Script block number: {0}; Block line {1}; Position: {2}; Message: {3}", index, exception.Line, exception.Position, exception.Message);
- Log().WriteError(exception.ToString());
+ Log().LogInformation("Npgsql exception has occurred in script: '{0}'", script.Name);
+ Log().LogError("Script block number: {0}; Block line {1}; Position: {2}; Message: {3}", index, exception.Line, exception.Position, exception.Message);
+ Log().LogError(exception.ToString());
throw;
}
}
diff --git a/src/dbup-postgresql/dbup-postgresql.csproj b/src/dbup-postgresql/dbup-postgresql.csproj
index ef3496a..1d48f85 100644
--- a/src/dbup-postgresql/dbup-postgresql.csproj
+++ b/src/dbup-postgresql/dbup-postgresql.csproj
@@ -6,7 +6,7 @@
DbUp Contributors
DbUp
Copyright © DbUp Contributors 2015
- netstandard1.3;netstandard2.0;net462
+ netstandard2.0
dbup-postgresql
DbUp.Postgresql
dbup-postgresql
@@ -16,10 +16,15 @@
dbup-icon.png
+
+ true
+ true
+ embedded
+
+
-
-
-
+
+