202509031250_transactions_updated_at_index.go raw
1 package migrations
2
3 import (
4 _ "embed"
5
6 "github.com/go-gormigrate/gormigrate/v2"
7 "gorm.io/gorm"
8 )
9
10 // speeds up this query:
11 // SELECT * FROM transactions WHERE state = 'SETTLED' OR type = 'outgoing' ORDER BY updated_at DESC LIMIT 20;
12 var _202509031250_transactions_updated_at_index = &gormigrate.Migration{
13 ID: "202509031250_transactions_updated_at_index",
14 Migrate: func(tx *gorm.DB) error {
15
16 err := tx.Exec("CREATE INDEX IF NOT EXISTS idx_transactions_updated_at ON transactions(updated_at);").Error
17 if err != nil {
18 return err
19 }
20
21 return nil
22 },
23 Rollback: func(tx *gorm.DB) error {
24 return nil
25 },
26 }
27