soxx 6f814e5b21
All checks were successful
Gitea Build Check / Build (pull_request) Successful in 3m8s
refactor: unified migrations and Tag* ID Changes
- unified the migrations
- added new IDs for Tag, TagAlias, TagGroup
- changed relevant functions to use the given IDs

BREAKING-CHANGE: Database needs to be cleared or migrated. Not compatible with Database v5
2025-01-28 13:27:11 +01:00

44 lines
1.0 KiB
Go

package models
// Tag models
type Tag struct {
ID TagID `json:"id" gorm:"primaryKey"`
Name TagName `json:"name"`
Type TagType `json:"type" gorm:"column:tag_type"`
Aliases []TagAlias `json:"aliases,omitempty" gorm:"foreignKey:TagID"`
Groups []TagGroup `json:"groups,omitempty" gorm:"foreignKey:TagID"`
Posts []Post `json:"posts,omitempty" gorm:"many2many:post_tags;"`
}
func (Tag) TableName() string {
return "Tag"
}
// TagAlias model
type TagAlias struct {
ID TagAliasID `json:"id" gorm:"primaryKey"`
Name TagAliasName `json:"name"`
TagID TagID `json:"tag_name"`
}
func (TagAlias) TableName() string {
return "TagAlias"
}
// TagGroup model
type TagGroup struct {
ID TagGroupID `json:"id" gorm:"primaryKey"`
Name TagGroupName `json:"name"`
TagID TagID `json:"tag_name"`
}
func (TagGroup) TableName() string {
return "TagGroup"
}
type TagsWithFrequency struct {
ID int64 `json:"id" gorm:"primaryKey"`
Frequency int64 `json:"frequency"`
Tags Tag `json:"tags"`
}