Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 86ec0be

Browse files
authored
Merge pull request #2063 from OpenBazaar/brian.migrationerror
Potential fix for migration failures
2 parents 2791875 + 93f59a4 commit 86ec0be

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

repo/migrations/Migration028.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,20 @@ func (migrateListingsToV5Schema) Up(repoPath, databasePassword string, testnetEn
258258
Indent: " ",
259259
}
260260

261-
var oldListingIndex []MigrateListingsToV5Schema_V4ListingIndexData
261+
var listingIndex []MigrateListingsToV5Schema_V5ListingIndexData
262262
listingsJSON, err := ioutil.ReadFile(listingsFilePath)
263263
if err != nil {
264264
return err
265265
}
266+
if err = json.Unmarshal(listingsJSON, &listingIndex); err == nil {
267+
return writeRepoVer(repoPath, 28)
268+
}
269+
270+
var oldListingIndex []MigrateListingsToV5Schema_V4ListingIndexData
271+
listingsJSON, err = ioutil.ReadFile(listingsFilePath)
272+
if err != nil {
273+
return err
274+
}
266275
if err = json.Unmarshal(listingsJSON, &oldListingIndex); err != nil {
267276
return err
268277
}

repo/migrations/Migration033.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ func (Migration033) Up(repoPath, databasePassword string, testnetEnabled bool) e
6868
return err
6969
}
7070
if _, err = tx.Exec(upSequence); err != nil {
71+
if err.Error() == "duplicate column name: err" {
72+
err = writeRepoVer(repoPath, migrationCreateMessagesAM09UpVer)
73+
if err != nil {
74+
return err
75+
}
76+
return nil
77+
}
7178
if rErr := tx.Rollback(); rErr != nil {
7279
return fmt.Errorf("rollback failed: (%s) due to (%s)", rErr.Error(), err.Error())
7380
}

0 commit comments

Comments
 (0)