2026-09-19 14:17:27 +02:00
|
|
|
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"`
|
2026-09-19 14:56:49 +02:00
|
|
|
Role string `gorm:"not null;default:''"`
|
|
|
|
|
Editor bool `gorm:"not null;default:false"`
|
2026-09-19 14:17:27 +02:00
|
|
|
CreatedAt time.Time
|
|
|
|
|
}
|
2026-09-19 14:48:42 +02:00
|
|
|
|
2026-09-19 14:56:49 +02:00
|
|
|
type ContentModel struct {
|
|
|
|
|
ID uint `gorm:"primaryKey"`
|
|
|
|
|
Slug string `gorm:"uniqueIndex;not null"`
|
|
|
|
|
Title string `gorm:"not null"`
|
|
|
|
|
Summary string
|
|
|
|
|
Body string `gorm:"not null"`
|
|
|
|
|
Status string `gorm:"not null;default:'draft'"`
|
|
|
|
|
Published bool `gorm:"not null;default:false"`
|
2026-09-19 15:11:12 +02:00
|
|
|
CategoryID uint
|
|
|
|
|
Category CategoryModel `gorm:"foreignKey:CategoryID"`
|
|
|
|
|
Badges []BadgeModel `gorm:"many2many:content_badges;joinForeignKey:ContentID;joinReferences:BadgeID"`
|
2026-09-19 14:56:49 +02:00
|
|
|
CreatedAt, UpdatedAt time.Time
|
|
|
|
|
CreatedBy, UpdatedBy uint
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-19 15:11:12 +02:00
|
|
|
type CategoryModel struct {
|
|
|
|
|
ID uint `gorm:"primaryKey"`
|
|
|
|
|
Slug string `gorm:"uniqueIndex;not null"`
|
|
|
|
|
Name string `gorm:"not null"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (CategoryModel) TableName() string { return "categories" }
|
|
|
|
|
|
|
|
|
|
type BadgeModel struct {
|
|
|
|
|
ID uint `gorm:"primaryKey"`
|
|
|
|
|
Name string `gorm:"uniqueIndex;not null"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (BadgeModel) TableName() string { return "badges" }
|
|
|
|
|
|
2026-09-19 14:56:49 +02:00
|
|
|
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"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ContentHistoryModel) TableName() string { return "content_history" }
|
|
|
|
|
|
2026-09-19 14:48:42 +02:00
|
|
|
func (UserModel) TableName() string { return "users" }
|
|
|
|
|
|
2026-09-19 14:17:27 +02:00
|
|
|
type AdminModel struct {
|
|
|
|
|
ID uint `gorm:"primaryKey"`
|
|
|
|
|
Email string `gorm:"uniqueIndex;not null"`
|
|
|
|
|
Name string
|
|
|
|
|
CreatedAt time.Time
|
|
|
|
|
}
|
2026-09-19 14:48:42 +02:00
|
|
|
|
|
|
|
|
func (AdminModel) TableName() string { return "admins" }
|
|
|
|
|
|
2026-09-19 14:17:27 +02:00
|
|
|
type SessionModel struct {
|
|
|
|
|
ID uint `gorm:"primaryKey"`
|
|
|
|
|
Token string `gorm:"uniqueIndex;not null"`
|
|
|
|
|
UserID *uint
|
|
|
|
|
AdminID *uint
|
|
|
|
|
ExpiresAt time.Time
|
|
|
|
|
CreatedAt time.Time
|
|
|
|
|
}
|
2026-09-19 14:48:42 +02:00
|
|
|
|
|
|
|
|
func (SessionModel) TableName() string { return "sessions" }
|