Skip to content

Commit

Permalink
fix linked list: clear the existing next/prev pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jan 25, 2024
1 parent 2473c62 commit 81b100a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,14 @@ func (ms MigrationSlice) Connect() MigrationSlice {

if i < len(ms)-1 {
m.Next = ms[i+1]
} else {
m.Next = nil
}

if i > 0 {
m.Previous = ms[i-1]
} else {
m.Previous = nil
}

ms[i] = m
Expand Down
2 changes: 1 addition & 1 deletion up.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Upgrade(ctx context.Context, db *DB, migrations MigrationSlice) error {
migrationMap := migrations.MapByPackage()
for _, pkgMigrations := range migrationMap {
pkgMigrations = pkgMigrations.Sort().Connect()

_, lastAppliedMigration, err := db.FindLastAppliedMigration(ctx, pkgMigrations)
if err != nil {
return err
Expand Down

0 comments on commit 81b100a

Please sign in to comment.