migrator: codeinsights-db cannot be migrated without other databases configured
Created by: danieldides
Environment
Minimal docker-compose.yaml
to test with:
version: '2.4'
services:
migrator:
container_name: migrator
image: 'index.docker.io/sourcegraph/migrator:3.35.1'
cpus: 4
mem_limit: '8g'
command:
["up"]
environment:
- PGHOST=pgsql
- PGPORT=5432
- PGUSER=sg
- PGPASSWORD=sg
- PGDATABASE=sg
- PGSSLMODE=disable
- CODEINTEL_PGHOST=codeintel-db
- CODEINTEL_PGPORT=5432
- CODEINTEL_PGUSER=sg
- CODEINTEL_PGPASSWORD=sg
- CODEINTEL_PGDATABASE=sg
- CODEINTEL_PGSSLMODE=disable
- CODEINSIGHTS_PGHOST=codeinsights-db
- CODEINSIGHTS_PGPORT=5432
- CODEINSIGHTS_PGUSER=postgres
- CODEINSIGHTS_PGPASSWORD=password
- CODEINSIGHTS_PGDATABASE=postgres
- CODEINSIGHTS_PGSSLMODE=disable
restart: "on-failure"
networks:
- sourcegraph
depends_on:
pgsql:
condition: service_healthy
codeintel-db:
condition: service_healthy
pgsql:
container_name: pgsql
image: 'index.docker.io/sourcegraph/postgres-12.6-alpine:insiders@sha256:695eaa5070a879863597b077c610129685a7ab4e8ac0039864b7aad3dfc5cf5b'
cpus: 4
mem_limit: '2g'
healthcheck:
test: '/liveness.sh'
interval: 10s
timeout: 1s
retries: 10
start_period: 15s
volumes:
- 'pgsql:/data/'
networks:
- sourcegraph
restart: always
stop_grace_period: 120s
codeintel-db:
container_name: codeintel-db
image: 'index.docker.io/sourcegraph/codeintel-db:insiders@sha256:a525705803fc787d20aed15e74c739bbfb77eed4351cbb6d1a46edc89877319b'
cpus: 4
mem_limit: '2g'
healthcheck:
test: '/liveness.sh'
interval: 10s
timeout: 1s
retries: 10
start_period: 15s
volumes:
- 'codeintel-db:/data/'
networks:
- sourcegraph
restart: always
stop_grace_period: 120s
codeinsights-db:
container_name: codeinsights-db
image: "index.docker.io/sourcegraph/codeinsights-db:insiders@sha256:56596dff34785b950fe69bcf051cbd2b7cd47fbc8d9733e8fd8af180047cdcb8"
cpus: 4
mem_limit: "2g"
environment:
- POSTGRES_PASSWORD=password
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- "codeinsights-db:/var/lib/postgresql/data/"
networks:
- sourcegraph
restart: always
stop_grace_period: 120s
volumes:
pgsql:
codeintel-db:
codeinsights-db:
networks:
sourcegraph:
Run with: docker compose -f /path/to/file.yaml up
and down with docker compose -f /path/to/file.yaml -v down --remove-orphans
to reset between tests.
frontend
only:
Migrating Commenting out the CODEINTEL_
and CODEINSIGHTS_
env vars and changing the command
to ["up", "-db", "frontend"]
yields:
migrator | t=2022-01-21T00:21:11+0000 lvl=info msg="Checked current version" schema=frontend version=1528395964 dirty=false
migrator | t=2022-01-21T00:21:11+0000 lvl=info msg="Checked current version" schema=frontend version=1528395964 dirty=false
migrator | t=2022-01-21T00:21:11+0000 lvl=info msg="Upgrading schema" schema=frontend
migrator exited with code 0
where the migrator starts and migrates the frontend
alone.
codeinsights
only:
Migrating Commenting out PG_
and CODEINTEL_
env vars and changing the command
to ["up", "-db", "codeinsights"]
yields:
migrator | error: frontend and codeintel databases must be distinct: postgres://[email protected]:5432 and postgres://[email protected]:5432 seem to refer to the same database
migrator exited with code 1
If you add back in all three sets of env vars, it starts and succeeds as expected. It does not appear to make a connection (the values can invalid) but it needs them set to be able to identify that the connection strings are different.