mirror of https://github.com/pressly/goose.git
39 lines
650 B
Go
39 lines
650 B
Go
package goose
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
)
|
|
|
|
func Run(command string, db *sql.DB, dir string) error {
|
|
switch command {
|
|
case "up":
|
|
if err := Up(db, dir); err != nil {
|
|
return err
|
|
}
|
|
case "up-by-one":
|
|
if err := UpByOne(db, dir); err != nil {
|
|
return err
|
|
}
|
|
case "down":
|
|
if err := Down(db, dir); err != nil {
|
|
return err
|
|
}
|
|
case "redo":
|
|
if err := Redo(db, dir); err != nil {
|
|
return err
|
|
}
|
|
case "status":
|
|
if err := Status(db, dir); err != nil {
|
|
return err
|
|
}
|
|
case "version":
|
|
if err := Version(db, dir); err != nil {
|
|
return err
|
|
}
|
|
default:
|
|
return fmt.Errorf("%q: no such command", command)
|
|
}
|
|
return nil
|
|
}
|