feat(workflow-executor): allow custom DB schema via DATABASE_SCHEMA env var#1754
feat(workflow-executor): allow custom DB schema via DATABASE_SCHEMA env var#1754nbouliol wants to merge 4 commits into
Conversation
…nv var The standalone CLI was locked to the `forest` schema: it read no schema env var and never set `database.schema`, so resolveSchema always fell back to DEFAULT_SCHEMA. Add a DATABASE_SCHEMA env var (mirroring DATABASE_SSL) so the CLI can target another schema; blank/unset keeps the `forest` default. Library consumers could already pass database.schema — this closes the CLI gap. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…up log Replace the bare 'forest' literal in logStartup with the existing DEFAULT_SCHEMA constant, removing the duplicated default, and drop the redundant what/where comment on the DATABASE_SCHEMA read. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (2)
🛟 Help
|
|
Nice — clean change and the 1. Validate
|
… privilege The schema now flows into raw DDL, so validate it as a Postgres identifier at the boundary (fail fast with ConfigurationError instead of a cryptic SQL error), and reject values past the 63-char limit Postgres would silently truncate. Document in the README that boot runs CREATE SCHEMA IF NOT EXISTS, which needs CREATE on the database even when the schema already exists. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Both addressed in f5efb65. 1. Validation — 2. README — documented. I verified the privilege behavior empirically on PG 15 rather than trust my assumption: with a role lacking Worth noting this requirement is not new to this PR: the boot-time |
…xists Postgres checks the database-level CREATE privilege for CREATE SCHEMA IF NOT EXISTS even when the schema is present, so an operator who pre-creates the schema still needed database-level CREATE just to boot. Probe pg_namespace first (world-readable, no privilege) inside the migration lock and skip the CREATE when the schema exists, so a DB user with only schema-level CREATE on a pre-created schema can run the executor. Document both grant paths in the README. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Summary
The standalone workflow-executor CLI was locked to the Postgres
forestschema. It read no schema env var and never setdatabase.schema, soresolveSchemaalways fell back toDEFAULT_SCHEMA. Library consumers could already passdatabase.schema— this closes the CLI gap.Changes
cli-core.ts: newDATABASE_SCHEMAenv var (mirrorsDATABASE_SSL) — read intoCliConfig, injected into thedatabaseoptions, surfaced in--helpand the startup log. Blank/unset resolves to theforestdefault.buildDatabase, and the startup-log schema.DATABASE_SCHEMAin the Database connection table + note.No store/build changes: the downstream plumbing and
forestfallback already existed.Test plan
yarn workspace @forestadmin/workflow-executor test -- test/cli.test.ts(108 passed)yarn workspace @forestadmin/workflow-executor lint(0 errors)yarn workspace @forestadmin/workflow-executor buildFixes PRD-773
🤖 Generated with Claude Code
Note
Add
DATABASE_SCHEMAenv var support to workflow-executor for custom Postgres schemaDATABASE_SCHEMAenvironment variable to cli-core.ts that sets the Postgres schema used by the executor, defaulting to"forest".ConfigurationErroron startup.DatabaseExecutorOptionswhen set, and includes it in structured startup logs.CREATEprivilege on the database at boot time due toCREATE SCHEMA IF NOT EXISTS.Changes since #1754 opened
runMigrationsinschema-migrations.tsto probepg_namespacefor schema existence before attempting schema creation [b6c7707]database-store-schema.test.tsto verify schema existence probing behavior [b6c7707]CLAUDE.mdandREADME.mdto document schema existence probing and reduced privilege requirements [b6c7707]Macroscope summarized f5efb65.