Skip to content

Could run dbmate migrations embedded in binary via fs.FS

Notifications You must be signed in to change notification settings

makasim/dbmateincode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dbmateincode

Migrate db using dbmate and embedded migrations.

Could be used as a workaround until dbmate fs.FS support added (see amacneil/dbmate#193).

Migrate

package main

import (
	"embed"
	"log"
	"net/url"

	"github.com/makasim/dbmateincode"

	_ "github.com/amacneil/dbmate/pkg/driver/postgres"
)

//go:embed sql/*.sql
var migrationDir embed.FS

func main() {
	dbUrl, err := url.Parse("postgres://postgres:dbpass@127.0.0.1:5432/test?sslmode=disable")
	if err != nil {
		log.Fatalln(err)
	}

	if err := dbmateincode.Migrate(dbmateincode.NewConfig(dbUrl, migrationDir)); err != nil {
		log.Fatalln(err)
	}
}

About

Could run dbmate migrations embedded in binary via fs.FS

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages