DavidHuie / gomigrate

A SQL database migration toolkit in Golang
MIT License
162 stars 27 forks source link

Create database not suported? #16

Open ThomasAlxDmy opened 8 years ago

ThomasAlxDmy commented 8 years ago

Hi there,

I'm trying this package for the first time and I can't make it work.

2016/01/21 18:38:15 Migrations table not found
2016/01/21 18:38:15 Error creating migrations table: Error 1046: No database selected
if db, err := sql.Open("mysql", *mysqlUser+":"+*mysqlPassword+"@tcp("+*mysqlIp+":"+*mysqlPort+")/")
err != nil {
        log.Fatal(err)
    }

migrator, err := gomigrate.NewMigrator(db, gomigrate.Mysql{}, "./migrations")
migrator.CreateMigrationsTable()

Am I doing something wrong or creating a database is not supported?

mikeatlas commented 8 years ago

You probably can pass the database name as part of the sql.Open string after the / symbol.