Skip to content

refactor: use @heroku/sdk for pg:backups commands (part 3) - #3980

Merged
erika-wallace merged 1 commit into
v12.0.0from
ew/pg-backups-part-3
Oct 10, 2026
Merged

erika-wallace merged 1 commit into
v12.0.0from
ew/pg-backups-part-3

Conversation

@erika-wallace

@erika-wallace erika-wallace commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Continues the @heroku/sdk migration for pg:backups commands. This PR moves pg:backups:capture and pg:backups:restore off raw this.heroku.* calls and the legacy backupsFactory polling helper, onto the SDK's data.backup.captureAndWait and data.restore.restoreAndWait extensions. Bumps @heroku/sdk to ^0.9.0.

Changes Made

  • pg:backups:capture now resolves the database via data.database.describe and performs the capture + wait-for-completion in a single data.backup.captureAndWait call.
  • pg:backups:restore now looks up existing backups via data.transfer.listByApp and performs the restore + wait-for-completion in a single data.restore.restoreAndWait call.
  • Added two shared helpers to src/lib/pg/backups.ts:
    • constructWaitOptions(interval, verbose, action) builds the intervalMs/onPoll/waitPoller options consumed by both captureAndWait and restoreAndWait.
    • reportTransferFailure(error, transferType) formats the "did not finish" error message from a TransferFailedError, replacing the equivalent inline catch block in the old wait() method.

Behavior notes (also documented in V12-CHANGES.md)

  • pg:backups:capture now names the DATABASE argument, or DATABASE_URL when that argument is omitted, in the "not yet provisioned" error instead of the add-on resource name.

Type of Change

Breaking Changes (major semver update)

  • Add a ! after your change type to denote a change that breaks current behavior

Feature Additions (minor semver update)

  • feat: Introduces a new feature to the codebase

Patch Updates (patch semver update)

  • fix: Bug fix
  • deps: Dependency upgrade
  • revert: Revert a previous commit
  • chore: Change that does not affect production code
  • refactor: Refactoring existing code without changing behavior
  • test: Add/update/remove tests

Testing

Notes:

Requires an app with a Heroku Postgres legacy-tier database attached.

Setup:

  1. Pull down this branch
  2. npm i && npm run build
  3. heroku logout && HEROKU_NETRC_WRITE=true ./bin/run login

Steps

  1. Create a backup. Verify the backup starts, shows progress, and completes successfully.
./bin/run pg:backups:capture <database> --app <app>
  1. Create a backup with verbose logs. Verify same output as above with log lines.
./bin/run pg:backups:capture <database> --app <app> --verbose
  1. List backups. Verify the two new backups are listed.
./bin/run pg:backups --app <app>
  1. Restore a backup (with extensions). Verify the restore starts, shows progress, and completes successfully.
./bin/run pg:backups:restore <backup-id> <database> --app <app> --confirm <app> --extensions uuid-ossp
  1. List restores. Verify the two new restores are listed.
./bin/run pg:backups --app <app>

Cleanup

  • ./bin/run logout

Screenshots (if applicable)

Related Issues

GUS work item: W-23386457

@erika-wallace
erika-wallace requested a review from a team as a code owner October 9, 2026 21:54
@erika-wallace
erika-wallace deployed to AcceptanceTests October 9, 2026 21:54 — with GitHub Actions Active
@erika-wallace
erika-wallace deployed to AcceptanceTests October 9, 2026 21:54 — with GitHub Actions Active
@erika-wallace
erika-wallace deployed to AcceptanceTests October 9, 2026 21:54 — with GitHub Actions Active
@erika-wallace
erika-wallace deployed to AcceptanceTests October 9, 2026 21:54 — with GitHub Actions Active
@github-actions github-actions Bot added size/M Medium PR (code churn < 500) docs Touches documentation labels Oct 9, 2026

@michaelmalave michaelmalave left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid part-3 of the @heroku/sdk migration — the capture/restore wiring, the shared wait/failure helpers, and the nock-to-SDK-stub test rewrite all read well, and I confirmed the happy paths live against a real app (capture, verbose capture, and list all work on 0.9.0). One thing to fix before merge, though: I verified against 0.9.0 that a mistyped/unknown DATABASE argument now reports "not yet provisioned / run addons:wait" instead of the old "Unknown database: X. Valid options are: ..." — a confirmed before/after regression on the error path (detail inline). The PR is labeled refactor (no behavior change), so the capture error-path change is worth a look against that intent.

Comment thread src/commands/pg/backups/capture.ts

@michaelmalave michaelmalave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests complete successfully, this looks good! Just one thing to review and fix.

@erika-wallace
erika-wallace merged commit f84e7d5 into v12.0.0 Oct 10, 2026
25 checks passed
@erika-wallace
erika-wallace deleted the ew/pg-backups-part-3 branch October 10, 2026 01:10

This branch was successfully deployed

1 active deployment
AcceptanceTests — be8942f6 Deployed Oct 9, 2026 by erika-wallace via integration (24.x, ubuntu-latest) #9415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Touches documentation size/M Medium PR (code churn < 500)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants