Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix creating of useless table

Cette révision appartient à :
sfan5 2017-05-09 17:14:13 +02:00
Parent 03a72b4d0d
révision 30f3b0c6eb
2 fichiers modifiés avec 5 ajouts et 9 suppressions

Voir le fichier

@ -30,7 +30,7 @@ func GormInit(conf *config.Config) (*gorm.DB, error) {
// db.SingularTable(true)
if config.Environment == "DEVELOPMENT" {
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")
}

Voir le fichier

@ -19,8 +19,8 @@ type User struct {
// TODO: move this to PublicUser
LikingCount int `json:"likingCount" gorm:"-"`
LikedCount int `json:"likedCount" gorm:"-"`
Likings []User `gorm:"foreignkey:userId;associationforeignkey:follower_id;many2many:users_followers;"`
Liked []User `gorm:"foreignkey:follower_id;associationforeignkey:userId;many2many:users_followers;"`
Likings []User `gorm:"foreignkey:userId;associationforeignkey:follower_id;many2many:user_follows"`
Liked []User `gorm:"foreignkey:follower_id;associationforeignkey:userId;many2many:user_follows"`
Md5 string `json:"md5"`
Torrents []Torrents `gorm:"ForeignKey:UploaderId"`
@ -30,12 +30,8 @@ type PublicUser struct {
User *User
}
// UsersFollowers is a relation table to relate users each other.
type UsersFollowers struct {
// different users following eachother
type UserFollows struct {
UserID uint `gorm:"column:user_id"`
FollowerID uint `gorm:"column:following"`
}
func (c UsersFollowers) TableName() string {
return "user_follows"
}