Skip to content

Commit

Permalink
replace use of pq package with go-sqlite3 package in the generated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
aphss committed Mar 12, 2013
1 parent 3a83f64 commit c1dca10
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions migration_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,37 +75,33 @@ var goMigrationTmpl = template.Must(template.New("driver").Parse(`
package main
import (
"database/sql"
_ "github.com/bmizerany/pq"
"log"
"fmt"
"database/sql"
"log"
"fmt"
_ "github.com/mattn/go-sqlite3"
)
func main() {
db, err := sql.Open("{{.DBDriver}}", "{{.DBOpen}}")
if err != nil {
log.Fatal("failed to open DB:", err)
}
defer db.Close()
txn, err := db.Begin()
if err != nil {
log.Fatal("db.Begin:", err)
}
{{ .Func }}(txn)
// XXX: drop goose_db_version table on some minimum version number?
versionFmt := "INSERT INTO goose_db_version (version_id, is_applied) VALUES (%v, %d);"
versionStmt := fmt.Sprintf(versionFmt, int64({{ .Version }}), {{ .Direction }})
if _, err = txn.Exec(versionStmt); err != nil {
txn.Rollback()
log.Fatal("failed to write version: ", err)
}
err = txn.Commit()
if err != nil {
log.Fatal("Commit() failed:", err)
}
db, err := sql.Open("{{.DBDriver}}", "{{.DBOpen}}")
if err != nil {
log.Fatal("failed to open DB:", err)
}
defer db.Close()
txn, err := db.Begin()
if err != nil {
log.Fatal("db.Begin:", err)
}
{{ .Func }}(txn)
// XXX: drop goose_db_version table on some minimum version number?
versionFmt := "INSERT INTO goose_db_version (version_id, is_applied) VALUES (%v, %d);"
versionStmt := fmt.Sprintf(versionFmt, int64({{ .Version }}), {{ .Direction }})
if _, err = txn.Exec(versionStmt); err != nil {
txn.Rollback()
log.Fatal("failed to write version: ", err)
}
err = txn.Commit()
if err != nil {
log.Fatal("Commit() failed:", err)
}
}
`))

0 comments on commit c1dca10

Please sign in to comment.