migration

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: MIT Imports: 6 Imported by: 2

README

migration

Usage

Create a new migration
package main

import (
	"github.com/dnnyjns/migration"
)

func main() {
  migration.Create("first_migration")
}
Run migrations
package main

import (
	_ "github.com/username/repo/migrations"
	"github.com/dnnyjns/migration"
)

func main() {
  db := setupDB()
  defer db.Close()
  migration.Run(db)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Dir = "./migrations"
)

Functions

func Add

func Add(m *Migration)

func Create

func Create(dir, name string)

func CreateDefault added in v0.1.2

func CreateDefault(name string)

func IsComplete added in v0.1.3

func IsComplete(db *gorm.DB) bool

func Migrate

func Migrate(db *gorm.DB) error

Types

type Migration

type Migration struct {
	DisableDDL bool      `gorm:"-"`
	Perform    performFn `gorm:"-"`
	Version    string    `gorm:"size:255;PRIMARY_KEY;NOT NULL"`
}

func (Migration) Migrate

func (m Migration) Migrate(db *gorm.DB)

Jump to

Keyboard shortcuts

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