Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sql-migrate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io/ioutil"
"os"
"runtime/debug"

"github.com/go-gorp/gorp/v3"
migrate "github.com/rubenv/sql-migrate"
Expand Down Expand Up @@ -103,3 +104,11 @@ func GetConnection(env *Environment) (*sql.DB, string, error) {

return db, env.Dialect, nil
}

// GetVersion returns the version.
func GetVersion() string {
if buildInfo, ok := debug.ReadBuildInfo(); ok && buildInfo.Main.Version != "(devel)" {
return buildInfo.Main.Version
}
return "dev"
}
2 changes: 1 addition & 1 deletion sql-migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func realMain() int {
},
},
HelpFunc: cli.BasicHelpFunc("sql-migrate"),
Version: "1.0.0",
Version: GetVersion(),
}

exitCode, err := cli.Run()
Expand Down