Repository navigation
refactor: use @heroku/sdk for pg:backups commands (part 3) - #3980
Conversation
There was a problem hiding this comment.
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.
michaelmalave
left a comment
There was a problem hiding this comment.
Tests complete successfully, this looks good! Just one thing to review and fix.
Summary
Continues the
@heroku/sdkmigration forpg:backupscommands. This PR movespg:backups:captureandpg:backups:restoreoff rawthis.heroku.*calls and the legacybackupsFactorypolling helper, onto the SDK'sdata.backup.captureAndWaitanddata.restore.restoreAndWaitextensions. Bumps@heroku/sdkto^0.9.0.Changes Made
pg:backups:capturenow resolves the database viadata.database.describeand performs the capture + wait-for-completion in a singledata.backup.captureAndWaitcall.pg:backups:restorenow looks up existing backups viadata.transfer.listByAppand performs the restore + wait-for-completion in a singledata.restore.restoreAndWaitcall.src/lib/pg/backups.ts:constructWaitOptions(interval, verbose, action)builds theintervalMs/onPoll/waitPolleroptions consumed by bothcaptureAndWaitandrestoreAndWait.reportTransferFailure(error, transferType)formats the "did not finish" error message from aTransferFailedError, replacing the equivalent inlinecatchblock in the oldwait()method.Behavior notes (also documented in
V12-CHANGES.md)pg:backups:capturenow names theDATABASEargument, orDATABASE_URLwhen 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)
!after your change type to denote a change that breaks current behaviorFeature Additions (minor semver update)
Patch Updates (patch semver update)
Testing
Notes:
Requires an app with a Heroku Postgres legacy-tier database attached.
Setup:
npm i && npm run buildheroku logout && HEROKU_NETRC_WRITE=true ./bin/run loginSteps
Cleanup
./bin/run logoutScreenshots (if applicable)
Related Issues
GUS work item: W-23386457