compile and update migration package

This commit is contained in:
c9s 2021-02-17 17:35:11 +08:00
parent 9723c7373a
commit 88f7f0f61c
2 changed files with 22 additions and 4 deletions

View File

@ -1,15 +1,24 @@
package mysql package mysql
import ( import (
"github.com/c9s/rockhopper"
"fmt" "fmt"
"runtime" "runtime"
"strings" "strings"
"github.com/c9s/rockhopper"
) )
var registeredGoMigrations map[int64]*rockhopper.Migration var registeredGoMigrations map[int64]*rockhopper.Migration
func Migrations() rockhopper.MigrationSlice {
var migrations = rockhopper.MigrationSlice{}
for _, migration := range registeredGoMigrations {
migrations = append(migrations, migration)
}
return migrations.SortAndConnect()
}
// AddMigration adds a migration. // AddMigration adds a migration.
func AddMigration(up, down rockhopper.TransactionHandler) { func AddMigration(up, down rockhopper.TransactionHandler) {
pc, filename, _, _ := runtime.Caller(1) pc, filename, _, _ := runtime.Caller(1)

View File

@ -1,15 +1,24 @@
package sqlite3 package sqlite3
import ( import (
"github.com/c9s/rockhopper"
"fmt" "fmt"
"runtime" "runtime"
"strings" "strings"
"github.com/c9s/rockhopper"
) )
var registeredGoMigrations map[int64]*rockhopper.Migration var registeredGoMigrations map[int64]*rockhopper.Migration
func Migrations() rockhopper.MigrationSlice {
var migrations = rockhopper.MigrationSlice{}
for _, migration := range registeredGoMigrations {
migrations = append(migrations, migration)
}
return migrations.SortAndConnect()
}
// AddMigration adds a migration. // AddMigration adds a migration.
func AddMigration(up, down rockhopper.TransactionHandler) { func AddMigration(up, down rockhopper.TransactionHandler) {
pc, filename, _, _ := runtime.Caller(1) pc, filename, _, _ := runtime.Caller(1)