Skip to content

Commit bfcd440

Browse files
committed
Remove indexes for automigrate
1 parent 1ec3af7 commit bfcd440

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

api/pkg/di/container.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ func (container *Container) DB() (db *gorm.DB) {
109109
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.EventListenerLog{})))
110110
}
111111

112-
db.Migrator().HasIndex(&entities.MessageThread{}, "")
113112
if err = db.AutoMigrate(&entities.MessageThread{}); err != nil {
114113
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.MessageThread{})))
115114
}

api/pkg/entities/event_listener_log.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
// EventListenerLog stores the log of all the events handled
1010
type EventListenerLog struct {
1111
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;"`
12-
EventID string `json:"event_id" gorm:"uniqueIndex:idx_event_listener_log_event_id_handler"`
12+
EventID string `json:"event_id" gorm:"index:idx_event_listener_log_event_id_handler"`
1313
EventType string `json:"event_type"`
14-
Handler string `json:"handler" gorm:"uniqueIndex:idx_event_listener_log_event_id_handler"`
14+
Handler string `json:"handler" gorm:"index:idx_event_listener_log_event_id_handler"`
1515
Duration time.Duration `json:"duration"`
1616
HandledAt time.Time `json:"handled_at"`
1717
CreatedAt time.Time `json:"created_at"`

api/pkg/entities/message_thread.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
// MessageThread represents a message thread between 2 phone numbers
1010
type MessageThread struct {
1111
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703ca"`
12-
Owner string `json:"owner" gorm:"uniqueIndex:idx_message_threads_owner_contact" example:"+18005550199"`
13-
Contact string `json:"contact" gorm:"uniqueIndex:idx_message_threads_owner_contact" example:"+18005550100"`
12+
Owner string `json:"owner" example:"+18005550199"`
13+
Contact string `json:"contact" example:"+18005550100"`
1414
LastMessageContent string `json:"last_message_content" example:"This is a sample message content"`
15-
LastMessageID uuid.UUID `json:"last_message_id" gorm:"uniqueIndex:idx_message_threads_last_message_id" example:"32343a19-da5e-4b1b-a767-3298a73703ca"`
15+
LastMessageID uuid.UUID `json:"last_message_id" example:"32343a19-da5e-4b1b-a767-3298a73703ca"`
1616
CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:09.527976+03:00"`
1717
UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:09.527976+03:00"`
1818
OrderTimestamp time.Time `json:"order_timestamp" gorm:"index:idx_message_threads_order_timestamp" example:"2022-06-05T14:26:09.527976+03:00"`

0 commit comments

Comments
 (0)