Skip to content

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

Merged
erika-wallace merged 6 commits into
v12.0.0from
ew/pg-backups-sdk
Oct 8, 2026
Merged

erika-wallace merged 6 commits into
v12.0.0from
ew/pg-backups-sdk

Conversation

@erika-wallace

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

Copy link
Copy Markdown
Contributor

Summary

This PR updates three pg:backups commands — pg:backups:schedule, pg:backups:schedules, and pg:backups:unschedule — to use the SDK instead of calling the Heroku API directly.

Changes Made

  • pg:backups:schedule now loads the database with data.database.describe and creates the schedule with data.transferSchedule.create. The command no longer builds schedule_name; the SDK sets it from the resolved attachment name.
  • pg:backups:schedules now lists schedules with data.transferSchedule.list.
  • pg:backups:unschedule now lists schedules with data.transferSchedule.list and deletes the match with data.transferSchedule.delete.
  • src/lib/pg/types.ts no longer defines TransferSchedule or PublicUrlResponse. Those types now come from @heroku/sdk and @heroku/types.
  • src/commands/pg/backups/index.ts drops an unused transferExtensions import left over from the pg:backups part-1 migration (refactor: use @heroku/sdk for pg:backups commands (part 1) #3958).

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

  • pg:backups:schedule's "not yet provisioned" error now names the DATABASE argument (or DATABASE_URL when omitted) instead of the resolved add-on's resource name, since the SDK's NotFoundError surfaces before the add-on name is known. The scheduling spinner still shows that add-on name when database.describe returns name; if name is absent it falls back to the DATABASE argument, then DATABASE_URL.
  • pg:backups:unschedule's "no daily backups found" error now names the DATABASE argument (or the auto-selected schedule name) instead of the resolved add-on's 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. Schedule the default database. Verify Scheduling automatic daily backups of <name> at 4:00 UTC... done.
./bin/run pg:backups:schedule --app <app> --at '4:00 UTC'
  1. Schedule a named database. Verify Scheduling automatic daily backups of <name> at 14:00 America/Los_Angeles... done. If <database> only has one attachment, this replaces the step 1 schedule instead of adding a second one.
./bin/run pg:backups:schedule <database> --app <app> --at '14:00 America/Los_Angeles'
  1. List schedules. With one attachment, verify a single DATABASE_URL: daily at 14:00 America/Los_Angeles line and no 4:00 UTC line. With a different attachment, both new schedules are listed. Other schedules already on the app are listed too.
./bin/run pg:backups:schedules --app <app>
  1. Unschedule one schedule by name. Verify Unscheduling <schedule-name> daily backups... done.
./bin/run pg:backups:unschedule <schedule-name> --app <app>
  1. Unschedule with no argument. This removes the only remaining schedule and prints Unscheduling <name> daily backups... done. If more than one schedule is still on the app, the command errors and lists them instead. If none remain, it errors with No schedules on <app>.
./bin/run pg:backups:unschedule --app <app>
  1. List schedules. The schedules from steps 1 and 2 are gone. If nothing else was scheduled, verify No backup schedules found on <app>. Otherwise the remaining schedules are listed.
./bin/run pg:backups:schedules --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 8, 2026 19:51
@github-actions github-actions Bot added size/M Medium PR (code churn < 500) docs Touches documentation labels Oct 8, 2026
@erika-wallace erika-wallace changed the title refactor(pg:backups): use @heroku/sdk in the schedule-related commands refactor: use @heroku/sdk for pg:backups commands (part 2) Oct 8, 2026
@erika-wallace
erika-wallace deployed to AcceptanceTests October 8, 2026 20:24 — with GitHub Actions Active
@erika-wallace
erika-wallace deployed to AcceptanceTests October 8, 2026 20:24 — with GitHub Actions Active
@erika-wallace
erika-wallace deployed to AcceptanceTests October 8, 2026 20:24 — with GitHub Actions Active
@erika-wallace
erika-wallace deployed to AcceptanceTests October 8, 2026 20:24 — with GitHub Actions Active

@tlowrimore-heroku tlowrimore-heroku 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.

LGTM!

@erika-wallace
erika-wallace merged commit d467964 into v12.0.0 Oct 8, 2026
26 checks passed
@erika-wallace
erika-wallace deleted the ew/pg-backups-sdk branch October 8, 2026 21:38

This branch was successfully deployed

1 active deployment
AcceptanceTests — addfd1f3 Deployed Oct 8, 2026 by erika-wallace via integration (22.x, ubuntu-latest) #9407
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