You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/cronosd/cmd/patch_db.go
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@ package cmd
2
2
3
3
import (
4
4
"fmt"
5
+
"os"
5
6
"path/filepath"
6
7
"strings"
7
8
"time"
@@ -241,6 +242,14 @@ Examples:
241
242
returnfmt.Errorf("--target-path must reference a *.db directory (got %q)", dbTargetPath)
242
243
}
243
244
245
+
// Verify target database exists
246
+
if_, err:=os.Stat(cleanTargetPath); err!=nil {
247
+
ifos.IsNotExist(err) {
248
+
returnfmt.Errorf("target database does not exist: %s (the target database must already exist before patching; use the migrate command to create a new database)", cleanTargetPath)
249
+
}
250
+
returnfmt.Errorf("failed to access target database: %w", err)
// targetPathError is a helper type to simulate the error from patch_db.go
87
142
typetargetPathErrorstruct {
88
143
pathstring
@@ -91,3 +146,12 @@ type targetPathError struct {
91
146
func (e*targetPathError) Error() string {
92
147
return"when patching multiple databases, --target-path must be a data directory (e.g., ~/.cronos/data), not a *.db file path (got \""+e.path+"\"); remove the .db suffix"
93
148
}
149
+
150
+
// targetExistenceError is a helper type to simulate the existence error from patch_db.go
151
+
typetargetExistenceErrorstruct {
152
+
pathstring
153
+
}
154
+
155
+
func (e*targetExistenceError) Error() string {
156
+
return"target database does not exist: "+e.path+" (the target database must already exist before patching; use the migrate command to create a new database)"
0 commit comments