Files

42 lines
1.4 KiB
Go

package models
import (
"time"
"github.com/google/uuid"
)
type User struct {
ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
Username string `gorm:"uniqueIndex;size:32;not null"`
DisplayName string `gorm:"size:100;not null;column:display_name"`
PasswordHash string `gorm:"size:255;not null;column:password_hash"`
CreatedAt time.Time `gorm:"not null;column:created_at"`
}
type Chat struct {
ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
Title string `gorm:"size:100;not null"`
CreatedAt time.Time `gorm:"not null;column:created_at"`
}
type ChatMember struct {
ChatID uuid.UUID `gorm:"type:uuid;primaryKey;column:chat_id"`
UserID uuid.UUID `gorm:"type:uuid;primaryKey;column:user_id"`
}
type Message struct {
ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
ChatID uuid.UUID `gorm:"type:uuid;not null;index:idx_msg_chat_time_id"`
SenderID uuid.UUID `gorm:"type:uuid;not null;column:sender_id"`
Text string `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;index:idx_msg_chat_time_id;column:created_at"`
}
type Session struct {
Token string `gorm:"primaryKey;size:255"`
UserID uuid.UUID `gorm:"type:uuid;not null;index;column:user_id"`
ExpiresAt time.Time `gorm:"not null;index;column:expires_at"`
CreatedAt time.Time `gorm:"not null;column:created_at"`
}