mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 21:19:18 +00:00
Cleanup gorm model attributes + add indexes
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
type Album struct {
|
||||
Model
|
||||
Title string `gorm:"not null"`
|
||||
ParentAlbumID *int
|
||||
ParentAlbumID *int `gorm:"index"`
|
||||
ParentAlbum *Album `gorm:"constraint:OnDelete:SET NULL;"`
|
||||
// OwnerID int `gorm:"not null"`
|
||||
// Owner User
|
||||
|
||||
@@ -13,20 +13,20 @@ type Media struct {
|
||||
Model
|
||||
Title string `gorm:"not null"`
|
||||
Path string `gorm:"not null"`
|
||||
PathHash string `gorm:"not null"`
|
||||
AlbumID int `gorm:"not null"`
|
||||
PathHash string `gorm:"not null;unique"`
|
||||
AlbumID int `gorm:"not null;index"`
|
||||
Album Album `gorm:"constraint:OnDelete:CASCADE;"`
|
||||
ExifID *int
|
||||
ExifID *int `gorm:"index"`
|
||||
Exif *MediaEXIF `gorm:"constraint:OnDelete:SET NULL;"`
|
||||
MediaURL []MediaURL `gorm:"constraint:OnDelete:CASCADE;"`
|
||||
DateShot time.Time `gorm:"not null"`
|
||||
DateImported time.Time `gorm:"not null"`
|
||||
// Favorite bool `gorm:"not null, default:false"`
|
||||
Type MediaType `gorm:"not null"`
|
||||
VideoMetadataID *int
|
||||
Type MediaType `gorm:"not null;index"`
|
||||
VideoMetadataID *int `gorm:"index"`
|
||||
VideoMetadata *VideoMetadata `gorm:"constraint:OnDelete:SET NULL;"`
|
||||
SideCarPath *string
|
||||
SideCarHash *string
|
||||
SideCarHash *string `gorm:"unique"`
|
||||
|
||||
// Only used internally
|
||||
CounterpartPath *string `gorm:-`
|
||||
@@ -72,12 +72,12 @@ const (
|
||||
|
||||
type MediaURL struct {
|
||||
Model
|
||||
MediaID int `gorm:"not null"`
|
||||
MediaID int `gorm:"not null;index"`
|
||||
Media Media `gorm:"constraint:OnDelete:CASCADE;"`
|
||||
MediaName string `gorm:"not null"`
|
||||
Width int `gorm:"not null"`
|
||||
Height int `gorm:"not null"`
|
||||
Purpose MediaPurpose `gorm:"not null"`
|
||||
Purpose MediaPurpose `gorm:"not null;index"`
|
||||
ContentType string `gorm:"not null"`
|
||||
FileSize int64 `gorm:"not null"`
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
type ShareToken struct {
|
||||
Model
|
||||
Value string `gorm:"not null"`
|
||||
OwnerID int `gorm:"not null"`
|
||||
OwnerID int `gorm:"not null;index"`
|
||||
Owner User `gorm:"constraint:OnDelete:CASCADE;"`
|
||||
Expire *time.Time
|
||||
Expire *time.Time `gorm:"index"`
|
||||
Password *string
|
||||
AlbumID *int
|
||||
AlbumID *int `gorm:"index"`
|
||||
Album *Album `gorm:"constraint:OnDelete:CASCADE;"`
|
||||
MediaID *int
|
||||
MediaID *int `gorm:"index"`
|
||||
Media *Media `gorm:"constraint:OnDelete:CASCADE;"`
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
type User struct {
|
||||
Model
|
||||
Username string `gorm:"unique,size:128"`
|
||||
Username string `gorm:"unique;size:128"`
|
||||
Password *string `gorm:"size:256`
|
||||
// RootPath string `gorm:"size:512`
|
||||
Albums []Album `gorm:"many2many:user_albums"`
|
||||
@@ -30,10 +30,10 @@ type UserMediaData struct {
|
||||
|
||||
type AccessToken struct {
|
||||
Model
|
||||
UserID int `gorm:"not null"`
|
||||
UserID int `gorm:"not null;index"`
|
||||
User User `gorm:"constraint:OnDelete:CASCADE;"`
|
||||
Value string `gorm:"not null, size:24`
|
||||
Expire time.Time `gorm:"not null"`
|
||||
Expire time.Time `gorm:"not null;index"`
|
||||
}
|
||||
|
||||
var ErrorInvalidUserCredentials = errors.New("invalid credentials")
|
||||
|
||||
Reference in New Issue
Block a user