handle existing secrets with no safe id
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -180,6 +180,20 @@ func CreateTables() {
|
||||
log.Printf("Error checking safes table : '%s'", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
// Create an initial safe
|
||||
rowCount, _ = CheckCount("safes")
|
||||
if rowCount == 0 {
|
||||
if _, err = db.Exec("INSERT INTO safes VALUES(1, 'Default Safe');"); err != nil {
|
||||
log.Printf("Error adding initial safe entry : '%s'", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Set any unassigned secrets to the default safe id
|
||||
if _, err = db.Exec("UPDATE secrets SET SafeId = REPLACE(SafeId,'NULL','1');"); err != nil {
|
||||
log.Printf("Error setting safe ID of existing secrets : '%s'", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Secrets table
|
||||
if _, err = db.Exec(createSecrets); err != nil {
|
||||
|
Reference in New Issue
Block a user