Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
dc8875d
feat: add config package with TOML parsing and LoadConfig
William-W-Chen May 14, 2026
8d14729
test: add config merge, boolean override, and error case tests
William-W-Chen May 14, 2026
2213d48
feat: add --config and --env flags to root command
William-W-Chen May 14, 2026
4c3958f
feat: plan/apply/dump commands read config values as fallback for CLI…
William-W-Chen May 14, 2026
b92078e
feat: add multi-tenant schema loop for plan and apply commands
William-W-Chen May 14, 2026
cf1cac8
test: add integration tests for config file loading and env overrides
William-W-Chen May 14, 2026
dd416f9
docs: update comments for ResolvedConfig, envConfig, and fileConfig s…
William-W-Chen May 14, 2026
e6fe1f3
feat: add configuration file support with environment overrides and m…
William-W-Chen May 14, 2026
a837a08
feat: implement read-only transaction for schema discovery queries
William-W-Chen May 14, 2026
5b23197
feat: add tests for read-only transaction enforcement in schema disco…
William-W-Chen May 14, 2026
9a57b5a
refactor: streamline CI workflows for unit and integration tests with…
William-W-Chen May 14, 2026
d4dca47
feat: update Docker workflow to use GitHub Container Registry
William-W-Chen May 14, 2026
03e59de
fix: ensure integration tests depend on unit tests in CI workflow
William-W-Chen May 14, 2026
f674c42
refactor: streamline CI workflows for unit and integration tests with…
William-W-Chen May 14, 2026
6df6f1a
fix: ensure integration tests depend on unit tests in CI workflow
William-W-Chen May 14, 2026
3130e92
refactor: consolidate unit and integration tests into a single CI job
William-W-Chen May 14, 2026
413e19a
revert: undo unnecessary trailing newline change in ci-test.yml
William-W-Chen May 14, 2026
3e2b293
Merge branch 'ci/matrix-improvements' into feat/config-file
William-W-Chen May 14, 2026
0b07702
refactor: remove integration test job from CI workflow
William-W-Chen May 14, 2026
282b531
Merge pull request #1 from NFUChen/feat/config-file
NFUChen May 14, 2026
9b5d90f
refactor: enhance PreRunE hooks to apply configuration for apply, dum…
William-W-Chen May 14, 2026
f4e4d43
feat: enhance PreRunE hooks to apply configuration for apply, dump, a…
William-W-Chen May 14, 2026
a0c9516
revert: restore changes from upstream base main
William-W-Chen May 14, 2026
d058178
refactor: remove applyConfigToDump call from runDump function
William-W-Chen May 14, 2026
b3c5463
fix: skip multi-schema path when --plan flag is used in apply
William-W-Chen May 15, 2026
2010913
fix: use URL-encoded DSN in DiscoverSchemas to prevent injection
William-W-Chen May 15, 2026
bd11fcc
fix: apply plan DB env vars in runPlanMultiSchema
William-W-Chen May 15, 2026
56c1b23
fix: apply plan DB env vars in runApplyMultiSchema
William-W-Chen May 15, 2026
cfc80b8
fix: redirect multi-schema progress banners to stderr
William-W-Chen May 15, 2026
953a0e5
fix: use per-schema output filenames to prevent overwrite in multi-sc…
William-W-Chen May 15, 2026
d5a78ea
fix: clear resolved config when config file is absent
William-W-Chen May 15, 2026
268e82c
test: add tests for deriveSchemaOutputTarget and --plan multi-schema …
William-W-Chen May 15, 2026
2073159
feat: implement multi-schema plan handling and output processing
William-W-Chen May 15, 2026
19c132f
feat: refactor output processing to use Outputter interface for plans
William-W-Chen May 15, 2026
49e13fa
feat: add human-readable preview output for multi-schema plans
William-W-Chen May 15, 2026
3a34820
Refactor privilege and schema management plans to standardize JSON st…
William-W-Chen May 15, 2026
7baa7b0
Refactor migration plan structure and related functions
William-W-Chen May 15, 2026
51b0176
chore: rename go file
William-W-Chen May 15, 2026
4e4d7bc
refactor: rename GeneratePlan to GenerateSchemaPlan for clarity
William-W-Chen May 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,75 @@ If the build fails with a `vendorHash` mismatch, update `nix/pgschema.nix` with
- [Docs](https://www.pgschema.com)
- [GitHub issues](https://github.com/pgplex/pgschema/issues)

## Configuration file

Instead of passing flags every time, you can create a `pgschema.toml` config file:

```toml
host = "localhost"
port = 5432
db = "myapp"
user = "postgres"
schema = "public"
file = "schema.sql"
```

Then simply run:

```bash
pgschema plan
pgschema apply
```

### Named environments

Use `[env.*]` blocks to define per-environment overrides. Values inherit from the base level:

```toml
schema = "public"
file = "schema.sql"

[env.dev]
host = "localhost"
db = "myapp_dev"
user = "postgres"

[env.prod]
host = "prod-db.internal"
db = "myapp_prod"
user = "app_user"
lock-timeout = "30s"
auto-approve = false
```

```bash
pgschema plan --env dev
pgschema apply --env prod
```

### Multi-tenant schema loop

For multi-tenant setups where each tenant has its own schema, define a `[schemas]` block with a SQL query that returns schema names. `plan` and `apply` will iterate over all discovered schemas automatically:

```toml
host = "localhost"
db = "myapp"
user = "postgres"
file = "tenant.sql"

[schemas]
query = "SELECT schema_name FROM information_schema.schemata WHERE schema_name LIKE 'tenant_%'"
```

```bash
pgschema plan # plans migration for each tenant schema
pgschema apply # applies migration to each tenant schema
```

### Priority

CLI flags always take precedence: **CLI flags > env vars > config env > config base > defaults**.

## Quick example

### Step 1: Dump schema
Expand Down
Loading