diff --git a/core/entity/database.go b/core/entity/database.go index bd89b7ce..eccb7d4f 100644 --- a/core/entity/database.go +++ b/core/entity/database.go @@ -24,6 +24,7 @@ type DatabaseColumn struct { Default string `json:"default,omitempty"` Extra string `json:"extra,omitempty"` Children []DatabaseColumn `json:"children,omitempty"` + Hash string `json:"hash,omitempty"` } type DatabaseIndex struct { @@ -31,6 +32,7 @@ type DatabaseIndex struct { Type string `json:"type,omitempty"` Columns []DatabaseIndexColumn `json:"columns"` Unique bool `json:"unique"` + Hash string `json:"hash,omitempty"` } type DatabaseIndexColumn struct { diff --git a/core/utils/hash.go b/core/utils/hash.go new file mode 100644 index 00000000..8fcbf0a1 --- /dev/null +++ b/core/utils/hash.go @@ -0,0 +1,12 @@ +package utils + +import "encoding/json" + +func GetObjectHash(obj any) string { + data, _ := json.Marshal(obj) + if data == nil { + // random hash + return EncryptMd5(NewUUIDString()) + } + return EncryptMd5(string(data)) +}