go_migrations

package module
v1.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 8 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run added in v1.2.0

func Run(migs []store.Migratable)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL