emissary/internal/migrate/migrate.go
William Petit 765257b4b1
Some checks reported errors
arcad/emissary/pipeline/head Something is wrong with the build of this commit
feat(datastore): add basic testsuite for agent repository
2023-04-12 11:09:53 +02:00

31 lines
629 B
Go

package migrate
import (
"fmt"
"github.com/golang-migrate/migrate/v4"
_ "github.com/golang-migrate/migrate/v4/database/postgres"
_ "github.com/golang-migrate/migrate/v4/database/sqlite"
_ "github.com/golang-migrate/migrate/v4/source/file"
"github.com/pkg/errors"
)
type Migrate = migrate.Migrate
var (
ErrNilVersion = migrate.ErrNilVersion
ErrNoChange = migrate.ErrNoChange
)
func New(migrationDir, driver, dsn string) (*migrate.Migrate, error) {
migr, err := migrate.New(
fmt.Sprintf("file://%s/%s", migrationDir, driver),
dsn,
)
if err != nil {
return nil, errors.WithStack(err)
}
return migr, nil
}