ERROR "sql schema version compatibility check failed: unable to read DB schema version keyspace/database: temporal error: pq: relation "schema_version" does not exis"

Hi
I am following this doc for self-hosting temporal for the production environment and settled the config file using the below link

https://github.dev/temporalio/temporal/blob/master/config/development-postgres.yaml

In the Postgres DB, I have two databases temporal and temporal_visibility.

Using the below Docker run command

docker run \
  -e SERVICES=history,matching,worker,frontend \
  -e LOG_LEVEL=info \
  -e DYNAMIC_CONFIG_FILE_PATH=<CONFIG_FILE_LOCATION>/config/docker.yaml \
  -v <CONFIG_FILE_LOCATION>/config/docker.yaml:/etc/temporal/config/config_template.yaml \
  -v <CONFIG_FILE_LOCATION>/config/dynamicconfig/development-sql.yaml:/etc/temporal/config/dynamicconfig/development-sql.yaml \
  temporalio/server:latest

Error:

[Fx] PROVIDE    fx.Shutdowner <= go.uber.org/fx.(*App).shutdowner-fm()
[Fx] PROVIDE    fx.DotGraph <= go.uber.org/fx.(*App).dotGraph-fm()
[Fx] ERROR              Failed to initialize custom logger: could not build arguments for function "go.uber.org/fx".(*App).constructCustomLogger.func2
        /go/pkg/mod/go.uber.org/fx@v1.18.2/app.go:414:
failed to build fxevent.Logger:
could not build arguments for function "go.temporal.io/server/temporal".glob..func8
        /home/builder/temporal/temporal/fx.go:921:
failed to build log.Logger:
received non-nil error from function "go.temporal.io/server/temporal".ServerOptionsProvider
        /home/builder/temporal/temporal/fx.go:158:
sql schema version compatibility check failed: unable to read DB schema version keyspace/database: temporal error: pq: relation "schema_version" does not exist
Unable to create server. Error: could not build arguments for function "go.uber.org/fx".(*App).constructCustomLogger.func2 (/go/pkg/mod/go.uber.org/fx@v1.18.2/app.go:414): failed to build fxevent.Logger: could not build arguments for function "go.temporal.io/server/temporal".glob..func8 (/home/builder/temporal/temporal/fx.go:921): failed to build log.Logger: received non-nil error from function "go.temporal.io/server/temporal".ServerOptionsProvider (/home/builder/temporal/temporal/fx.go:158): sql schema version compatibility check failed: unable to read DB schema version keyspace/database: temporal error: pq: relation "schema_version" does not exist

I think couple of things are missing on that page you linked. You have to set up your persistence and visibility schemas up-front (not just create temporal, temporal_visibility).

If you intend to use the temporalio/server image (advised to use so you can set up each service role on independent container) you would need to either set up schemas before you stand up cluster via script or maybe make it entry-point of admin-tolls image, see sample here.

Also the service has two config files, static and dynamic config. Static config is required and for the temporalio/server image its generated for you from default template and the env vars you set. You can also create your custom template if you wanted to expose some fields that are not in default template or you want to restrict it in ways, see sample here.

I think if you want to stand up cluster quick on docker with each service role in its own container, use compose sample here which by the way is being moved to our official docker compose repo too, see pr here.

One more thing, dont use “latest” as your image version. It can lead to issues. Best practice would be to always define a specific version for your images.

Thank you for your reply.
I was able to spin stand alone temporal following this repo that you shared.

Understood from one official doc that the minimum Temporal Server dependency is a database and all the grafana, elastic search etc. are only optional.

I need to spin my temporal standalone server with AWS RDS as database and currently not going with any additional feature. Can you please help on this.