Skip to content

A migrator command built on top of Gormigrate using GORM for migration files built as Go's plugin.

License

Notifications You must be signed in to change notification settings

grauwoelfchen/gormless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gormless

A migrator command built on top of Gormigrate using GORM for migration files built as Go's plugin.

Inspired by diesel-cli, but for GORM.

Repository

https://gitlab.com/grauwoelfchen/gormless

Install

# see build section for tags
% go get -tags=<TAG> gitlab.com/grauwoelfchen/gormless/cmd/gormless

See examples.

Build

% go build -tags="mssql"
% go build -tags="mysql"
% go build -tags="postgres"
% go build -tags="sqlite"

Usage

At first, you need to create migration files as Go's plugins.

% cat migration/20190404_create_users/up.go
package main

import "github.com/jinzhu/gorm"

// Up ...
func Up(tx *gorm.DB) error {
  ...
}

See gormigrate.
And build them as a plugin.

% cd ./migration/20190404_create_users/
% ls
down.go up.go
% go build -buildmode=plugin

Gormless recognize that .so plugins.

Examples

[env variables] gormless <action> [<option>]

The action must be one of commit, migrate, revert, rollback or version.
Using a flag -migration-directory or through an environment variable MIGRATION_DIRECTORY=..., you can set path to the directory contains your migration files. The flag has higher priority than the environment variable.
DATABASE_URL=... Should be started with mssql://, mysql://, postgres:// or sqlite://. Default is :memory: (sqlite).

It looks like so:

% DATABASE_URL=... gormless commit
% DATABASE_URL=... gormless revert

See gormless -h about details.

About

A migrator command built on top of Gormigrate using GORM for migration files built as Go's plugin.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published