Skip to content

Commit

Permalink
add migration for blob indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Jul 26, 2024
1 parent d4a808a commit 4898344
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/core/data-api-backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (bf *backfiller) backfillPayloadsDelivered() error {
payloadsNew := 0
url := fmt.Sprintf("%s?limit=%d", baseURL, pageLimit)
if cursorSlot > 0 {
url = fmt.Sprintf("%s&cursor=%d", baseURL, cursorSlot)
url = fmt.Sprintf("%s&cursor=%d", url, cursorSlot)
}
_log.WithField("url: ", url).Info("Fetching payloads...")
var data []relaycommon.BidTraceV2JSON
Expand Down
19 changes: 19 additions & 0 deletions database/migrations/003_add_blob_index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package migrations

import (
"github.com/flashbots/relayscan/database/vars"
migrate "github.com/rubenv/sql-migrate"
)

var migration003SQL = `
CREATE INDEX IF NOT EXISTS ` + vars.TableDataAPIPayloadDelivered + `_num_blob_txs_idx ON ` + vars.TableDataAPIPayloadDelivered + `("num_blob_txs");
CREATE INDEX IF NOT EXISTS ` + vars.TableDataAPIPayloadDelivered + `_num_blobs_idx ON ` + vars.TableDataAPIPayloadDelivered + `("num_blobs");
`

var Migration003AddBlobIndexes = &migrate.Migration{
Id: "003-add-blob-indexes",
Up: []string{migration003SQL},

DisableTransactionUp: false,
DisableTransactionDown: true,
}
1 change: 1 addition & 0 deletions database/migrations/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ var Migrations = migrate.MemoryMigrationSource{
Migrations: []*migrate.Migration{
Migration001InitDatabase,
Migration002AddBlobCount,
Migration003AddBlobIndexes,
},
}

0 comments on commit 4898344

Please sign in to comment.