Skip to content

Commit ef78317

Browse files
committed
review comments
1 parent fe88751 commit ef78317

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

packages/cli/src/commands/pg/upgrade/run.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

packages/cli/src/lib/pg/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ export type PgUpgradeResponse = {
172172
}
173173

174174
export type PgUpgradeError = {
175-
status: number,
176175
body: {
177176
id: string,
178177
message: string,

0 commit comments

Comments
 (0)