https://github.com/escalopa/migrate-go
A library to migrate database
https://github.com/escalopa/migrate-go
golang migration
Last synced: 2 months ago
JSON representation
A library to migrate database
- Host: GitHub
- URL: https://github.com/escalopa/migrate-go
- Owner: escalopa
- License: apache-2.0
- Created: 2023-11-01T20:28:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-19T11:22:10.000Z (over 1 year ago)
- Last Synced: 2025-01-19T15:20:16.320Z (4 months ago)
- Topics: golang, migration
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# migrate-go 💨
This is a tool to migrate database.
Built upon [migrate](https://github.com/golang-migrate/migrate).Core feature is that it can read database dsn from file not only raw string. 🔥
## Usage 🧰
### Flags 🚩
- `-d` : database dsn raw string
- `-f` : file secret path to read database dsn (overwrite `-d`)
- `-dir` : migration directory absolute path### Docker 🐳
1. Using DSN raw string
```bash
docker pull dekuyo/migrate-go:latest
docker run --rm -it -v $PWD:/app dekuyo/migrate-go -dir /app/migration -d "user:password@host:port/database"
```2. Using DSN file
```bash
docker pull dekuyo/migrate-go:latest
docker run --rm -it -v $PWD:/app -v /path/to/dsn/file:/path/to/dsn/file dekuyo/migrate-go -dir /app/migration -f /path/to/dsn/file
```### Docker Compose 🐳
1. Using DSN raw string
```yaml
db-migrate:
image: dekuyo/migrate-go:latest
volumes:
- ./migrations:/migrations
command: [ "-dir", "/migrations", "-dsn", "postgres://postgres:postgres@db:5432/order-shop?sslmode=disable" ]
```2. Using DSN file
```yaml
db-migrate:
image: dekuyo/migrate-go:latest
volumes:
- ./migrations:/migrations
- ./path/to/dsn/file:/path/to/dsn/file
command: [ "-dir", "/migrations", "-file", "/path/to/dsn/file" ]
``