Skip to content

Commit

Permalink
Create contract indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Oct 8, 2023
1 parent ca8023f commit 9a0e26f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
9 changes: 0 additions & 9 deletions cmd/indexer/indexer/indices.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ func (bi *BlockchainIndexer) createIndices(ctx context.Context) error {
if err := bi.Storage.CreateIndex(ctx, "contracts_level_idx", "level", contractModel); err != nil {
return err
}
if err := bi.Storage.CreateIndex(ctx, "contracts_alpha_id_idx", "alpha_id", contractModel); err != nil {
return err
}
if err := bi.Storage.CreateIndex(ctx, "contracts_babylon_id_idx", "babylon_id", contractModel); err != nil {
return err
}
if err := bi.Storage.CreateIndex(ctx, "contracts_jakarta_id_idx", "jakarta_id", contractModel); err != nil {
return err
}

// Global constants
globalConstant := (*contract.GlobalConstant)(nil)
Expand Down
24 changes: 24 additions & 0 deletions internal/postgres/core/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,30 @@ func createBaseIndices(ctx context.Context, db bun.IDB) error {
Exec(ctx); err != nil {
return err
}
if _, err := db.NewCreateIndex().
Model((*contract.Contract)(nil)).
IfNotExists().
Index("contracts_alpha_id_idx").
Column("alpha_id").
Exec(ctx); err != nil {
return err
}
if _, err := db.NewCreateIndex().
Model((*contract.Contract)(nil)).
IfNotExists().
Index("contracts_babylon_id_idx").
Column("babylon_id").
Exec(ctx); err != nil {
return err
}
if _, err := db.NewCreateIndex().
Model((*contract.Contract)(nil)).
IfNotExists().
Index("contracts_jakarta_id_idx").
Column("jakarta_id").
Exec(ctx); err != nil {
return err
}

// Scripts
if _, err := db.NewCreateIndex().
Expand Down

0 comments on commit 9a0e26f

Please sign in to comment.