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
CreatedAt time.Time
UpdatedAt time.Time
LoginTokens []LoginSession `gorm:"references:ID"`
Keys []Key `gorm:"references:ID"`
LoginTokens []LoginSession
Keys []Key
}

View File

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

View File

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

View File

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