diff --git a/stores/migrations.go b/stores/migrations.go index a9a058ba8..b3302e44e 100644 --- a/stores/migrations.go +++ b/stores/migrations.go @@ -342,6 +342,12 @@ func performMigrations(db *gorm.DB, logger *zap.SugaredLogger) error { return performMigration00032_objectIndices(tx, logger) }, }, + { + ID: "00033_transactionsTimestampIndex", + Migrate: func(tx *gorm.DB) error { + return performMigration00033_transactionsTimestampIndex(tx, logger) + }, + }, } // Create migrator. m := gormigrate.New(db, gormigrate.DefaultOptions, migrations) @@ -1429,3 +1435,16 @@ func performMigration00032_objectIndices(txn *gorm.DB, logger *zap.SugaredLogger logger.Info("migration 00032_objectIndices complete") return nil } + +func performMigration00033_transactionsTimestampIndex(txn *gorm.DB, logger *zap.SugaredLogger) error { + logger.Info("performing migration 00033_transactionsTimestampIndex") + + if err := txn.Table("transactions").Migrator().AutoMigrate(&struct { + Timestamp int64 `gorm:"index:idx_transactions_timestamp"` + }{}); err != nil { + return err + } + + logger.Info("migration 00033_transactionsTimestampIndex complete") + return nil +} diff --git a/stores/wallet.go b/stores/wallet.go index b4aa8a48c..679e96074 100644 --- a/stores/wallet.go +++ b/stores/wallet.go @@ -29,7 +29,7 @@ type ( TransactionID hash256 `gorm:"unique;index;NOT NULL;size:32"` Inflow currency Outflow currency - Timestamp int64 + Timestamp int64 `gorm:"index:idx_transactions_timestamp"` } outputChange struct {