Skip to content

Commit

Permalink
use common state.DB interface
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverpool committed Oct 10, 2023
1 parent 8ebcb11 commit c445b82
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/pressly/goose/v3/internal/sqlparser"
"github.com/pressly/goose/v3/internal/state"
)

// MigrationRecord struct.
Expand Down Expand Up @@ -165,7 +166,7 @@ func runGoMigrationNoTx(
}
}
if recordVersion {
return insertOrDeleteVersionNoTx(ctx, db, version, direction)
return insertOrDeleteVersion(ctx, db, version, direction)
}
return nil
}
Expand Down Expand Up @@ -204,14 +205,7 @@ func runGoMigration(
return nil
}

func insertOrDeleteVersion(ctx context.Context, tx *sql.Tx, version int64, direction bool) error {
if direction {
return globalStorage().InsertVersion(ctx, tx, version)
}
return globalStorage().DeleteVersion(ctx, tx, version)
}

func insertOrDeleteVersionNoTx(ctx context.Context, db *sql.DB, version int64, direction bool) error {
func insertOrDeleteVersion(ctx context.Context, db state.DB, version int64, direction bool) error {
if direction {
return globalStorage().InsertVersion(ctx, db, version)
}
Expand Down

0 comments on commit c445b82

Please sign in to comment.