Database migration runner for PostgreSQL and MySQL
1.4K
Simple database migration runner for PostgreSQL and MySQL.
docker run \
-e DB_TYPE=postgresql \
-e DB_HOST=localhost \
-e DB_NAME=myapp \
-e DB_USER=postgres \
-e DB_PASSWORD=secret \
-v $(pwd)/migrations:/migrations \
ogulcanaydogan/db-migrate up
| Command | Description |
|---|---|
up [VERSION] | Apply pending migrations (optionally up to VERSION) |
down [STEPS] | Roll back migrations (default: 1 step) |
status | Show applied and pending migrations |
create NAME | Create new migration file pair |
migrations/
├── 001_create_users.up.sql
├── 001_create_users.down.sql
├── 002_add_email_index.up.sql
└── 002_add_email_index.down.sql
| Variable | Description | Default |
|---|---|---|
DB_TYPE | postgresql or mysql | postgresql |
DB_HOST | Database host | localhost |
DB_PORT | Database port | Auto-detected |
DB_NAME | Database name (required) | - |
DB_USER | Database user (required) | - |
DB_PASSWORD | Database password | - |
MIGRATIONS_DIR | Path to migration files | /migrations |
DRY_RUN | Set to true for dry run | false |
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: myapp
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secret
migrate:
image: ogulcanaydogan/db-migrate
command: ["up"]
depends_on:
db:
condition: service_healthy
environment:
- DB_HOST=db
- DB_NAME=myapp
- DB_USER=postgres
- DB_PASSWORD=secret
volumes:
- ./migrations:/migrations
MIT
Content type
Image
Digest
sha256:8e7fe60e1…
Size
74.1 MB
Last updated
7 months ago
docker pull ogulcanaydogan/db-migrate