Add shares table for sharing photos and albums

This commit is contained in:
Michael Mayer 2019-06-16 21:04:29 -07:00
parent bb8c2dbbea
commit 27530bc0be
2 changed files with 30 additions and 0 deletions

View file

@ -412,6 +412,7 @@ func (c *Config) MigrateDb() {
&models.Camera{},
&models.Lens{},
&models.Country{},
&models.Share{},
)
}

29
internal/models/share.go Normal file
View file

@ -0,0 +1,29 @@
package models
import (
"time"
"github.com/jinzhu/gorm"
uuid "github.com/satori/go.uuid"
)
// Shared photos and/or albums
type Share struct {
ShareUUID string `gorm:"primary_key;auto_increment:false"`
PhotoID uint
AlbumID uint
ShareSecret string
SharePassword string
ShareExpires time.Time
Photo *Photo
Album *Album
}
func (Share) TableName() string {
return "shares"
}
func (s *Share) BeforeCreate(scope *gorm.Scope) error {
return scope.SetColumn("ShareUUID", uuid.NewV4().String())
}