@@ -20,10 +20,26 @@ export default class Upgrade extends Command {
2020 On follower databases, this command unfollows the leader database before upgrading the follower's Postgres version.
2121 ` )
2222
23+ static examples = [
24+ heredoc `
25+ # Upgrade an Essential-tier database to a specific version
26+ $ heroku pg:upgrade:run postgresql-curved-12345 --version 14 --app myapp
27+ ` ,
28+ heredoc `
29+ # Upgrade a Standard-tier follower database to the latest supported version
30+ $ heroku pg:upgrade:run HEROKU_POSTGRESQL_BLUE_URL --app myapp
31+ ` ,
32+ heredoc `
33+ # Run a previously scheduled upgrade on a Standard-tier leader database
34+ $ heroku pg:upgrade:run DATABASE_URL --app myapp
35+ ` ,
36+ ]
37+
2338 static flags = {
2439 confirm : flags . string ( { char : 'c' } ) ,
2540 version : flags . string ( { char : 'v' , description : 'Postgres version to upgrade to' } ) ,
2641 app : flags . app ( { required : true } ) ,
42+ remote : flags . remote ( { char : 'r' } ) ,
2743 }
2844
2945 static args = {
@@ -74,8 +90,12 @@ export default class Upgrade extends Command {
7490 const response = await this . heroku . post < PgUpgradeResponse > ( `/client/v11/databases/${ db . id } /upgrade/run` , { hostname : pgHost ( ) , body : data } )
7591 ux . action . stop ( heredoc ( `done\n${ formatResponseWithCommands ( response . body . message ) } ` ) )
7692 } catch ( error ) {
77- const response = error as PgUpgradeError
78- ux . error ( heredoc ( `${ formatResponseWithCommands ( response . body . message ) } \n\nError ID: ${ response . body . id } ` ) )
93+ if ( error instanceof Error && 'body' in error ) {
94+ const response = error as PgUpgradeError
95+ ux . error ( heredoc ( `${ formatResponseWithCommands ( response . body . message ) } \n\nError ID: ${ response . body . id } ` ) )
96+ } else {
97+ throw error
98+ }
7999 }
80100 }
81101}
0 commit comments