supertokens-docker-postgresql icon indicating copy to clipboard operation
supertokens-docker-postgresql copied to clipboard

[BUG] `?schema` connection param is not respected

Open jkazimierczak opened this issue 1 year ago • 0 comments

Issue Summary

SuperTokens container doesn't respect ?schema connection string param. Only if the POSTGRESQL_TABLE_SCHEMA variable is specified, then the ST uses that schema instead.

Steps to reproduce

  1. Create necessary files (.env and docker-compose.yaml)
  2. Run:
docker-compose down -v
docker-compose up -d
  1. Check the database with any tool of choice.

Expected Behavior

?schema connection param is respected.

Additional context

docker-compose.yaml

version: "3.8"

services:
    appPostgres:
        image: postgres:alpine
        container_name: app_postgres
        restart: unless-stopped
        environment:
            - POSTGRES_USER=username
            - POSTGRES_PASSWORD=password
            - POSTGRES_DB=app
        ports:
            - "5432:5432"
        volumes:
            - app_postgres_data:/var/lib/postgresql/data
        healthcheck:
            test:
                [
                    "CMD-SHELL",
                    "sh -c 'pg_isready -U username -d app'",
                ]
            interval: 10s
            timeout: 5s
            retries: 5

    # https://github.com/supertokens/supertokens-docker-postgresql/blob/master/README.md
    supertokens:
        image: registry.supertokens.io/supertokens/supertokens-postgresql:7.0
        restart: unless-stopped
        depends_on:
            appPostgres:
                condition: service_healthy
        ports:
            - 3567:3567
        environment:
            - POSTGRESQL_CONNECTION_URI="postgresql://username:password@appPostgres:5432/app?schema=super_tokens"
        healthcheck:
            test: >
                bash -c 'exec 3<>/dev/tcp/127.0.0.1/3567 && echo -e "GET /hello HTTP/1.1\r\nhost: 127.0.0.1:3567\r\nConnection: close\r\n\r\n" >&3 && cat <&3 | grep "Hello"'
            interval: 10s
            timeout: 5s
            retries: 5

networks:
    default:
        name: app_net

volumes:
    app_postgres_data:

All of ST-related tables are generated inside of public schema instead of specified schema:

image

jkazimierczak avatar Mar 04 '24 18:03 jkazimierczak