Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,24 @@ var cmdRunMigrations = &cobra.Command{
Short: "",
Run: func(cmd *cobra.Command, args []string) {
logger := debug.SetupCobra(cmd, "integration")
dbPaths := map[kv.Label]string{kv.ChainDB: chaindata}
migrateDB := func(label kv.Label, path string) {
logger.Info("Opening DB", "label", label, "path", path)
// Non-accede and exclusive mode - to apply creation of new tables if needed.
cfg := dbCfg(label, path).RemoveFlags(mdbx.Accede).Exclusive(true)
db, err := openDB(cfg, true, logger)
if err != nil {
logger.Error("Opening DB", "error", err)
return
}
defer db.Close()
// Nothing to do, migrations will be applied automatically
}

// Chaindata DB *must* be the first one because guaranteed to contain data in Config table
// (see openSnapshotOnce in allSnapshots below).
migrateDB(kv.ChainDB, chaindata)

dbPaths := map[kv.Label]string{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • if chaindata must be first - then just don't use map use array.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, this can be simplified. neither a map nor an array is needed: I'll just call migrateDB instead of filling a useless data structure

// Migrations must be applied also to the consensus DB because ConsensusTables contain also ChaindataTables
// (see kv/tables.go).
consensus := strings.Replace(chaindata, "chaindata", "aura", 1)
Expand All @@ -436,15 +453,7 @@ var cmdRunMigrations = &cobra.Command{
dbPaths[kv.PolygonBridgeDB] = polygonBridge
}
for dbLabel, dbPath := range dbPaths {
//non-accede and exclusive mode - to apply create new tables if need.
cfg := dbCfg(dbLabel, dbPath).RemoveFlags(mdbx.Accede).Exclusive(true)
db, err := openDB(cfg, true, logger)
if err != nil {
logger.Error("Opening DB", "error", err)
return
}
defer db.Close()
// Nothing to do, migrations will be applied automatically
migrateDB(dbLabel, dbPath)
}
},
}
Expand Down
Loading