Skip to content

Commit 91d0f8e

Browse files
authored
Add schema_version to output of db info command (#2309)
1 parent 60e8cc9 commit 91d0f8e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/juno/dbcmd.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/NethermindEth/juno/core/felt"
1111
"github.com/NethermindEth/juno/db"
1212
"github.com/NethermindEth/juno/db/pebble"
13+
"github.com/NethermindEth/juno/migration"
1314
"github.com/NethermindEth/juno/utils"
1415
"github.com/olekukonko/tablewriter"
1516
"github.com/spf13/cobra"
@@ -21,6 +22,7 @@ const (
2122

2223
type DBInfo struct {
2324
Network string `json:"network"`
25+
SchemaVersion uint64 `json:"schema_version"`
2426
ChainHeight uint64 `json:"chain_height"`
2527
LatestBlockHash *felt.Felt `json:"latest_block_hash"`
2628
LatestStateRoot *felt.Felt `json:"latest_state_root"`
@@ -84,7 +86,7 @@ func dbInfo(cmd *cobra.Command, args []string) error {
8486
defer database.Close()
8587

8688
chain := blockchain.New(database, nil)
87-
info := DBInfo{}
89+
var info DBInfo
8890

8991
// Get the latest block information
9092
headBlock, err := chain.Head()
@@ -97,6 +99,12 @@ func dbInfo(cmd *cobra.Command, args []string) error {
9799
return fmt.Errorf("failed to get the state update: %v", err)
98100
}
99101

102+
schemaMeta, err := migration.SchemaMetadata(database)
103+
if err != nil {
104+
return fmt.Errorf("failed to get schema metadata: %v", err)
105+
}
106+
107+
info.SchemaVersion = schemaMeta.Version
100108
info.Network = getNetwork(headBlock, stateUpdate.StateDiff)
101109
info.ChainHeight = headBlock.Number
102110
info.LatestBlockHash = headBlock.Hash

0 commit comments

Comments
 (0)