Repository navigation
Add SCHEMAVAULTS_DBH_ADAPTER env var support for adapter selection - #5
Merged
Merged
Conversation
…er selection
The CLI's migrate/reverse commands previously hardcoded the
postgres-neon-proxy adapter. Adapter selection is now resolved as:
--adapter flag > SCHEMAVAULTS_DBH_ADAPTER env var (including values
loaded from --env-file) > postgres-neon-proxy default.
- Add SchemaVaultsDbhAdapterType ("postgres" | "postgres-neon-proxy")
with an isValidDbhAdapterType() guard
- Add getDbhAdapterTypeFromEnv() util that validates the env var and
throws on unrecognized values instead of silently falling back
- createDbh(undefined, opts) now falls back to SCHEMAVAULTS_DBH_ADAPTER,
throwing when neither an adapter type nor the env var is set
- Warn when --ws-proxy-url is passed to a non-proxy adapter
- Fix SchemaVaultsPostgresAdapter's init log claiming to be the
NeonProxy adapter, so debug output reflects the selected adapter
- Document the env var and flag in README.md and CLAUDE.md; add unit
tests covering resolution, precedence, and error cases
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LiV9mbTstiiKfPL1FuwrUr
…ore widening cast Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LiV9mbTstiiKfPL1FuwrUr
Add a LICENSE file and update package.json's license field from UNLICENSED to MIT; sync the README's docker image version example. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LiV9mbTstiiKfPL1FuwrUr
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
This PR adds support for selecting the database adapter via the
SCHEMAVAULTS_DBH_ADAPTERenvironment variable, enabling more flexible deployment configurations without requiring code changes. The CLI andcreateDbh()factory now support a consistent adapter resolution strategy with clear precedence rules.Key Changes
New adapter type system (
src/types/SchemaVaultsDbhAdapterType.ts):SchemaVaultsDbhAdapterTypeunion type ("postgres" | "postgres-neon-proxy")isValidDbhAdapterType()type guard andSCHEMAVAULTS_DBH_ADAPTER_TYPESconstantSCHEMAVAULTS_DBH_ADAPTERinProcessEnvfor type-safe environment variable accessEnvironment variable resolution (
src/utils/getDbhAdapterTypeFromEnv.ts):SCHEMAVAULTS_DBH_ADAPTERenv varTypeErroron invalid values to fail loudly instead of silently falling backEnhanced
createDbh()factory (src/create-dbh.ts):undefinedasadapter_typeto defer to the environment variableSCHEMAVAULTS_DBH_ADAPTERwhen no adapter type is explicitly passedCLI adapter selection (
src/cli.ts):-a, --adapter <adapter>flag to bothmigrateandreversecommandsresolveCliAdapterType()with three-tier precedence:--adapterflagSCHEMAVAULTS_DBH_ADAPTERenvironment variable"postgres-neon-proxy"(historical default)--ws-proxy-urlis used with non-neon-proxy adapterscreateDbh()factory callsDocumentation (README.md):
createDbh()SCHEMAVAULTS_DBH_ADAPTERandSCHEMAVAULTS_DBH_DEBUGto optional environment variablesComprehensive test coverage (
src/tests/DbhAdapterTypeFromEnv.test.ts):getDbhAdapterTypeFromEnv()utilitycreateDbh()fallback behaviorPackage exports (
src/index.ts):getDbhAdapterTypeFromEnv()for public useImplementation Details
"postgres-neon-proxy"when neither flag nor env var is sethttps://claude.ai/code/session_01LiV9mbTstiiKfPL1FuwrUr