BREAKING CHANGE: V2 of thr SDK #12

Merged
fenpaws merged 124 commits from develop/postgresql into main 2024-07-01 20:46:28 +00:00
7 changed files with 45 additions and 10 deletions
Showing only changes of commit 5a693063bb - Show all commits

View File

@ -7,8 +7,11 @@ import (
// Post model // Post model
type Post struct { type Post struct {
BaseModel BaseModel
Rating models.Rating `gorm:"type:rating"` Rating models.Rating `gorm:"type:enum('safe','questionable','explicit')"`
Body string `gorm:"type:text"` Body string `gorm:"type:text"`
UserID int `gorm:"index"` UserID int
Status string `gorm:"type:post_status"` Status string
Tags []Tag `gorm:"many2many:post_tags;"`
Favorites []UserFavorite `gorm:"foreignKey:PostID"`
References []PostReference `gorm:"foreignKey:PostID"`
} }

View File

@ -0,0 +1,8 @@
package pgModels
type PostReference struct {
PostID string `gorm:"primaryKey"`
SourceID string `gorm:"primaryKey"`
URL string `gorm:"not null;unique"`
SourcePostID string
}

View File

@ -3,6 +3,8 @@ package pgModels
// Source model // Source model
type Source struct { type Source struct {
BaseModel BaseModel
DisplayName string `gorm:"type:text"` DisplayName string
Domain string `gorm:"type:text;not null;unique"` Domain string `gorm:"not null;unique"`
UserSources []UserSource `gorm:"foreignKey:SourceID"`
References []PostReference `gorm:"foreignKey:SourceID"`
} }

View File

@ -5,17 +5,20 @@ import "git.dragse.it/anthrove/otter-space-sdk/pkg/models"
// Tag models // Tag models
type Tag struct { type Tag struct {
Name string `gorm:"primaryKey"` Name string `gorm:"primaryKey"`
Type models.TagType `gorm:"type:tag_type"` Type models.TagType
Aliases []TagAlias `gorm:"foreignKey:TagID"`
Groups []TagGroup `gorm:"foreignKey:TagID"`
Posts []Post `gorm:"many2many:post_tags;"`
} }
// TagAlias model // TagAlias model
type TagAlias struct { type TagAlias struct {
Name string `gorm:"primaryKey"` Name string `gorm:"primaryKey"`
TagID string `gorm:"index"` TagID string
} }
// TagGroup model // TagGroup model
type TagGroup struct { type TagGroup struct {
Name string `gorm:"primaryKey"` Name string `gorm:"primaryKey"`
TagID string `gorm:"index"` TagID string
} }

View File

@ -3,4 +3,6 @@ package pgModels
// User model // User model
type User struct { type User struct {
BaseModel BaseModel
Favorites []UserFavorite `gorm:"foreignKey:UserID"`
Sources []UserSource `gorm:"foreignKey:UserID"`
} }

View File

@ -0,0 +1,9 @@
package pgModels
import "time"
type UserFavorite struct {
UserID string `gorm:"primaryKey"`
PostID string `gorm:"primaryKey"`
CreatedAt time.Time
}

View File

@ -0,0 +1,8 @@
package pgModels
type UserSource struct {
UserID string `gorm:"primaryKey"`
SourceID string `gorm:"primaryKey"`
AccountUsername string
AccountID string
}