Repository navigation
Conversation
Adds data.databaseSettings.{getAll, get, update}. Each resolves the
Postgres database (DATABASE_URL by default), rejects Essential-tier
databases with EssentialDatabaseNotSupportedError, and returns the
resolved add-on with the settings. get/update throw UnknownSettingError
when the database's settings don't include the key.
W-23389002
2 of 8 tasks
- Reject Advanced-tier databases with AdvancedDatabaseNotSupportedError before any settings request; those databases use data.postgresSettings. Doc comments now say the resource covers classic tiers. - Rename UnknownSettingError to UnknownDatabaseSettingError to match its id and the other database error names. - Add `key` to get/update results so the result says which setting it is. - When an update response lacks the key, say the update was sent but couldn't be confirmed, instead of saying the setting doesn't exist. - Treat a setting as missing only when it's undefined. - Add the ./resources/data/database-settings package export, like the sibling data resources. - Tests: pin the database identity and signal for get/update and the resolver, aborted update sends nothing, falsy values, Advanced-tier rejection, and end-to-end wiring against the real request URLs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
data.databaseSettings.{getAll, get, update}so the v12 CLI'spg:settingscommands can drop their own database resolution and their direct calls to/postgres/v0/databases/{id}/config.getAll(appIdentity, databaseIdentity?, options?)returns{addon, settings}.get(appIdentity, key, databaseIdentity?, options?)returns{addon, setting}.update(appIdentity, key, value, databaseIdentity?, options?)sends only{[key]: value}and returns{addon, setting}.Each one resolves the database through
resolvePgDatabase(DATABASE_URLby default) and rejects Essential-tier databases withEssentialDatabaseNotSupportedErrorbefore calling the config endpoint.getandupdatethrow a newUnknownSettingError(idunknown_database_setting) when the response doesn't include the key. The endpoint only returns the keys the database's tier supports.Notes:
databaseSettingsresource, notdatabase.settings, because extensions add methods to a resource and can't add nested objects.PostgresDatabaseUpdateConfigOptsin@heroku/typeslists only 3 of the keys the endpoint accepts, soupdatecasts the body. The key and value types come fromPostgresDatabaseConfigResult, which lists every key.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:
The CLI side is in heroku/cli on branch
eb/W-23389002/pg-settings-sdk. You need a non-Essential Heroku Postgres database to try it.Steps:
npm run build, then in a script:const sdk = new HerokuSDK({extensions: [databaseSettingsExtensions]}).await sdk.data.databaseSettings.getAll('<app>')returns theDATABASE_URLdatabase's add-on and every setting.await sdk.data.databaseSettings.get('<app>', 'log_lock_waits')returns that one setting.await sdk.data.databaseSettings.update('<app>', 'log_lock_waits', true)returns the updated setting. Set it back afterward.EssentialDatabaseNotSupportedErrorwithout calling the config endpoint.Related Issues
GUS work item: W-23389002