feat: initial commit
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
This commit is contained in:
30
internal/migrate/migrate.go
Normal file
30
internal/migrate/migrate.go
Normal file
@ -0,0 +1,30 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user