Skip to content

Commit

Permalink
Add explicit datetime annotations to timestamp cols
Browse files Browse the repository at this point in the history
  • Loading branch information
airforce270 committed Aug 17, 2024
1 parent ca82fdf commit a93064e
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions database/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ var AllModels = []any{

// BotBan represents a bot being banned from a channel.
type BotBan struct {
gorm.Model
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"type:datetime"`
UpdatedAt time.Time `gorm:"type:datetime"`
DeletedAt gorm.DeletedAt `gorm:"index"`

// Platform contains the which platform this channel is on.
Platform string
Expand All @@ -33,7 +36,10 @@ type BotBan struct {

// ChannelCommandCooldown contains a record of a command cooldown in a channel.
type ChannelCommandCooldown struct {
gorm.Model
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"type:datetime"`
UpdatedAt time.Time `gorm:"type:datetime"`
DeletedAt gorm.DeletedAt `gorm:"index"`

// Channel is the channel the command has a cooldown in.
Channel string
Expand All @@ -45,7 +51,10 @@ type ChannelCommandCooldown struct {

// Duel represents a gamba duel.
type Duel struct {
gorm.Model
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"type:datetime"`
UpdatedAt time.Time `gorm:"type:datetime"`
DeletedAt gorm.DeletedAt `gorm:"index"`

// UserID is the ID of the user that initiated the duel.
UserID uint
Expand All @@ -67,7 +76,10 @@ type Duel struct {

// GambaTransaction represents a single gamba transaction.
type GambaTransaction struct {
gorm.Model
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"type:datetime"`
UpdatedAt time.Time `gorm:"type:datetime"`
DeletedAt gorm.DeletedAt `gorm:"index"`

// UserID is the ID of the user that executed the transaction.
UserID uint
Expand All @@ -81,7 +93,10 @@ type GambaTransaction struct {

// JoinedChannel represents a channel the bot should join.
type JoinedChannel struct {
gorm.Model
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"type:datetime"`
UpdatedAt time.Time `gorm:"type:datetime"`
DeletedAt gorm.DeletedAt `gorm:"index"`

// Platform contains the which platform this channel is on.
Platform string
Expand All @@ -97,7 +112,10 @@ type JoinedChannel struct {

// Message represents a chat message.
type Message struct {
gorm.Model
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"type:datetime"`
UpdatedAt time.Time `gorm:"type:datetime"`
DeletedAt gorm.DeletedAt `gorm:"index"`

// Text contains the text of the message.
Text string
Expand All @@ -114,7 +132,10 @@ type Message struct {

// User represents a user.
type User struct {
gorm.Model
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"type:datetime"`
UpdatedAt time.Time `gorm:"type:datetime"`
DeletedAt gorm.DeletedAt `gorm:"index"`

// TwitchID is the user's ID on Twitch, if known
TwitchID string
Expand All @@ -124,7 +145,10 @@ type User struct {

// UserCommandCooldown contains a record of a command cooldown for a user.
type UserCommandCooldown struct {
gorm.Model
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"type:datetime"`
UpdatedAt time.Time `gorm:"type:datetime"`
DeletedAt gorm.DeletedAt `gorm:"index"`

// UserID is the ID of the user with the cooldown.
UserID uint
Expand Down

0 comments on commit a93064e

Please sign in to comment.