Skip to content

Commit

Permalink
reset command to remove migration directory and genesis state files
Browse files Browse the repository at this point in the history
  • Loading branch information
charithabandi committed Dec 17, 2024
1 parent e935637 commit e69a533
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/node/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ func restoreDB(d *coreDependencies) bool {
}

// Snapshot file exists
snapFile, err := os.Open(appCfg.GenesisState)
genFileName, err := node.ExpandPath(appCfg.GenesisState)
if err != nil {
failBuild(err, "failed to expand genesis state path")
}

snapFile, err := os.Open(genFileName)
if err != nil {
failBuild(err, "failed to open genesis state file")
}
Expand Down
12 changes: 12 additions & 0 deletions app/setup/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ func ResetCmd() *cobra.Command {
return err
}
fmt.Println("Snapshots directory removed", snapDir)

// remove the migrations directory
migrationsDir := filepath.Join(rootDir, "migrations")
if err := os.RemoveAll(migrationsDir); err != nil {
return err
}
fmt.Println("Migrations directory removed", migrationsDir)

// remove genesis state file if exists
genesisFile := filepath.Join(rootDir, "genesis-state.sql.gz")
os.Remove(genesisFile) // ignore error
fmt.Println("Genesis state file removed", genesisFile)
}

return nil
Expand Down

0 comments on commit e69a533

Please sign in to comment.