When running `pushkin-dev prep` with existing database containers from a
previous run, the command would fail with a misleading "password
authentication failed" error. This happened because the existing containers
were using different credentials than the current pushkin.yaml config.
This commit implements Option 1 from the issue: automatic detection and
cleanup of stale database containers.
Changes:
- Added `ensureCleanState()` function that checks for existing database
containers before setup
- If containers exist, displays a warning and removes them cleanly
- Uses `docker ps -a` to detect both running and stopped containers
- Follows the same pattern as `killLocal()` using compose.stop() and
compose.rm()
- Includes proper error handling to avoid failing the entire setup
Benefits:
- Makes `prep` command idempotent - safe to run multiple times
- Eliminates confusing password authentication errors
- Improves developer experience by avoiding manual cleanup steps
- No waiting through 10 failed connection attempts (~2+ minutes)
Fixes pushkin-dev prep fails cryptically when database containers already exist
1) Failing for existing container
When running
pushkin-dev prepwith existing database containers from a previous run, the command would fail with a misleading "password authentication failed" error. This happened because the existing containers were using different credentials than the current pushkin.yaml config.This commit implements Option 1 from the issue: automatic detection and cleanup of stale database containers.
Changes:
ensureCleanState()function that checks for existing database containers before setupdocker ps -ato detect both running and stopped containerskillLocal()using compose.stop() and compose.rm()Benefits:
prepcommand idempotent - safe to run multiple timesFixes pushkin-dev prep fails cryptically when database containers already exist
2) Failing for non-Pushkin site templates