Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --fast flag to upgrade command #2505

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions packages/pg-v5/commands/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,31 @@ async function run(context, heroku) {

if (status.error) throw new Error(status.error)

if (!replica.following) {
throw new Error('pg:upgrade is only available for follower databases on at least the Standard tier.')
}

let origin = util.databaseNameFromUrl(replica.following, await heroku.get(`/apps/${app}/config-vars`))
let confirmText
if (flags.fast) {
// TODO: Scary warning about in-place upgrades being beta?
confirmText = `WARNING: Destructive action
${cli.color.addon(db.name)} will be upgraded to a newer PostgreSQL version.

This cannot be undone.`
} else {
if (!replica.following) {
throw new Error('pg:upgrade is only available for follower databases on at least the Standard tier.')
}

await cli.confirmApp(app, flags.confirm, `WARNING: Destructive action
${cli.color.addon(db.name)} will be upgraded to a newer PostgreSQL version, stop following ${origin}, and become writable.
let origin = util.databaseNameFromUrl(replica.following, await heroku.get(`/apps/${app}/config-vars`))
confirmText = `WARNING: Destructive action
${cli.color.addon(db.name)} will be upgraded to a newer PostgreSQL version, stop following ${origin}, and become writable.

This cannot be undone.`
}

This cannot be undone.`)
await cli.confirmApp(app, flags.confirm, confirmText)

let data = {version: flags.version}
if (flags.fast) {
data.fast = true
}

await cli.action(`Starting upgrade of ${cli.color.addon(db.name)}`, (async function () {
await heroku.post(`/client/v11/databases/${db.id}/upgrade`, {host: host(db), body: data})
Expand All @@ -48,6 +61,7 @@ module.exports = {
flags: [
{name: 'confirm', char: 'c', hasValue: true},
{name: 'version', char: 'v', description: 'PostgreSQL version to upgrade to', hasValue: true},
{name: 'fast'},
],
run: cli.command({preauth: true}, run),
}
Loading