Skip to content

Postgres - allow custom schema #291

@thomasjiangcy

Description

@thomasjiangcy

Desired Behavior

First off, thank you for this project! It kind of came at a really nice time as I was evaluating options like Temporal, Restate, DBOS, etc.

Allow customizing schema used for tables. Currently hardcoded to openworkflow.

This is mainly for flexibility around different levels of isolation. The current state allows for two types of isolation - via namespace and physical isolation (different PG instances/clusters).

I'm building a project that involves control/data plane (not live yet!) but in specific deployment scenarios, the control/data plane boundaries are strict, so each plane will have its own set of openworkflow workers and pg instance -- this is possible right now. However, in development or other deployment scenarios (e.g. simpler setups like single-host deploys), it may be worthwhile to maintain isolation beyond namespaces in a single pg instance such as control_plane schema and data_plane schema.

Example Usage

// apps/control-plane/openworkflow.config.ts
...
export default defineConfig({
  backend: isDev
    ? BackendSqlite.connect("./openworkflow/backend.db")
    : await BackendPostgres.connect(process.env.OPENWORKFLOW_POSTGRES_URL!, {
    schema: "control_plane", // exposed here
   }),
  ...
});

// apps/data-plane/openworkflow.config.ts
...
export default defineConfig({
  backend: isDev
    ? BackendSqlite.connect("./openworkflow/backend.db")
    : await BackendPostgres.connect(process.env.OPENWORKFLOW_POSTGRES_URL!, {
    schema: "data_plane", // exposed here
   }),
  ...
});

I'm not sure if this is something directionally aligned, since I noticed this in postgres.js:

// The default schema to use for OpenWorkflow data. This type is more for
// documentation than for practical use. The only time we allow schema
// customization is during testing, specifically for testing migrations.
// Everywhere else uses the "openworkflow" schema directly for prepared
// statements.

I'll be happy to take a stab at this if this is something you're open to exposing as a config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions