Skip to content

Commit 3a8fb4e

Browse files
committed
copy
1 parent 9a18900 commit 3a8fb4e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/commands/database/connection-string.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AuthenticatedCommand } from 'commands-base/authenticated-command';
55
import { VAR_UNKNOWN } from 'consts/messages';
66
import { getDatabaseConnectionString } from 'services/database-service';
77
import { DynamicChoicesService } from 'services/dynamic-choices-service';
8+
import { defaultVersionByAppId } from 'src/services/app-versions-service';
89
import { chooseRegionIfNeeded, getRegionFromString } from 'src/utils/region';
910
import { HttpError } from 'types/errors';
1011
import logger from 'utils/logger';
@@ -32,12 +33,15 @@ export default class ConnectionString extends AuthenticatedCommand {
3233
appId = await DynamicChoicesService.chooseApp();
3334
}
3435

35-
const selectedRegion = await chooseRegionIfNeeded(parsedRegion, { appId });
36+
const defaultVersion = await defaultVersionByAppId(Number(appId));
37+
const selectedRegion = await chooseRegionIfNeeded(parsedRegion, { appId, appVersionId: defaultVersion?.id });
3638
const result = await getDatabaseConnectionString(appId, selectedRegion);
3739

3840
logger.log(chalk.green('✓ Connection string retrieved successfully:'));
3941
logger.log(chalk.cyan(result.connectionString));
40-
logger.log(chalk.cyan(`Expires at: ${result.expiresAt}`));
42+
logger.log(
43+
chalk.cyan(`The connection may take a few moments to be available, and will expire at: ${result.expiresAt}`),
44+
);
4145

4246
this.preparePrintCommand(this, { appId });
4347
} catch (error: unknown) {
@@ -46,7 +50,9 @@ export default class ConnectionString extends AuthenticatedCommand {
4650
logger.error(`\n ${chalk.italic(chalk.red(error.message))}`);
4751
} else {
4852
logger.error(
49-
`An unknown error happened while fetching connection string for app id - "${appId || VAR_UNKNOWN}"`,
53+
`An unknown error happened while fetching the database connection string for app id - "${
54+
appId || VAR_UNKNOWN
55+
}"`,
5056
);
5157
}
5258

0 commit comments

Comments
 (0)