-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converts uint64 id's to uuidV7 (#220)
- Loading branch information
1 parent
f785a01
commit 39dae37
Showing
20 changed files
with
290 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,37 @@ | ||
package model | ||
|
||
import "time" | ||
import ( | ||
"fmt" | ||
"github.com/google/uuid" | ||
"gorm.io/gorm" | ||
"time" | ||
) | ||
|
||
type RelationshipHistory struct { | ||
ID uint64 `gorm:"primarykey"` | ||
OrgId string `gorm:"index"` | ||
ID uuid.UUID `gorm:"type:uuid;primarykey"` | ||
OrgId string `gorm:"index"` | ||
RelationshipData JsonObject | ||
RelationshipType string | ||
SubjectId uint64 `gorm:"index"` | ||
ObjectId uint64 `gorm:"index"` | ||
SubjectId uuid.UUID `gorm:"type:uuid;index"` | ||
ObjectId uuid.UUID `gorm:"type:uuid;index"` | ||
Reporter RelationshipReporter | ||
Timestamp *time.Time `gorm:"autoCreateTime"` | ||
|
||
RelationshipId uint64 `gorm:"index"` | ||
RelationshipId uuid.UUID `gorm:"type:uuid;index"` | ||
OperationType OperationType `gorm:"index"` | ||
} | ||
|
||
func (*RelationshipHistory) TableName() string { | ||
return "relationship_history" | ||
} | ||
|
||
func (r *RelationshipHistory) BeforeCreate(db *gorm.DB) error { | ||
var err error | ||
if r.ID == uuid.Nil { | ||
r.ID, err = uuid.NewV7() | ||
if err != nil { | ||
return fmt.Errorf("failed to generate uuid: %w", err) | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.