changing layout

This commit is contained in:
Daniel Noulet 2026-09-19 16:45:24 +02:00
parent 17b5f751e2
commit b1c6aa659b
37 changed files with 695 additions and 1018 deletions

View file

@ -2,17 +2,6 @@ package persistence
import "time"
type UserModel struct {
ID uint `gorm:"primaryKey"`
Email string `gorm:"uniqueIndex;not null"`
Name string
Provider string `gorm:"not null"`
ProviderSubject string `gorm:"uniqueIndex;not null"`
Role string `gorm:"not null;default:''"`
Editor bool `gorm:"not null;default:false"`
CreatedAt time.Time
}
type ContentModel struct {
ID uint `gorm:"primaryKey"`
Slug string `gorm:"uniqueIndex;not null"`
@ -25,9 +14,10 @@ type ContentModel struct {
Category CategoryModel `gorm:"foreignKey:CategoryID"`
Badges []BadgeModel `gorm:"many2many:content_badges;joinForeignKey:ContentID;joinReferences:BadgeID"`
CreatedAt, UpdatedAt time.Time
CreatedBy, UpdatedBy uint
}
func (ContentModel) TableName() string { return "content" }
type CategoryModel struct {
ID uint `gorm:"primaryKey"`
Slug string `gorm:"uniqueIndex;not null"`
@ -43,38 +33,12 @@ type BadgeModel struct {
func (BadgeModel) TableName() string { return "badges" }
func (ContentModel) TableName() string { return "content" }
type ContentHistoryModel struct {
ID uint `gorm:"primaryKey"`
ContentID uint `gorm:"index;not null"`
Operation string `gorm:"not null"`
ActorID *uint
ActorAdminID *uint
CreatedAt time.Time
Snapshot string `gorm:"type:jsonb;not null"`
ID uint `gorm:"primaryKey"`
ContentID uint `gorm:"index;not null"`
Operation string `gorm:"not null"`
CreatedAt time.Time
Snapshot string `gorm:"type:jsonb;not null"`
}
func (ContentHistoryModel) TableName() string { return "content_history" }
func (UserModel) TableName() string { return "users" }
type AdminModel struct {
ID uint `gorm:"primaryKey"`
Email string `gorm:"uniqueIndex;not null"`
Name string
CreatedAt time.Time
}
func (AdminModel) TableName() string { return "admins" }
type SessionModel struct {
ID uint `gorm:"primaryKey"`
Token string `gorm:"uniqueIndex;not null"`
UserID *uint
AdminID *uint
ExpiresAt time.Time
CreatedAt time.Time
}
func (SessionModel) TableName() string { return "sessions" }