Skip to content

GoLang module for creating database migrations.

License

Notifications You must be signed in to change notification settings

silverark/go-migrations

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Module for the creating migrations for GoLang applications.

Now only for MySQL and Postgres!

Install

    go get github.com/ShkrutDenis/go-migrations

for update use flag -u:

    go get -u github.com/ShkrutDenis/go-migrations

Usage

Run this command for put to your project the template for usage go-migrations:

    bash $GOPATH/github.com/ShkrutDenis/go-migrations/init.sh
    or if you use vendor folder
    bash vendor/github.com/ShkrutDenis/go-migrations/init.sh

Or you can copy sources from your dependencies path manually if you have trouble with command. For example from:

    .../github.com/ShkrutDenis/go-migrations/template

In migrations/list directory create your migrations like existed example

In migrations/entry.go in getMigrationsList() method put your migrations structures

For migrate:

    go run migrations/entry.go

If you want to rollback, add --rollback flag.

Environment variables

Module uses next variables for creating a connection with DB:

  • DB_DRIVER
  • DB_USER
  • DB_PASSWORD
  • DB_HOST
  • DB_PORT
  • DB_NAME

if DB_HOST and DB_PORT doesn’t exist, will be used a DB_CONNECTION with next format: host:port

By default, module load env file from the current directory with name .env. For use custom env file you can use next flags: --env-path and --env-file

Documentation

You can found documentation here.

Examples

You can found few examples with create migrations here.

License

Licensed under MIT License

About

GoLang module for creating database migrations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.3%
  • Shell 0.7%