Hi there, we have a PostgreSQL database stood up in RDS and we’re trying to connect multiple n8n instances to it using environment variables in a docker-compose format:
n8n: image: n8nio/n8n:0.69.1-ubuntu ports: - "80:5678" environment: - N8N_BASIC_AUTH_ACTIVE=true - N8N_BASIC_AUTH_USER=${N8N_USER} - N8N_BASIC_AUTH_PASSWORD=${N8N_PASS} - N8N_HOST=${N8N_HOST} - N8N_PORT=5678 - N8N_LISTEN_ADDRESS=0.0.0.0 - N8N_PROTOCOL=http - NODE_ENV=production - WEBHOOK_TUNNEL_URL=http://${N8N_HOST} - VUE_APP_URL_BASE_API=http://${N8N_HOST} - DB_TYPE=postgresdb - DB_TABLE_PREFIX=${N8N_USER}_ - DB_POSTGRESDB_DATABASE=n8n - DB_POSTGRESDB_HOST=${DB_HOST} - DB_POSTGRESDB_USER=${DB_USER} - DB_POSTGRESDB_PASSWORD=${DB_PASS}
So the first instance we start up with the following docker-compose template works great - it connects to the database, creates the tables that are needed, we can store credentials, run workflows, etc. But when we try to use the same docker-compose template to spin up another instance of n8n, we get the following error:
UnhandledPromiseRejectionWarning: Error: There was an error: relation "pk_814c3d3c36e8a27fa8edb761b0e" already exists
After some research, it looks like “pk_814c3d3c36e8a27fa8edb761b0e” is the name of the primary key constraint for the credentials_entity table. I also found this primary key referenced in this file.
Are the primary keys specific to the n8n build? Is there any way to just create a unique one upon initialization of the tables rather than build time?
Thanks!