@@ -5,6 +5,7 @@ import { AuthenticatedCommand } from 'commands-base/authenticated-command';
55import { VAR_UNKNOWN } from 'consts/messages' ;
66import { getDatabaseConnectionString } from 'services/database-service' ;
77import { DynamicChoicesService } from 'services/dynamic-choices-service' ;
8+ import { defaultVersionByAppId } from 'src/services/app-versions-service' ;
89import { chooseRegionIfNeeded , getRegionFromString } from 'src/utils/region' ;
910import { HttpError } from 'types/errors' ;
1011import 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