Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Add unique constraint to hash, email and username

Cette révision appartient à :
pantsudev 2017-06-14 16:42:15 +10:00
Parent aa08ec9f67
révision 948e7ce8c4
2 fichiers modifiés avec 5 ajouts et 5 suppressions

Voir le fichier

@ -45,7 +45,7 @@ type Feed struct {
type Torrent struct { type Torrent struct {
ID uint `gorm:"column:torrent_id;primary_key"` ID uint `gorm:"column:torrent_id;primary_key"`
Name string `gorm:"column:torrent_name"` Name string `gorm:"column:torrent_name"`
Hash string `gorm:"column:torrent_hash"` Hash string `gorm:"column:torrent_hash;unique"`
Category int `gorm:"column:category"` Category int `gorm:"column:category"`
SubCategory int `gorm:"column:sub_category"` SubCategory int `gorm:"column:sub_category"`
Status int `gorm:"column:status"` Status int `gorm:"column:status"`
@ -60,8 +60,8 @@ type Torrent struct {
AnidbID string `gorm:"column:anidb_id"` AnidbID string `gorm:"column:anidb_id"`
Trackers string `gorm:"column:trackers"` Trackers string `gorm:"column:trackers"`
// Indicates the language of the torrent's content (eg. subs, dubs, raws, manga TLs) // Indicates the language of the torrent's content (eg. subs, dubs, raws, manga TLs)
Language string `gorm:"column:language"` Language string `gorm:"column:language"`
DeletedAt *time.Time DeletedAt *time.Time
Uploader *User `gorm:"AssociationForeignKey:UploaderID;ForeignKey:user_id"` Uploader *User `gorm:"AssociationForeignKey:UploaderID;ForeignKey:user_id"`
OldUploader string `gorm:"-"` // ??????? OldUploader string `gorm:"-"` // ???????

Voir le fichier

@ -24,9 +24,9 @@ const (
// User model // User model
type User struct { type User struct {
ID uint `gorm:"column:user_id;primary_key"` ID uint `gorm:"column:user_id;primary_key"`
Username string `gorm:"column:username"` Username string `gorm:"column:username;unique"`
Password string `gorm:"column:password"` Password string `gorm:"column:password"`
Email string `gorm:"column:email"` Email string `gorm:"column:email;unique"`
Status int `gorm:"column:status"` Status int `gorm:"column:status"`
CreatedAt time.Time `gorm:"column:created_at"` CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"` UpdatedAt time.Time `gorm:"column:updated_at"`