create photo and album
This commit is contained in:
parent
45683cbc0d
commit
51a40f294b
@ -12,6 +12,8 @@ func (s *Service) Migrate() {
|
|||||||
tx := s.DB.Set("gorm:table_options", "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")
|
tx := s.DB.Set("gorm:table_options", "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")
|
||||||
tx.AutoMigrate(&models.Account{})
|
tx.AutoMigrate(&models.Account{})
|
||||||
tx.AutoMigrate(&models.Session{})
|
tx.AutoMigrate(&models.Session{})
|
||||||
|
tx.AutoMigrate(&models.Album{})
|
||||||
|
tx.AutoMigrate(&models.Photo{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) DBConfig() {
|
func (s *Service) DBConfig() {
|
||||||
|
13
internal/photos/models/album.go
Normal file
13
internal/photos/models/album.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type Album struct {
|
||||||
|
ID uint32 `gorm:"primary_key"`
|
||||||
|
Name string `gorm:"not null"`
|
||||||
|
Parent *Album `gorm:"constraint:OnDelete:SET NULL,OnUpdate:CASCADE"`
|
||||||
|
ParentId uint32
|
||||||
|
Photos []*Photo `gorm:"many2many:album_photos"`
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
}
|
@ -1,6 +1,15 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
type Photo struct {
|
type Photo struct {
|
||||||
ID uint32 `gorm:"primary_key"`
|
ID uint32 `gorm:"primary_key"`
|
||||||
File string
|
File string `gorm:"not null"`
|
||||||
|
Name string `gorm:"not null"`
|
||||||
|
Checksum string `gorm:"unique;size:44;not null"`
|
||||||
|
Account *Account `gorm:"constraint:OnDelete:SET NULL,OnUpdate:CASCADE"`
|
||||||
|
AccountId uint32
|
||||||
|
Albums []*Album `gorm:"many2many:album_photos"`
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user