Commits

Liam Staskawicz  committed 3c6b6c3

use filepath rather than path to ensure we're dealing with filenames in an OS compatible way. fixes #2.

  • Participants
  • Parent commits 003f86c

Comments (0)

Files changed (5)

File cmd_create.go

 	"fmt"
 	"log"
 	"os"
-	"path"
 	"path/filepath"
 	"text/template"
 	"time"
 	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" {

File cmd_status.go

 	"database/sql"
 	"fmt"
 	"log"
-	"path"
+	"path/filepath"
 	"time"
 )
 
 	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))
 	}
 }
 
 	"github.com/bmizerany/pq"
 	"github.com/kylelemons/go-gypsy/yaml"
 	"os"
-	"path"
+	"path/filepath"
 )
 
 // global options. available to any subcommands.
 // 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 {
 	}
 
 	return &DBConf{
-		MigrationsDir: path.Join(*dbPath, "migrations"),
+		MigrationsDir: filepath.Join(*dbPath, "migrations"),
 		Env:           *dbEnv,
 		Driver:        drv,
 		OpenStr:       open,
 	_ "github.com/ziutek/mymysql/godrv"
 	"log"
 	"os"
-	"path"
 	"path/filepath"
 	"sort"
 	"strconv"
 
 		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":
 			log.Fatalf("FAIL %v, quitting migration", e)
 		}
 
-		fmt.Println("OK   ", path.Base(m.Source))
+		fmt.Println("OK   ", filepath.Base(m.Source))
 	}
 }
 
 			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))
 				}
 			}
 
 // 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")
 	}
 

File migration_sql.go

 	"fmt"
 	"io/ioutil"
 	"log"
-	"path"
+	"path/filepath"
 	"strings"
 )
 
 
 		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