Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename the fevm related table #1218

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions model/fevm/blockheader.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

type FEVMBlockHeader struct {
tableName struct{} `pg:"fevm_block_header"` // nolint: structcheck
tableName struct{} `pg:"fevm_block_headers"` // nolint: structcheck

// Height message was executed at.
Height int64 `pg:",pk,notnull,use_zero"`
Expand Down Expand Up @@ -41,7 +41,7 @@ type FEVMBlockHeader struct {
}

func (f *FEVMBlockHeader) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_header"))
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_headers"))
metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, f)
}
Expand All @@ -52,7 +52,7 @@ func (f FEVMBlockHeaderList) Persist(ctx context.Context, s model.StorageBatch,
if len(f) == 0 {
return nil
}
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_header"))
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_headers"))
metrics.RecordCount(ctx, metrics.PersistModel, len(f))
return s.PersistModel(ctx, f)
}
6 changes: 3 additions & 3 deletions model/fevm/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

type FEVMReceipt struct {
tableName struct{} `pg:"fevm_receipt"` // nolint: structcheck
tableName struct{} `pg:"fevm_receipts"` // nolint: structcheck

// Height message was executed at.
Height int64 `pg:",pk,notnull,use_zero"`
Expand All @@ -34,7 +34,7 @@ type FEVMReceipt struct {
}

func (f *FEVMReceipt) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_receipt"))
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_receipts"))
metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, f)
}
Expand All @@ -45,7 +45,7 @@ func (f FEVMReceiptList) Persist(ctx context.Context, s model.StorageBatch, vers
if len(f) == 0 {
return nil
}
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_receipt"))
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_receipts"))
metrics.RecordCount(ctx, metrics.PersistModel, len(f))
return s.PersistModel(ctx, f)
}
6 changes: 3 additions & 3 deletions model/fevm/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

type FEVMTransaction struct {
tableName struct{} `pg:"fevm_transaction"` // nolint: structcheck
tableName struct{} `pg:"fevm_transactions"` // nolint: structcheck

// Height message was executed at.
Height int64 `pg:",pk,notnull,use_zero"`
Expand All @@ -36,7 +36,7 @@ type FEVMTransaction struct {
}

func (f *FEVMTransaction) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_transaction"))
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_transactions"))
metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, f)
}
Expand All @@ -47,7 +47,7 @@ func (f FEVMTransactionList) Persist(ctx context.Context, s model.StorageBatch,
if len(f) == 0 {
return nil
}
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_transaction"))
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_transactions"))
metrics.RecordCount(ctx, metrics.PersistModel, len(f))
return s.PersistModel(ctx, f)
}
12 changes: 12 additions & 0 deletions schemas/v1/26_fevm_rename_table.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package v1

func init() {
patches.Register(
26,
`
ALTER TABLE IF EXISTS {{ .SchemaName | default "public"}}.fevm_block_header RENAME TO fevm_block_headers;
ALTER TABLE IF EXISTS {{ .SchemaName | default "public"}}.fevm_receipt RENAME TO fevm_receipts;
ALTER TABLE IF EXISTS {{ .SchemaName | default "public"}}.fevm_transaction RENAME TO fevm_transactions;
`,
)
}