Skip to content

fiskeben/packr-source-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

packr-source-driver

Use gobuffalo/packr to bundle database migrations in the final binary and use them as a source to golang-migrate/migrate.

Usage

Here's a simple example of how to create a migrate instance with a packr based driver:

import (
	"fmt"
	packrdriver "github.com/fiskeben/packr-source-driver/driver"
	"github.com/gobuffalo/packr"
	"github.com/golang-migrate/migrate"
)

func makeMigrate(connection string) (*migrate.Migrate, error) {
	box := packr.NewBox("./path/to/migration/steps")
	driver, err := packrdriver.WithInstance(box)
	if err != nil {
		return nil, fmt.Errorf("failed to create migration data driver: %v", err)
	}

	return migrate.NewWithSourceInstance("packr", driver, connection)
}

Contribute

PRs are welcome.

About

Packr backed driver for golang-migrate

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages