diff --git a/src/libs/mysqlHandler.go b/src/libs/mysqlHandler.go index a1170179..79e96543 100644 --- a/src/libs/mysqlHandler.go +++ b/src/libs/mysqlHandler.go @@ -371,7 +371,6 @@ func insertSystemPolicy(cfg types.ConfigDB, db *sql.DB, policy types.KnoxSystemP return err } defer stmt.Close() - time := ConvertStrToUnixTime("now") specPointer := &policy.Spec spec, err := json.Marshal(specPointer) @@ -389,8 +388,8 @@ func insertSystemPolicy(cfg types.ConfigDB, db *sql.DB, policy types.KnoxSystemP policy.Metadata["status"], policy.Outdated, spec, - time, - time, + ConvertStrToUnixTime("now"), + ConvertStrToUnixTime("now"), true) if err != nil { return err @@ -536,8 +535,8 @@ func CreateTableSystemPolicyMySQL(cfg types.ConfigDB) error { " `status` varchar(10) DEFAULT NULL," + " `outdated` varchar(50) DEFAULT NULL," + " `spec` JSON DEFAULT NULL," + - " `generatedTime` bigint DEFAULT NULL," + - " `updatedTime` bigint DEFAULT NULL," + + " `generatedTime` bigint NOT NULL," + + " `updatedTime` bigint NOT NULL," + " `latest` BOOLEAN," + " PRIMARY KEY (`id`)" + " );" diff --git a/src/libs/sqliteHandler.go b/src/libs/sqliteHandler.go index 33b677ed..5d9f29ab 100644 --- a/src/libs/sqliteHandler.go +++ b/src/libs/sqliteHandler.go @@ -361,7 +361,6 @@ func insertSystemPolicySQLite(cfg types.ConfigDB, db *sql.DB, policy types.KnoxS return err } defer stmt.Close() - time := ConvertStrToUnixTime("now") specPointer := &policy.Spec spec, err := json.Marshal(specPointer) @@ -379,8 +378,8 @@ func insertSystemPolicySQLite(cfg types.ConfigDB, db *sql.DB, policy types.KnoxS policy.Metadata["status"], policy.Outdated, spec, - time, - time, + ConvertStrToUnixTime("now"), + ConvertStrToUnixTime("now"), true) if err != nil { return err @@ -514,8 +513,8 @@ func CreateTableSystemPolicySQLite(cfg types.ConfigDB) error { " `status` varchar(10) DEFAULT NULL," + " `outdated` varchar(50) DEFAULT NULL," + " `spec` JSON DEFAULT NULL," + - " `generatedTime` bigint DEFAULT NULL," + - " `updatedTime` bigint DEFAULT NULL," + + " `generatedTime` bigint NOT NULL," + + " `updatedTime` bigint NOT NULL," + " `latest` BOOLEAN," + " PRIMARY KEY (`id`)" + " );"