Categorygithub.com/efureev/db-migrator
modulepackage
1.4.7
Repository: https://github.com/efureev/db-migrator.git
Documentation: pkg.go.dev

# README

Migrator

Binary file to help you manage migrations into your DB.

Features

  • Create migration with custom name: ./migrate create -n file_name
  • Migrate up your migrations: ./migrate up
  • Migrate down your migrations: ./migrate down
  • Refresh all migrations: ./migrate fresh
  • Clean all you DB: ./migrate wipe
  • Migrations Version: ./migrate db:version
  • App Version: ./migrate version

Build

./build.sh

Examples

$ ./migrate --help
$ ./migrate version
$ ./migrate create -n file_name
$ ./migrate create --name='create users table'
$ ./migrate up
$
$ MIGRATION_DIR=./custom ./migrate up 
DB_HOST=pg DB_PORT=5434 DB_USER=fureev DB_NAME=test MIGRATION_DIR=./migrations migrate 

Docker

Without config file

docker run -v /Volumes/Docker/project/migrations:/migrations \
  -e DB_USER=fureev \
  -e DB_NAME=testdb \
  --network host \
  feugene/db-migrator create -n 'create user table'
docker run -v /Volumes/Docker/project/migrations:/migrations \
  -e DB_USER=fureev \
  -e DB_PASS=pass \
  -e DB_PORT=5435 \
  -e DB_NAME=testdb \
  --network host \
  feugene/db-migrator status

With config file

docker run -v /Volumes/Docker/project/migrations:/migrations \
  -v /Volumes/Docker/data/kb/migrator/config.test.yaml:/app/config.yaml \
  --network host \
  feugene/db-migrator status

or define config file:

docker run --network host \
  -v /Volumes/Docker/project/migrations:/migrations \
  -v /Volumes/Docker/data/kb/migrator/config.test.yaml:/app/config.yaml \
  feugene/db-migrator -f /app/config.yaml status

Where config file:

[migrations]
path = "/migrations"

[database]
user = "fureev"
password = ""
host = "localhost"
port = 5432
name = "testing"

More examples:

docker run -v /Volumes/Docker/data/kb/migrations:/migrations -e DB_USER:fureev --network host feugene/db-migrator status
docker run -v /Volumes/Docker/data/kb/migrations:/migrations -v /Volumes/Docker/data/kb/migrator/config.test.yaml:/app/config.yaml --network host feugene/db-migrator up

# Packages

No description provided by the author