From 31d299499745e890e3d08567d66cbf4aa3e0554b Mon Sep 17 00:00:00 2001 From: yukkop Date: Thu, 30 Apr 2026 15:48:33 +0000 Subject: [PATCH] feat(`db-tool`): `postgres-init`: apply hectic-inheritance by default Flip PG_HECTIC_INHERITANCE default 0 -> 1. Set PG_HECTIC_INHERITANCE=0 to opt out. --- package/db-tool/README.md | 7 ++----- package/db-tool/postgres-init.sh | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/package/db-tool/README.md b/package/db-tool/README.md index 0e37e4c..b5c2248 100644 --- a/package/db-tool/README.md +++ b/package/db-tool/README.md @@ -32,7 +32,7 @@ These variables must be set for `db-tool` to function. | `PG_CONF_FILE` | (unset) | Path to a `postgresql.conf` file. When set, replaces the script-generated config entirely on fresh init. `port` and `unix_socket_directories` are still appended at runtime (always overridden). When set, `PG_DISABLE_LOGGING` and `PG_SHARED_PRELOAD_LIBRARIES` are ignored. | | `PG_SHARED_PRELOAD_LIBRARIES` | `pg_cron` | Comma-separated `shared_preload_libraries` value. Set to empty string to disable. Ignored when `PG_CONF_FILE` is set. | | `PG_DISABLE_LOGGING` | `0` | Set to `1` to disable PostgreSQL logging collector. Ignored when `PG_CONF_FILE` is set. | -| `PG_HECTIC_INHERITANCE` | `0` | Set to `1` to apply the [`hectic` inheritance bundle](#hectic-inheritance-bundle) to the target database after init. | +| `PG_HECTIC_INHERITANCE` | `1` | Apply the [`hectic` inheritance bundle](#hectic-inheritance-bundle) to the target database after init. Set to `0` to disable. | | `HECTIC_INHERITANCE_SQL` | (auto) | Override path to the SQL file applied by `PG_HECTIC_INHERITANCE=1`. Defaults to the SQL shipped with `postgres-init`. | | `PATCH_LOG` | (stdout) | Path to log the output of database patches. | | `HYDRATE_LOG` | (stdout) | Path to log the output of database hydration. | @@ -136,10 +136,7 @@ ALTER DATABASE mydb SET hectic.inheritance_extra_excluded_schemas = 'legacy,etl' ### Apply via `postgres-init` -```sh -export PG_HECTIC_INHERITANCE=1 -postgres-init -``` +Applied automatically. Set `PG_HECTIC_INHERITANCE=0` to opt out. ### Apply via `migrator` or any psql pipeline diff --git a/package/db-tool/postgres-init.sh b/package/db-tool/postgres-init.sh index c298cf6..2bef1c7 100644 --- a/package/db-tool/postgres-init.sh +++ b/package/db-tool/postgres-init.sh @@ -48,7 +48,7 @@ postgres_init_main() { fi psql -h "$sockdir" -p "$PG_PORT" -d "$db" -v ON_ERROR_STOP=1 -c 'select 1;' || return 1 - if [ "${PG_HECTIC_INHERITANCE:-0}" = "1" ]; then + if [ "${PG_HECTIC_INHERITANCE:-1}" = "1" ]; then sql_file="${HECTIC_INHERITANCE_SQL:-${HECTIC_INHERITANCE_SQL_DEFAULT:-}}" if [ -z "$sql_file" ]; then printf '%s\n' 'postgres-init: PG_HECTIC_INHERITANCE=1 but no SQL file resolved (set HECTIC_INHERITANCE_SQL)' >&2