diff --git a/internal/database/event_tier_indexes_test.go b/internal/database/event_tier_indexes_test.go index 2999464..46835c2 100644 --- a/internal/database/event_tier_indexes_test.go +++ b/internal/database/event_tier_indexes_test.go @@ -17,24 +17,24 @@ type indexedColumn struct { field string } -// eventTierIndexes are the columns the background work reads by: the -// recovery and sweep queries (status), the event log (event_id and -// delivery_id) and retention (created_at). -var eventTierIndexes = []indexedColumn{ - {&database.Delivery{}, "Status"}, - {&database.Delivery{}, "EventID"}, - {&database.DeliveryResult{}, "DeliveryID"}, - {&database.Event{}, "CreatedAt"}, -} - // TestWebhookDBManager_OpenAddsEventTierIndexes verifies that opening a // per-webhook database that predates these indexes creates them, so the -// queries above stop scanning whole tables. It stands in for an older -// database file by dropping the indexes AutoMigrate just created, then -// reopening the same file. +// queries that read by those columns stop scanning whole tables. It +// stands in for an older database file by dropping the indexes +// AutoMigrate just created, then reopening the same file. func TestWebhookDBManager_OpenAddsEventTierIndexes(t *testing.T) { t.Parallel() + // The columns the background work reads by: the recovery and sweep + // queries (status), the event log (event_id and delivery_id) and + // retention (created_at). + eventTierIndexes := []indexedColumn{ + {&database.Delivery{}, "Status"}, + {&database.Delivery{}, "EventID"}, + {&database.DeliveryResult{}, "DeliveryID"}, + {&database.Event{}, "CreatedAt"}, + } + mgr, lc := setupTestWebhookDBManager(t) ctx := context.Background() require.NoError(t, lc.Start(ctx)) diff --git a/internal/database/model_delivery_result.go b/internal/database/model_delivery_result.go index d701a95..de064a0 100644 --- a/internal/database/model_delivery_result.go +++ b/internal/database/model_delivery_result.go @@ -5,10 +5,10 @@ type DeliveryResult struct { BaseModel DeliveryID string `gorm:"type:uuid;not null;index" json:"deliveryId"` - AttemptNum int `gorm:"not null" json:"attemptNum"` + AttemptNum int `gorm:"not null" json:"attemptNum"` Success bool `json:"success"` StatusCode int `json:"statusCode,omitempty"` - ResponseBody string `gorm:"type:text" json:"responseBody,omitempty"` + ResponseBody string `gorm:"type:text" json:"responseBody,omitempty"` Error string `json:"error,omitempty"` Duration int64 `json:"durationMs"` // Duration in milliseconds