From 7c99cad52e64fa6f0abebc94c228f4394caa066f Mon Sep 17 00:00:00 2001 From: Chris Hager Date: Fri, 26 Jul 2024 10:31:10 +0200 Subject: [PATCH] add migration for blob indexes --- database/migrations/003_add_blob_index.go | 19 +++++++++++++++++++ database/migrations/migration.go | 1 + 2 files changed, 20 insertions(+) create mode 100644 database/migrations/003_add_blob_index.go diff --git a/database/migrations/003_add_blob_index.go b/database/migrations/003_add_blob_index.go new file mode 100644 index 0000000..b7ab15c --- /dev/null +++ b/database/migrations/003_add_blob_index.go @@ -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, +} diff --git a/database/migrations/migration.go b/database/migrations/migration.go index 973c7c4..b6feb38 100644 --- a/database/migrations/migration.go +++ b/database/migrations/migration.go @@ -9,5 +9,6 @@ var Migrations = migrate.MemoryMigrationSource{ Migrations: []*migrate.Migration{ Migration001InitDatabase, Migration002AddBlobCount, + Migration003AddBlobIndexes, }, }