Skip to content

Commit

Permalink
retun MigrateTool errors instead of logging them
Browse files Browse the repository at this point in the history
  • Loading branch information
jmezo committed Jul 10, 2024
1 parent 9d0c6d8 commit 37df4fc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 37df4fc

Please sign in to comment.