gormless

module
v0.0.0-...-4812b8a Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2019 License: MIT

README

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.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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