Skip to content

Atrox/go-migrate-rice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rice Source Driver for golang-migrate/migrate

Installation

go get github.com/atrox/go-migrate-rice

Example

import (
	rice "github.com/GeertJohan/go.rice"
	migraterice "github.com/atrox/go-migrate-rice"
	"github.com/golang-migrate/migrate/v4"
	"github.com/golang-migrate/migrate/v4/database/postgres"
)

// get rice box
migrationsBox := rice.MustFindBox("migrations")

// create source driver with specified rice box
sourceDriver, _ := migraterice.WithInstance(migrationsBox)

// create database driver
dbDriver, _ := postgres.WithInstance(openDatabase(), &postgres.Config{})

// create migration instance
m, _ := migrate.NewWithInstance("rice", sourceDriver, "postgres", dbDriver)

// migrate
m.Up()