Fix Model Issues & wrong id types in Database migration #16
13
pkg/database/migrations/005_id_fixes.sql
Normal file
13
pkg/database/migrations/005_id_fixes.sql
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
-- +migrate Up
|
||||||
|
ALTER TABLE "PostReference"
|
||||||
|
ALTER COLUMN post_id TYPE CHAR(25),
|
||||||
|
ALTER COLUMN source_id TYPE CHAR(25);
|
||||||
|
|
||||||
|
ALTER TABLE post_tags
|
||||||
|
ALTER COLUMN post_id TYPE CHAR(25);
|
||||||
|
|
||||||
|
ALTER TABLE "UserFavorites"
|
||||||
|
ALTER COLUMN post_id TYPE CHAR(25);
|
||||||
|
|
||||||
|
ALTER TABLE "UserSource"
|
||||||
|
ALTER COLUMN source_id TYPE CHAR(25);
|
@ -9,8 +9,10 @@ const (
|
|||||||
|
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
BaseModel[PoolID]
|
BaseModel[PoolID]
|
||||||
Name string `json:"name" gorm:"type:varchar(25)"`
|
Name string `json:"name" gorm:"column:name;type:varchar(25)"`
|
||||||
Category PoolCategory `json:"category" gorm:"type:pool_category;type:enum('series', 'collection')"`
|
Category PoolCategory `json:"category" gorm:"column:category;type:pool_category;type:enum('series', 'collection')"`
|
||||||
|
Posts []PoolPost `json:"posts" gorm:"foreignKey:PoolID"`
|
||||||
|
Sources []PoolReference `json:"sources" gorm:"foreignKey:PoolID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Pool) TableName() string {
|
func (Pool) TableName() string {
|
||||||
@ -18,11 +20,10 @@ func (Pool) TableName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PoolPost struct {
|
type PoolPost struct {
|
||||||
Pool Pool `json:"pool" gorm:"foreignKey:ID;references:PoolID"`
|
PoolID PoolID `json:"pool_id" gorm:"column:pool_id;primaryKey"`
|
||||||
PoolID PoolID `json:"pool_id" gorm:""`
|
Pool Pool `json:"-"`
|
||||||
Post Post `json:"post" gorm:"foreignKey:ID;references:PostID"`
|
PostID PostID `json:"post_id" gorm:"column:post_id;primaryKey"`
|
||||||
PostID PostID `json:"post_id" gorm:""`
|
OrderPosition int `json:"order_position" gorm:"column:order_position;default:0"`
|
||||||
OrderPosition int `json:"order_position" gorm:"not null;default:0"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (PoolPost) TableName() string {
|
func (PoolPost) TableName() string {
|
||||||
@ -30,11 +31,10 @@ func (PoolPost) TableName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PoolReference struct {
|
type PoolReference struct {
|
||||||
Pool Pool `json:"pool" gorm:"foreignKey:ID;references:PoolID"`
|
PoolID PoolID `json:"pool_id" gorm:"column:pool_id;primaryKey"`
|
||||||
PoolID PoolID `json:"pool_id" gorm:""`
|
Pool Pool `json:"-"`
|
||||||
Source Source `json:"source" gorm:"foreignKey:ID;references:SourceID"`
|
SourceID SourceID `json:"source_id" gorm:"column:source_id;primaryKey"`
|
||||||
SourceID SourceID `json:"source_id" gorm:""`
|
URL string `json:"url" gorm:"column:url;primaryKey"`
|
||||||
URL string `json:"url" gorm:"not null"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (PoolReference) TableName() string {
|
func (PoolReference) TableName() string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user