mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
drop the legacy upgradeDB
This commit is contained in:
parent
ecf94cdeea
commit
276b6c1e48
|
@ -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
|
||||
}
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
driver: mysql
|
||||
dialect: mysql
|
||||
dsn: "root@tcp(localhost:3306)/bbgo?parseTime=true"
|
||||
migrationsDir: migrations
|
||||
migrationsDir: migrations/mysql
|
||||
|
|
Loading…
Reference in New Issue
Block a user