fix: update model relationships

This commit is contained in:
Derrick Hammer 2023-04-30 02:16:32 -04:00
parent 25c7d6d4fb
commit 628f1b4aca
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
4 changed files with 13 additions and 10 deletions

View File

@ -12,6 +12,6 @@ type Account struct {
Password *string Password *string
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time
LoginTokens []LoginSession `gorm:"references:ID"` LoginTokens []LoginSession
Keys []Key `gorm:"references:ID"` Keys []Key
} }

View File

@ -7,8 +7,9 @@ import (
type Key struct { type Key struct {
gorm.Model gorm.Model
ID uint `gorm:"primaryKey"` ID uint `gorm:"primaryKey"`
Account Account `gorm:"references:ID"` AccountID uint
Account Account
PublicKey string PublicKey string
PrivateKey string PrivateKey string
CreatedAt time.Time CreatedAt time.Time

View File

@ -7,8 +7,9 @@ import (
type KeyChallenge struct { type KeyChallenge struct {
gorm.Model gorm.Model
ID uint `gorm:"primaryKey"` ID uint `gorm:"primaryKey"`
Account Account `gorm:"foreignKey:AccountID"` AccountID uint
Challenge string `gorm:"not null"` Account Account
Challenge string `gorm:"not null"`
Expiration time.Time Expiration time.Time
} }

View File

@ -7,9 +7,10 @@ import (
type LoginSession struct { type LoginSession struct {
gorm.Model gorm.Model
ID uint `gorm:"primaryKey"` ID uint `gorm:"primaryKey"`
Token string `gorm:"uniqueIndex"` AccountID uint
Account Account `gorm:"foreignKey:AccountID"` Token string `gorm:"uniqueIndex"`
Account Account
Expiration time.Time Expiration time.Time
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time