Skip to content

Commit

Permalink
feat: added hash to models
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Aug 26, 2024
1 parent fdea835 commit 08d1acb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/entity/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ 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 {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Columns []DatabaseIndexColumn `json:"columns"`
Unique bool `json:"unique"`
Hash string `json:"hash,omitempty"`
}

type DatabaseIndexColumn struct {
Expand Down
12 changes: 12 additions & 0 deletions core/utils/hash.go
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit 08d1acb

Please sign in to comment.