From 37df4fccec5130aa82b7de19ba17fed43a6e7f78 Mon Sep 17 00:00:00 2001 From: jano Date: Wed, 10 Jul 2024 15:29:53 +0200 Subject: [PATCH] retun MigrateTool errors instead of logging them --- migration/migration.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/migration/migration.go b/migration/migration.go index 2059b17..db3b838 100644 --- a/migration/migration.go +++ b/migration/migration.go @@ -100,6 +100,23 @@ func MigrationTool(conn string, down bool, opts Opts, embeds ...embed.FS) { log.Info(ctx, "migration succeed") } +func MigrationToolWithError(conn string, down bool, opts Opts, embeds ...embed.FS) error { + ctx := context.Background() + m, err := Get(ctx, conn, opts, embeds...) + if err != nil { + return err + } + if m == nil { + return errors.New("migration is nil") + } + if down { + err = m.Down() + } else { + err = m.Up() + } + return err +} + func PrepareCockroach(conn string) string { return strings.Replace(conn, "postgres://", "cockroach://", 1) }