chore: update migrator

This commit is contained in:
steven
2023-09-29 12:47:49 +08:00
parent 87ddeb2c79
commit 8168fb71a8
5 changed files with 136 additions and 168 deletions

View File

@ -3,6 +3,7 @@ package mysql
import (
"context"
"database/sql"
"fmt"
"github.com/pkg/errors"
@ -16,7 +17,10 @@ type Driver struct {
}
func NewDriver(profile *profile.Profile) (store.Driver, error) {
db, err := sql.Open("mysql", profile.DSN)
// Open MySQL connection with parameter.
// multiStatements=true is required for migration.
// See more in: https://github.com/go-sql-driver/mysql#multistatements
db, err := sql.Open("mysql", fmt.Sprintf("%s?multiStatements=true", profile.DSN))
if err != nil {
return nil, errors.Wrapf(err, "failed to open db: %s", profile.DSN)
}