diff --git a/cmd_create.go b/cmd_create.go index c6619fd..ad755d7 100644 --- a/cmd_create.go +++ b/cmd_create.go @@ -4,7 +4,6 @@ import ( "fmt" "log" "os" - "path" "path/filepath" "text/template" "time" @@ -42,7 +41,7 @@ func createRun(cmd *Command, args ...string) { if err != nil { log.Fatal(err) } - fpath := path.Join(conf.MigrationsDir, filename) + fpath := filepath.Join(conf.MigrationsDir, filename) var tmpl *template.Template if migrationType == "sql" { diff --git a/cmd_status.go b/cmd_status.go index 22d3c04..e30ec9d 100644 --- a/cmd_status.go +++ b/cmd_status.go @@ -4,7 +4,7 @@ import ( "database/sql" "fmt" "log" - "path" + "path/filepath" "time" ) @@ -50,7 +50,7 @@ func statusRun(cmd *Command, args ...string) { fmt.Println(" Applied At Migration") fmt.Println(" =======================================") for _, m := range mm.Migrations { - printMigrationStatus(db, m.Version, path.Base(m.Source)) + printMigrationStatus(db, m.Version, filepath.Base(m.Source)) } } diff --git a/dbconf.go b/dbconf.go index 66438a3..8294cd0 100644 --- a/dbconf.go +++ b/dbconf.go @@ -6,7 +6,7 @@ import ( "github.com/bmizerany/pq" "github.com/kylelemons/go-gypsy/yaml" "os" - "path" + "path/filepath" ) // global options. available to any subcommands. @@ -23,7 +23,7 @@ type DBConf struct { // extract configuration details from the given file func MakeDBConf() (*DBConf, error) { - cfgFile := path.Join(*dbPath, "dbconf.yml") + cfgFile := filepath.Join(*dbPath, "dbconf.yml") f, err := yaml.ReadFile(cfgFile) if err != nil { @@ -51,7 +51,7 @@ func MakeDBConf() (*DBConf, error) { } return &DBConf{ - MigrationsDir: path.Join(*dbPath, "migrations"), + MigrationsDir: filepath.Join(*dbPath, "migrations"), Env: *dbEnv, Driver: drv, OpenStr: open, diff --git a/migrate.go b/migrate.go index fcc93e1..ba87862 100644 --- a/migrate.go +++ b/migrate.go @@ -8,7 +8,6 @@ import ( _ "github.com/ziutek/mymysql/godrv" "log" "os" - "path" "path/filepath" "sort" "strconv" @@ -73,7 +72,7 @@ func runMigrations(conf *DBConf, migrationsDir string, target int64) { var e error - switch path.Ext(m.Source) { + switch filepath.Ext(m.Source) { case ".go": e = runGoMigration(conf, m.Source, m.Version, mm.Direction) case ".sql": @@ -84,7 +83,7 @@ func runMigrations(conf *DBConf, migrationsDir string, target int64) { log.Fatalf("FAIL %v, quitting migration", e) } - fmt.Println("OK ", path.Base(m.Source)) + fmt.Println("OK ", filepath.Base(m.Source)) } } @@ -104,7 +103,7 @@ func collectMigrations(dirpath string, current, target int64) (mm *MigrationMap, for _, m := range mm.Migrations { if v == m.Version { log.Fatalf("more than one file specifies the migration for version %d (%s and %s)", - v, m.Source, path.Join(dirpath, name)) + v, m.Source, filepath.Join(dirpath, name)) } } @@ -170,9 +169,9 @@ func (mm *MigrationMap) Sort(direction bool) { // and ext specifies the type of migration func numericComponent(name string) (int64, error) { - base := path.Base(name) + base := filepath.Base(name) - if ext := path.Ext(base); ext != ".go" && ext != ".sql" { + if ext := filepath.Ext(base); ext != ".go" && ext != ".sql" { return 0, errors.New("not a recognized migration file type") } diff --git a/migration_sql.go b/migration_sql.go index c80db22..11b90f3 100644 --- a/migration_sql.go +++ b/migration_sql.go @@ -5,7 +5,7 @@ import ( "fmt" "io/ioutil" "log" - "path" + "path/filepath" "strings" ) @@ -53,13 +53,13 @@ func runSQLMigration(db *sql.DB, script string, v int64, direction bool) error { if _, err = txn.Exec(query); err != nil { txn.Rollback() - log.Fatalf("FAIL %s (%v), quitting migration.", path.Base(script), err) + log.Fatalf("FAIL %s (%v), quitting migration.", filepath.Base(script), err) return err } } if err = finalizeMigration(txn, direction, v); err != nil { - log.Fatalf("error finalizing migration %s, quitting. (%v)", path.Base(script), err) + log.Fatalf("error finalizing migration %s, quitting. (%v)", filepath.Base(script), err) } return nil