Skip to content

Conversation

@brempusz
Copy link

What was changed

It is possible to use two separate database names: one for "core" and one for "visibility" database. By default, the same user/password was used for both databases.

This change adds two new env variables that can be used to provide user/pass for "visibility" database.

Small fix applied: use -pw parameter instead of exported SQL_PASSWORD env variable.

Why?

  • To fully support database separation.
  • To use single database with separate schemas for core/visibility (by creating users with default search_path)

Checklist

  1. Closes [Feature Request] Add VISIBILITY_POSTGRES_USER/PWD parameters to auto-setup.sh #291

  2. How was this tested:
    I checked out https://github.com/temporalio/docker-compose
    I used modified docker-compose file:

version: "3.5"
services:
  postgresql:
    container_name: temporal-postgresql
    environment:
      POSTGRES_PASSWORD: temporal
      POSTGRES_USER: temporal
    image: postgres:${POSTGRESQL_VERSION}
    networks:
      - temporal-network
    ports:
      - 5432:5432
    volumes:
      - /var/lib/postgresql/data
      - ./customize/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/
  temporal:
    container_name: temporal
    depends_on:
      - postgresql
    environment:
      - SKIP_DB_CREATE=true
      - DBNAME=temporal
      - VISIBILITY_DBNAME=temporal
      - DB=postgres12
      - DB_PORT=5432
      - POSTGRES_USER=temporal_core
      - POSTGRES_PWD=temporal_core
      - VISIBILITY_POSTGRES_USER=temporal_visibility
      - VISIBILITY_POSTGRES_PWD=temporal_visibility
      - POSTGRES_SEEDS=postgresql
      - DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development-sql.yaml
      - TEMPORAL_ADDRESS=temporal:7233
      - TEMPORAL_CLI_ADDRESS=temporal:7233
    image: temporalio/auto-setup:${TEMPORAL_VERSION}
    networks:
      - temporal-network
    ports:
      - 7233:7233
    volumes:
      - ./dynamicconfig:/etc/temporal/config/dynamicconfig
      - ./customize/auto-setup.sh:/etc/temporal/auto-setup.sh
  temporal-admin-tools:
    container_name: temporal-admin-tools
    depends_on:
      - temporal
    environment:
      - TEMPORAL_ADDRESS=temporal:7233
      - TEMPORAL_CLI_ADDRESS=temporal:7233
    image: temporalio/admin-tools:${TEMPORAL_ADMINTOOLS_VERSION}
    networks:
      - temporal-network
    stdin_open: true
    tty: true
  temporal-ui:
    container_name: temporal-ui
    depends_on:
      - temporal
    environment:
      - TEMPORAL_ADDRESS=temporal:7233
      - TEMPORAL_CORS_ORIGINS=http://localhost:3000
    image: temporalio/ui:${TEMPORAL_UI_VERSION}
    networks:
      - temporal-network
    ports:
      - 8080:8080
networks:
  temporal-network:
    driver: bridge
    name: temporal-network

postgres initdb script (to create test users):

create schema core;

-- "superuser" role is needed because temporal schema migration scrips use "create extension"
create user temporal_core with encrypted password 'temporal_core' superuser;
alter schema core owner to temporal_core;
alter role temporal_core set search_path = core;


create schema visibility;

-- "superuser" role is needed because temporal schema migration scrips use "create extension"
create user temporal_visibility with encrypted password 'temporal_visibility' superuser;
alter schema visibility owner to temporal_visibility;
alter role temporal_visibility set search_path = visibility;

Started the stack using docker compose and checked the logs, database contents.

  1. Any docs updates needed?
    probably https://docs.temporal.io/self-hosted-guide/visibility#postgresql

Maybe example docker-compose should be added to https://github.com/temporalio/docker-compose

It is possible to use two separate database names: one for "core"
and one for "visibility" database. By default, the same
user/password was used for both databases.

This change adds two new env variables that can be used to provide
user/pass for "visibility" database.

Small fix applied: use `-pw` parameter instead of exported
`SQL_PASSWORD` env variable.
@brempusz brempusz requested a review from a team as a code owner October 23, 2025 09:23
@CLAassistant
Copy link

CLAassistant commented Oct 23, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add VISIBILITY_POSTGRES_USER/PWD parameters to auto-setup.sh

2 participants