drop the legacy upgradeDB

This commit is contained in:
c9s 2021-02-06 09:52:53 +08:00
parent ecf94cdeea
commit 276b6c1e48
2 changed files with 1 additions and 30 deletions

View File

@ -1,13 +1,9 @@
package bbgo
import (
"context"
"database/sql"
// register the go migrations
_ "github.com/c9s/bbgo/pkg/migrations"
"github.com/c9s/rockhopper"
"github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
)
@ -23,28 +19,3 @@ func ConnectMySQL(dsn string) (*sqlx.DB, error) {
return sqlx.Connect("mysql", dsn)
}
func upgradeDB(ctx context.Context, driver string, db *sql.DB) error {
dialect, err := rockhopper.LoadDialect(driver)
if err != nil {
return err
}
loader := &rockhopper.GoMigrationLoader{}
migrations, err := loader.Load()
if err != nil {
return err
}
rh := rockhopper.New(driver, dialect, db)
currentVersion, err := rh.CurrentVersion()
if err != nil {
return err
}
if err := rockhopper.Up(ctx, rh, migrations, currentVersion, 0); err != nil {
return err
}
return nil
}

View File

@ -2,4 +2,4 @@
driver: mysql
dialect: mysql
dsn: "root@tcp(localhost:3306)/bbgo?parseTime=true"
migrationsDir: migrations
migrationsDir: migrations/mysql