Skip to content

Commit

Permalink
Merge pull request #19 from jmezo/migrate-with-error
Browse files Browse the repository at this point in the history
Migration returning errors
  • Loading branch information
PumpkinSeed authored Jul 10, 2024
2 parents 9d0c6d8 + 37df4fc commit be83c82
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 be83c82

Please sign in to comment.