Table "user" does not exist when I specify custom schema in postgres

  • **n8n version: 1.4.1
  • **Database (default: SQLite):postgresQL
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):Docker
  • **Operating system:Amazon Linux 2

So basically I just specified my custom schema and when I do it seems to only create the “migrations” table and nothing else. The setup runs flawlessly when I don’t specify the schema (defaults to “public” schema).

error:

There was an error running database migrations
n8n_docker-n8n-1       | TypeORMError: Table "user" does not exist.
n8n_docker-postgres-1  | 2023-09-01 14:10:59.841 UTC [436] FATAL:  role "-d" does not exist

docker-compose.yml:

version: '3.8'

volumes:
  db_storage:
  n8n_storage:

services:
  postgres:
    image: postgres:11
    restart: always
    environment:
      - POSTGRES_USER=***
      - POSTGRES_PASSWORD=***
      - POSTGRES_DB=***
      - DB_POSTGRESDB_SCHEMA=N8N
      - POSTGRES_NON_ROOT_USER
      - POSTGRES_NON_ROOT_PASSWORD
    volumes:
      - db_storage:/var/lib/postgresql/data
      - ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
      interval: 5s
      timeout: 5s
      retries: 10

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=***
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=***
      - DB_POSTGRESDB_USER=***
      - DB_POSTGRESDB_PASSWORD=***
      - DB_POSTGRESDB_SCHEMA=N8N
    ports:
      - 5678:5678
    links:
      - postgres
    volumes:
      - n8n_storage:/home/node/.n8n
    depends_on:
      postgres:
        condition: service_healthy

I created the schema in my database so I have no idea what’s going on, thank you in advance!

Hey @C11,

Welcome to the community :raised_hands:

Can you share the init-data.sh you are using? I just created a new database and I noticed that Postgres seems to prefer lowercase schema names so it could be that if you change DB_POSTGRESDB_SCHEMA to n8n it will just work.

It looks like that was the solution! Thank you Jon!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.