diff --git a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs index d7c8f73..b3131dc 100644 --- a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs +++ b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs @@ -1,38 +1,39 @@ -[assembly: System.CLSCompliantAttribute(false)] -[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)] -[assembly: System.Runtime.InteropServices.GuidAttribute("5ddc04cc-0bd3-421e-9ae4-9fd0e4f4ef04")] - +[assembly: System.CLSCompliant(false)] +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/DbUp/dbup-postgresql.git")] +[assembly: System.Runtime.InteropServices.ComVisible(false)] +[assembly: System.Runtime.InteropServices.Guid("5ddc04cc-0bd3-421e-9ae4-9fd0e4f4ef04")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")] 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(this DbUp.Builder.SupportedDatabases supported, string connectionString) { } 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 DbUp.Builder.UpgradeEngineBuilder PostgresqlDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString, string schema, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { } - public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString) { } public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForDropDatabase 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.Postgresql.PostgresqlConnectionOptions connectionOptions) { } - public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger) { } - public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForDropDatabase supported, string connectionString, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { } - public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForDropDatabase supported, string connectionString, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { } + public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString) { } + public static DbUp.Builder.UpgradeEngineBuilder PostgresqlDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString, string schema) { } public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForDropDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger) { } - public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { } - public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { } - public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForDropDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { } + public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForDropDatabase supported, string connectionString, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { } + public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForDropDatabase supported, string connectionString, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { } + public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger) { } + public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { } + public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { } + public static DbUp.Builder.UpgradeEngineBuilder PostgresqlDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString, string schema, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { } + 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.SupportedDatabasesForDropDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { } + public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForDropDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { } + public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { } + public static void PostgresqlDatabase(this DbUp.SupportedDatabasesForEnsureDatabase supported, string connectionString, DbUp.Engine.Output.IUpgradeLog logger, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { } } namespace DbUp.Postgresql { - public class PostgresqlConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager, DbUp.Engine.Transactions.IConnectionManager + public class PostgresqlConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager { - public PostgresqlConnectionManager(string connectionString) { } public PostgresqlConnectionManager(Npgsql.NpgsqlDataSource datasource) { } - public PostgresqlConnectionManager(string connectionString, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { } + public PostgresqlConnectionManager(string connectionString) { } public PostgresqlConnectionManager(string connectionString, DbUp.Postgresql.PostgresqlConnectionOptions connectionOptions) { } + public PostgresqlConnectionManager(string connectionString, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { } public bool StandardConformingStrings { get; set; } public override System.Collections.Generic.IEnumerable SplitScriptIntoCommands(string scriptContents) { } } @@ -43,7 +44,7 @@ public PostgresqlConnectionOptions() { } public string MasterDatabaseName { get; set; } public System.Net.Security.RemoteCertificateValidationCallback UserCertificateValidationCallback { get; set; } } - public class PostgresqlObjectParser : DbUp.Support.SqlObjectParser, DbUp.Engine.ISqlObjectParser + public class PostgresqlObjectParser : DbUp.Support.SqlObjectParser { public PostgresqlObjectParser() { } } @@ -52,13 +53,13 @@ public class PostgresqlPreprocessor : DbUp.Engine.IScriptPreprocessor public PostgresqlPreprocessor() { } public string Process(string contents) { } } - public class PostgresqlScriptExecutor : DbUp.Support.ScriptExecutor, DbUp.Engine.IScriptExecutor + public class PostgresqlScriptExecutor : DbUp.Support.ScriptExecutor { 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 class PostgresqlTableJournal : DbUp.Support.TableJournal { public PostgresqlTableJournal(System.Func connectionManager, System.Func logger, string schema, string tableName) { } protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { } @@ -66,4 +67,4 @@ protected override string GetInsertJournalEntrySql(string scriptName, string app protected override System.Data.IDbCommand GetInsertScriptCommand(System.Func dbCommandFactory, DbUp.Engine.SqlScript script) { } protected override string GetJournalEntriesSql() { } } -} +} \ No newline at end of file diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 83295fe..22618f0 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -10,10 +10,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/dbup-postgresql/PostgresqlExtensions.cs b/src/dbup-postgresql/PostgresqlExtensions.cs index 42dbcaa..8c965ab 100644 --- a/src/dbup-postgresql/PostgresqlExtensions.cs +++ b/src/dbup-postgresql/PostgresqlExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Data; using System.Security.Cryptography.X509Certificates; using System.Text.RegularExpressions; @@ -165,6 +165,13 @@ public static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase s PostgresqlDatabase(supported, connectionString, logger, new PostgresqlConnectionOptions()); } + /// + /// Ensures that the database specified in the connection string exists using SSL for the connection. + /// + /// Fluent helper type. + /// The connection string. + /// The used to record actions. + /// Certificate for securing connection. public static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase supported, string connectionString, IUpgradeLog logger, X509Certificate2 certificate) { var options = new PostgresqlConnectionOptions @@ -174,6 +181,13 @@ public static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase s PostgresqlDatabase(supported, connectionString, logger, options); } + /// + /// Ensures that the database specified in the connection string exists using SSL for the connection. + /// + /// Fluent helper type. + /// The connection string. + /// The used to record actions. + /// Connection options to set SSL parameters public static void PostgresqlDatabase( this SupportedDatabasesForEnsureDatabase supported, string connectionString, @@ -292,6 +306,13 @@ public static void PostgresqlDatabase(this SupportedDatabasesForDropDatabase sup PostgresqlDatabase(supported, connectionString, logger, new PostgresqlConnectionOptions()); } + /// + /// Drops the database specified in the connection string if it exists using SSL for the connection. + /// + /// Fluent helper type. + /// The connection string. + /// The used to record actions. + /// Certificate for securing connection. public static void PostgresqlDatabase(this SupportedDatabasesForDropDatabase supported, string connectionString, IUpgradeLog logger, X509Certificate2 certificate) { var options = new PostgresqlConnectionOptions @@ -301,6 +322,13 @@ public static void PostgresqlDatabase(this SupportedDatabasesForDropDatabase sup PostgresqlDatabase(supported, connectionString, logger, options); } + /// + /// Drops the database specified in the connection string if it exists using SSL for the connection. + /// + /// Fluent helper type. + /// The connection string. + /// The used to record actions. + /// Connection options to set SSL parameters public static void PostgresqlDatabase( this SupportedDatabasesForDropDatabase supported, string connectionString, diff --git a/src/dbup-postgresql/PostgresqlObjectParser.cs b/src/dbup-postgresql/PostgresqlObjectParser.cs index 7e5cc44..96d2eb8 100644 --- a/src/dbup-postgresql/PostgresqlObjectParser.cs +++ b/src/dbup-postgresql/PostgresqlObjectParser.cs @@ -1,8 +1,11 @@ -using DbUp.Support; +using DbUp.Support; namespace DbUp.Postgresql; /// /// Parses Sql Objects and performs quoting functions. /// +/// +/// Initializes a new instance of the class. +/// public class PostgresqlObjectParser() : SqlObjectParser("\"", "\""); diff --git a/src/dbup-postgresql/PostgresqlScriptExecutor.cs b/src/dbup-postgresql/PostgresqlScriptExecutor.cs index 78d4766..5a8c657 100644 --- a/src/dbup-postgresql/PostgresqlScriptExecutor.cs +++ b/src/dbup-postgresql/PostgresqlScriptExecutor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using DbUp.Engine; using DbUp.Engine.Output; @@ -25,12 +25,14 @@ public class PostgresqlScriptExecutor : ScriptExecutor public PostgresqlScriptExecutor(Func connectionManagerFactory, Func log, string schema, Func variablesEnabled, IEnumerable scriptPreprocessors, Func journalFactory) : base(connectionManagerFactory, new PostgresqlObjectParser(), log, schema, variablesEnabled, scriptPreprocessors, journalFactory) - { - } + { + } - protected override string GetVerifySchemaSql(string schema) => $"CREATE SCHEMA IF NOT EXISTS {schema}"; + /// + protected override string GetVerifySchemaSql(string schema) => $"CREATE SCHEMA IF NOT EXISTS {schema}"; - protected override void ExecuteCommandsWithinExceptionHandler(int index, SqlScript script, Action executeCommand) + /// + protected override void ExecuteCommandsWithinExceptionHandler(int index, SqlScript script, Action executeCommand) { try { diff --git a/src/dbup-postgresql/PostgresqlTableJournal.cs b/src/dbup-postgresql/PostgresqlTableJournal.cs index fc35160..1fe0e0f 100644 --- a/src/dbup-postgresql/PostgresqlTableJournal.cs +++ b/src/dbup-postgresql/PostgresqlTableJournal.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Data; using DbUp.Engine; using DbUp.Engine.Output; @@ -22,10 +22,11 @@ public class PostgresqlTableJournal : TableJournal /// The name of the journal table. public PostgresqlTableJournal(Func connectionManager, Func logger, string schema, string tableName) : base(connectionManager, logger, new PostgresqlObjectParser(), schema, tableName) - { - } + { + } - protected override IDbCommand GetInsertScriptCommand(Func dbCommandFactory, SqlScript script) + /// + protected override IDbCommand GetInsertScriptCommand(Func dbCommandFactory, SqlScript script) { // EnableSqlRewriting is enabled by default, and needs to be explicitly disabled bool enableSqlRewriting = !AppContext.TryGetSwitch("Npgsql.EnableSqlRewriting", out bool enabled) || enabled; @@ -49,16 +50,19 @@ protected override IDbCommand GetInsertScriptCommand(Func dbCommandF return command; } + /// protected override string GetInsertJournalEntrySql(string scriptName, string applied) { return $"insert into {FqSchemaTableName} (ScriptName, Applied) values ({scriptName}, {applied})"; } + /// protected override string GetJournalEntriesSql() { return $"select ScriptName from {FqSchemaTableName} order by ScriptName"; } + /// protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { return diff --git a/src/dbup-postgresql/dbup-postgresql.csproj b/src/dbup-postgresql/dbup-postgresql.csproj index e6df8c2..f5c7eef 100644 --- a/src/dbup-postgresql/dbup-postgresql.csproj +++ b/src/dbup-postgresql/dbup-postgresql.csproj @@ -1,4 +1,4 @@ - + DbUp makes it easy to deploy and upgrade SQL Server databases. This package adds PostgreSQL support. @@ -14,6 +14,7 @@ true https://github.com/DbUp/dbup-postgresql.git dbup-icon.png + true @@ -23,7 +24,7 @@ - + @@ -31,7 +32,7 @@ - +