|
|
@@ -352,6 +352,7 @@ async function checkPostgresDbExists(options: any, root: string): Promise<true>
|
|
|
port: options.port,
|
|
|
database: options.database,
|
|
|
schema: options.schema,
|
|
|
+ ssl: options.ssl,
|
|
|
};
|
|
|
const client = new Client(connectionOptions);
|
|
|
|
|
|
@@ -371,6 +372,8 @@ async function checkPostgresDbExists(options: any, root: string): Promise<true>
|
|
|
throwDatabaseDoesNotExist(options.database);
|
|
|
} else if (e.message === 'NO_SCHEMA') {
|
|
|
throwDatabaseSchemaDoesNotExist(options.database, options.schema);
|
|
|
+ } else if (e.code === '28000') {
|
|
|
+ throwSSLConnectionError(e, options.ssl);
|
|
|
}
|
|
|
throwConnectionError(e);
|
|
|
await client.end();
|
|
|
@@ -389,6 +392,18 @@ function throwConnectionError(err: any) {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+function throwSSLConnectionError(err: any, sslEnabled?: any) {
|
|
|
+ throw new Error(
|
|
|
+ 'Could not connect to the database. ' +
|
|
|
+ (sslEnabled === undefined
|
|
|
+ ? 'Is your server requiring an SSL connection?'
|
|
|
+ : 'Are you sure your server supports SSL?') +
|
|
|
+ `Please check the connection settings in your Vendure config.\n[${
|
|
|
+ (err.message || err.toString()) as string
|
|
|
+ }]`,
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
function throwDatabaseDoesNotExist(name: string) {
|
|
|
throw new Error(`Database "${name}" does not exist. Please create the database and then try again.`);
|
|
|
}
|