From 88f7f0f61cec14268e06858fe621a37caaf11da2 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 17 Feb 2021 17:35:11 +0800 Subject: [PATCH] compile and update migration package --- pkg/migrations/mysql/migration_api.go | 13 +++++++++++-- pkg/migrations/sqlite3/migration_api.go | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pkg/migrations/mysql/migration_api.go b/pkg/migrations/mysql/migration_api.go index b4cbebc2b..95753ff3f 100644 --- a/pkg/migrations/mysql/migration_api.go +++ b/pkg/migrations/mysql/migration_api.go @@ -1,15 +1,24 @@ package mysql import ( - "github.com/c9s/rockhopper" - "fmt" "runtime" "strings" + + "github.com/c9s/rockhopper" ) 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. func AddMigration(up, down rockhopper.TransactionHandler) { pc, filename, _, _ := runtime.Caller(1) diff --git a/pkg/migrations/sqlite3/migration_api.go b/pkg/migrations/sqlite3/migration_api.go index 8b874a63d..388f397f1 100644 --- a/pkg/migrations/sqlite3/migration_api.go +++ b/pkg/migrations/sqlite3/migration_api.go @@ -1,15 +1,24 @@ package sqlite3 import ( - "github.com/c9s/rockhopper" - "fmt" "runtime" "strings" + + "github.com/c9s/rockhopper" ) 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. func AddMigration(up, down rockhopper.TransactionHandler) { pc, filename, _, _ := runtime.Caller(1)