feat: Add pgschema.toml configuration file support#1
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… flags Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a config file defines [schemas] with a SQL query, plan and apply commands discover tenant schemas dynamically and iterate over each one. Dump is excluded since it produces a single template schema. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests cover: no config file, explicit config path, env overrides with inheritance, schemas section, plan fields, boolean overrides, and command-level config fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ulti-tenant schema handling
pgschema.toml configuration file support
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
Add
pgschema.tomlconfiguration file support, enabling users to runpgschema plan/pgschema applywithout repeating CLI flags. Includes named environment overrides, multi-tenant schema loop, and CI workflow improvements.Configuration file (
pgschema.toml)cmd/configpackage: TOML parsing withBurntSushi/toml, base +[env.*]merge logic usingtoml.MetaData.IsDefined()to correctly handle boolean zero-value overrides (e.g.auto-approve = falsein env block overridesauto-approve = trueat base level)--configand--envpersistent flags on root commandplan,apply,dump) read config values as fallback when CLI flags are not explicitly setMulti-tenant schema loop
[schemas]config section with a SQLqueryfield that discovers tenant schema names dynamicallyplanandapplyiterate over all discovered schemas automaticallydumpis excluded — it produces a single template schema, looping would be redundantGeneratePlan,ApplyMigration) to avoid infinite recursion through the dispatch checksql.TxOptions{ReadOnly: true}) to prevent accidental data modificationCI workflow improvements
ci-test.yml: Split intounit(fast,go test -short) andintegration(matrix across PG 14-18) jobs running in parallelrelease.yml: Converted serial PG version testing into parallel matrix strategydocker-latest.yml: Switched from Docker Hub to GitHub Container Registry (GHCR)Changed files
cmd/config/config.gocmd/config/config_test.gocmd/config_integration_test.gocmd/root.go--config,--envflags andloadConfig()inPersistentPreRuncmd/plan/plan.goMarkFlagRequired("file")cmd/apply/apply.gocmd/dump/dump.goREADME.md.github/workflows/ci-test.yml.github/workflows/release.yml.github/workflows/docker-latest.ymlTest plan
go test -v ./cmd/config— unit tests for config parsing and merge logicgo test -v ./cmd -run TestConfigLoading— integration tests for config file loading through root commandgo test -v ./cmd -run TestDiscoverSchemas_ReadOnlyEnforcement— read-only transaction enforcement (SELECT allowed, CREATE/DROP/INSERT rejected)go test -v ./...— full test suite to verify no regressionspgschema.tomlwith connection details, runpgschema planwithout flags[env.dev]/[env.prod], verify--envswitching