Skip to content

Commit

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// UserID is the ID of the user with the cooldown.
UserID uint
Expand Down
48 changes: 36 additions & 12 deletions gamba/gamba_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,27 +286,35 @@ func TestDeduplicateByUser(t *testing.T) {
input: []grant{
{
User: models.User{
ID: 1,
Model: gorm.Model{
ID: 1,
},
},
IsActive: true,
},
{
User: models.User{
ID: 2,
Model: gorm.Model{
ID: 2,
},
},
IsActive: true,
},
},
want: []grant{
{
User: models.User{
ID: 1,
Model: gorm.Model{
ID: 1,
},
},
IsActive: true,
},
{
User: models.User{
ID: 2,
Model: gorm.Model{
ID: 2,
},
},
IsActive: true,
},
Expand All @@ -317,27 +325,35 @@ func TestDeduplicateByUser(t *testing.T) {
input: []grant{
{
User: models.User{
ID: 1,
Model: gorm.Model{
ID: 1,
},
},
IsActive: false,
},
{
User: models.User{
ID: 2,
Model: gorm.Model{
ID: 2,
},
},
IsActive: false,
},
},
want: []grant{
{
User: models.User{
ID: 1,
Model: gorm.Model{
ID: 1,
},
},
IsActive: false,
},
{
User: models.User{
ID: 2,
Model: gorm.Model{
ID: 2,
},
},
IsActive: false,
},
Expand All @@ -348,27 +364,35 @@ func TestDeduplicateByUser(t *testing.T) {
input: []grant{
{
User: models.User{
ID: 1,
Model: gorm.Model{
ID: 1,
},
},
IsActive: false,
},
{
User: models.User{
ID: 2,
Model: gorm.Model{
ID: 2,
},
},
IsActive: true,
},
},
want: []grant{
{
User: models.User{
ID: 2,
Model: gorm.Model{
ID: 2,
},
},
IsActive: true,
},
{
User: models.User{
ID: 1,
Model: gorm.Model{
ID: 1,
},
},
IsActive: false,
},
Expand Down

0 comments on commit 49761f1

Please sign in to comment.