try again to fix lastupdated
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:
@@ -329,6 +329,8 @@ func CreateTables() {
|
|||||||
);
|
);
|
||||||
INSERT INTO secrets SELECT SecretId, RoleId, SafeId, DeviceName, DeviceCategory, UserName, Secret FROM _secrets_old;
|
INSERT INTO secrets SELECT SecretId, RoleId, SafeId, DeviceName, DeviceCategory, UserName, Secret FROM _secrets_old;
|
||||||
ALTER TABLE secrets DROP COLUMN RoleId;
|
ALTER TABLE secrets DROP COLUMN RoleId;
|
||||||
|
ALTER TABLE secrets ADD COLUMN LastUpdated datetime;
|
||||||
|
UPDATE secrets SET LastUpdated = (datetime('1970-01-01 00:00:00')) WHERE LastUpdated is null;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
PRAGMA foreign_keys=on;
|
PRAGMA foreign_keys=on;
|
||||||
DROP TABLE _secrets_old;
|
DROP TABLE _secrets_old;
|
||||||
@@ -384,11 +386,17 @@ func CreateTables() {
|
|||||||
secretsLastUpdatedCheck, _ := CheckColumnExists("secrets", "LastUpdated")
|
secretsLastUpdatedCheck, _ := CheckColumnExists("secrets", "LastUpdated")
|
||||||
if !secretsLastUpdatedCheck {
|
if !secretsLastUpdatedCheck {
|
||||||
// Add the column for LastUpdated in the secrets table
|
// Add the column for LastUpdated in the secrets table
|
||||||
_, err := db.Exec("ALTER TABLE secrets ADD COLUMN LastUpdated datetime DEFAULT (datetime('1970-01-01 00:00:00'));")
|
_, err := db.Exec("ALTER TABLE secrets ADD COLUMN LastUpdated datetime;")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error altering secrets table to add LastUpdated column : '%s'\n", err)
|
log.Printf("Error altering secrets table to add LastUpdated column : '%s'\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the default value
|
||||||
|
if _, err = db.Exec("UPDATE secrets SET LastUpdated = (datetime('1970-01-01 00:00:00')) WHERE LastUpdated is null;"); err != nil {
|
||||||
|
log.Printf("Error setting LastUpdated of existing secrets : '%s'", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user