Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/dbup-postgresql/PostgresqlConnectionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ public class PostgresqlConnectionOptions
public X509Certificate2 ClientCertificate { get; set; }

/// <summary>
// Custom handler to verify the remote SSL certificate.
// Ignored if Npgsql.NpgsqlConnectionStringBuilder.TrustServerCertificate is set.
/// Custom handler to verify the remote SSL certificate.
/// Ignored if Npgsql.NpgsqlConnectionStringBuilder.TrustServerCertificate is set.
/// </summary>
public RemoteCertificateValidationCallback UserCertificateValidationCallback { get; set; }

/// <summary>
/// The database to connect to initially. Default is 'postgres'.
/// </summary>
public string MasterDatabaseName { get; set; } = "postgres";
}
}
9 changes: 7 additions & 2 deletions src/dbup-postgresql/PostgresqlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ private static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase
PostgresqlDatabase(supported, connectionString, logger, options);
}

private static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase supported, string connectionString, IUpgradeLog logger, PostgresqlConnectionOptions connectionOptions)
private static void PostgresqlDatabase(
this SupportedDatabasesForEnsureDatabase supported,
string connectionString,
IUpgradeLog logger,
PostgresqlConnectionOptions connectionOptions
)
{
if (supported == null) throw new ArgumentNullException("supported");

Expand All @@ -179,7 +184,7 @@ private static void PostgresqlDatabase(this SupportedDatabasesForEnsureDatabase
throw new InvalidOperationException("The connection string does not specify a database name.");
}

masterConnectionStringBuilder.Database = "postgres";
masterConnectionStringBuilder.Database = connectionOptions.MasterDatabaseName;

var logMasterConnectionStringBuilder = new NpgsqlConnectionStringBuilder(masterConnectionStringBuilder.ConnectionString);
if (!string.IsNullOrEmpty(logMasterConnectionStringBuilder.Password))
Expand Down