Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Remove indexes for automigrate

Acho Arnoldbfcd44083093
diff --git a/api/pkg/di/container.go b/api/pkg/di/container.go
index 3ca1e896..d17dd676 100644
--- a/api/pkg/di/container.go
+++ b/api/pkg/di/container.go
@@ -109,7 +109,6 @@ func (container *Container) DB() (db *gorm.DB) {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.EventListenerLog{})))
}
- db.Migrator().HasIndex(&entities.MessageThread{}, "")
if err = db.AutoMigrate(&entities.MessageThread{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.MessageThread{})))
}
diff --git a/api/pkg/entities/event_listener_log.go b/api/pkg/entities/event_listener_log.go
index 91e3f4cb..50f0662c 100644
--- a/api/pkg/entities/event_listener_log.go
+++ b/api/pkg/entities/event_listener_log.go
@@ -9,9 +9,9 @@ import (
// EventListenerLog stores the log of all the events handled
type EventListenerLog struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;"`
- EventID string `json:"event_id" gorm:"uniqueIndex:idx_event_listener_log_event_id_handler"`
+ EventID string `json:"event_id" gorm:"index:idx_event_listener_log_event_id_handler"`
EventType string `json:"event_type"`
- Handler string `json:"handler" gorm:"uniqueIndex:idx_event_listener_log_event_id_handler"`
+ Handler string `json:"handler" gorm:"index:idx_event_listener_log_event_id_handler"`
Duration time.Duration `json:"duration"`
HandledAt time.Time `json:"handled_at"`
CreatedAt time.Time `json:"created_at"`
diff --git a/api/pkg/entities/message_thread.go b/api/pkg/entities/message_thread.go
index b2974a0e..e9da93fe 100644
--- a/api/pkg/entities/message_thread.go
+++ b/api/pkg/entities/message_thread.go
@@ -9,10 +9,10 @@ import (
// MessageThread represents a message thread between 2 phone numbers
type MessageThread struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703ca"`
- Owner string `json:"owner" gorm:"uniqueIndex:idx_message_threads_owner_contact" example:"+18005550199"`
- Contact string `json:"contact" gorm:"uniqueIndex:idx_message_threads_owner_contact" example:"+18005550100"`
+ Owner string `json:"owner" example:"+18005550199"`
+ Contact string `json:"contact" example:"+18005550100"`
LastMessageContent string `json:"last_message_content" example:"This is a sample message content"`
- LastMessageID uuid.UUID `json:"last_message_id" gorm:"uniqueIndex:idx_message_threads_last_message_id" example:"32343a19-da5e-4b1b-a767-3298a73703ca"`
+ LastMessageID uuid.UUID `json:"last_message_id" example:"32343a19-da5e-4b1b-a767-3298a73703ca"`
CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:09.527976+03:00"`
UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:09.527976+03:00"`
OrderTimestamp time.Time `json:"order_timestamp" gorm:"index:idx_message_threads_order_timestamp" example:"2022-06-05T14:26:09.527976+03:00"`