58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package src
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type User struct {
|
|
ID uint `gorm:"primaryKey"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
|
|
Email string `gorm:"uniqueIndex;size:320"`
|
|
Username string `gorm:"uniqueIndex;size:64"`
|
|
Slug string `gorm:"uniqueIndex;size:80"`
|
|
}
|
|
|
|
type Session struct {
|
|
ID uint `gorm:"primaryKey"`
|
|
CreatedAt time.Time
|
|
// No expiry by default; can add later
|
|
Token string `gorm:"uniqueIndex;size:128"`
|
|
UserID uint `gorm:"index"`
|
|
User User
|
|
}
|
|
|
|
type LoginToken struct {
|
|
ID uint `gorm:"primaryKey"`
|
|
CreatedAt time.Time
|
|
Token string `gorm:"uniqueIndex;size:128"`
|
|
Email string `gorm:"index;size:320"`
|
|
ExpiresAt time.Time `gorm:"index"`
|
|
}
|
|
|
|
type Table struct {
|
|
ID uint `gorm:"primaryKey"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
Name string
|
|
Slug string `gorm:"uniqueIndex;size:80"`
|
|
}
|
|
|
|
type Game struct {
|
|
ID uint `gorm:"primaryKey"`
|
|
CreatedAt time.Time `gorm:"index"`
|
|
TableID *uint `gorm:"index"`
|
|
Table *Table
|
|
ScoreA int
|
|
ScoreB int
|
|
}
|
|
|
|
type GamePlayer struct {
|
|
ID uint `gorm:"primaryKey"`
|
|
GameID uint `gorm:"index"`
|
|
UserID uint `gorm:"index"`
|
|
Side string `gorm:"size:1;index"` // "A" or "B"
|
|
User User
|
|
}
|