-
Notifications
You must be signed in to change notification settings - Fork 1
/
bash.go
45 lines (34 loc) · 897 Bytes
/
bash.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Package bash implements the Driver interface.
package bash
import (
"os/exec"
"github.com/db-journey/migrate/v2/driver"
"github.com/db-journey/migrate/v2/file"
)
var fileTemplate = []byte(``)
func init() {
driver.Register("bash", "sh", fileTemplate, Open)
}
type Driver struct {
}
func Open(url string) (driver.Driver, error) {
return &Driver{}, nil
}
func (driver *Driver) Close() error {
return nil
}
func (driver *Driver) Migrate(f file.File) error {
return nil
}
// Version returns the current migration version.
func (driver *Driver) Version() (file.Version, error) {
return file.Version(0), nil
}
// Versions returns the list of applied migrations.
func (driver *Driver) Versions() (file.Versions, error) {
return file.Versions{0}, nil
}
// Execute shell script
func (driver *Driver) Execute(commands string) error {
return exec.Command("sh", "-c", commands).Run()
}