pass db connection to go migration script

Open
#54 · Created  · Last updated

Description

... so that other libraries (such as https://github.com/jinzhu/gorm) can reuse the db connection.

For example:

func Up_20160221232922(txn *sql.Tx, db *sql.DB) { gdb, _ := gorm.Open("postgres", db) gdb.CreateTable(&models.User{}) } func Down_20160221232922(txn *sql.Tx, db *sql.DB) { gdb, _ := gorm.Open("postgres", db) gdb.DropTable(&models.User{}) }

0 attachments

0 comments

Loading commits...