Fix creating of useless table
Cette révision appartient à :
Parent
03a72b4d0d
révision
30f3b0c6eb
2 fichiers modifiés avec 5 ajouts et 9 suppressions
|
@ -30,7 +30,7 @@ func GormInit(conf *config.Config) (*gorm.DB, error) {
|
||||||
// db.SingularTable(true)
|
// db.SingularTable(true)
|
||||||
if config.Environment == "DEVELOPMENT" {
|
if config.Environment == "DEVELOPMENT" {
|
||||||
db.LogMode(true)
|
db.LogMode(true)
|
||||||
db.AutoMigrate(&model.Torrents{}, &model.UsersFollowers{}, &model.User{}, &model.Comment{}, &model.OldComment{})
|
db.AutoMigrate(&model.Torrents{}, &model.UserFollows{}, &model.User{}, &model.Comment{}, &model.OldComment{})
|
||||||
// db.Model(&model.User{}).AddIndex("idx_user_token", "token")
|
// db.Model(&model.User{}).AddIndex("idx_user_token", "token")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ type User struct {
|
||||||
// TODO: move this to PublicUser
|
// TODO: move this to PublicUser
|
||||||
LikingCount int `json:"likingCount" gorm:"-"`
|
LikingCount int `json:"likingCount" gorm:"-"`
|
||||||
LikedCount int `json:"likedCount" gorm:"-"`
|
LikedCount int `json:"likedCount" gorm:"-"`
|
||||||
Likings []User `gorm:"foreignkey:userId;associationforeignkey:follower_id;many2many:users_followers;"`
|
Likings []User `gorm:"foreignkey:userId;associationforeignkey:follower_id;many2many:user_follows"`
|
||||||
Liked []User `gorm:"foreignkey:follower_id;associationforeignkey:userId;many2many:users_followers;"`
|
Liked []User `gorm:"foreignkey:follower_id;associationforeignkey:userId;many2many:user_follows"`
|
||||||
|
|
||||||
Md5 string `json:"md5"`
|
Md5 string `json:"md5"`
|
||||||
Torrents []Torrents `gorm:"ForeignKey:UploaderId"`
|
Torrents []Torrents `gorm:"ForeignKey:UploaderId"`
|
||||||
|
@ -30,12 +30,8 @@ type PublicUser struct {
|
||||||
User *User
|
User *User
|
||||||
}
|
}
|
||||||
|
|
||||||
// UsersFollowers is a relation table to relate users each other.
|
// different users following eachother
|
||||||
type UsersFollowers struct {
|
type UserFollows struct {
|
||||||
UserID uint `gorm:"column:user_id"`
|
UserID uint `gorm:"column:user_id"`
|
||||||
FollowerID uint `gorm:"column:following"`
|
FollowerID uint `gorm:"column:following"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c UsersFollowers) TableName() string {
|
|
||||||
return "user_follows"
|
|
||||||
}
|
|
||||||
|
|
Référencer dans un nouveau ticket