func (g *MigrationGenerator) Build(pkgs ...*Package) (*Migration, error) {
	old, err := g.LoadLock()
	if err != nil {
		return nil, err
	}
	new, err := SchemaFromPackages(pkgs...)
	if err != nil {
		return nil, err
	}
	return NewMigration(old, new)
}
Build creates a new migration from a set of scanned packages.
package generator  
import (
	"bytes"
	"encoding"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"runtime/debug"
	"strings"
	"time"
	"github.com/fatih/color"
)
type Generator struct {
	filename string
}
func NewGenerator(filename string) *Generator {
	return &Generator{filename}
}
func (g *Generator) Generate(pkg *Package) error {
	return g.writeFile(pkg)
}
func (g *Generator) writeFile(pkg *Package) (err error) {
	file, err := os.Create(g.filename)
	if err != nil {
		return err
	}
	defer func() {
		if r := recover(); r != nil {
			fmt.Printf("kallax: PANIC during '%s' generation:\n%s\n\n", g.filename, r)
			if err == nil {
				err = fmt.Errorf(string(debug.Stack()))
			}
		}
		file.Close()
		if err != nil {
			if os.Remove(g.filename) == nil {
				fmt.Println("kallax: No file generated due to an occurred error:")
			} else {
				fmt.Printf("kallax: The autogenerated file '%s' could not be completed nor deleted due to an occurred error:\n", g.filename)
			}
		}
	}()
	return Base.Execute(file, pkg)
}
type Timestamper func() time.Time
type MigrationGenerator struct {
	name string
	dir  string
	now  Timestamper
}
type migrationFileType string
const (
	migrationUp   = migrationFileType("up.sql")
	migrationDown = migrationFileType("down.sql")
	migrationLock = migrationFileType("lock.json")
)
func NewMigrationGenerator(name, dir string) *MigrationGenerator {
	return &MigrationGenerator{slugify(name), dir, time.Now}
}