Skip to content

Commit 4464cd3

Browse files
TerryhungTerry
andauthored
Add rename the fevm related table (#1218)
Co-authored-by: Terry <[email protected]>
1 parent b86896a commit 4464cd3

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

model/fevm/blockheader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
type FEVMBlockHeader struct {
13-
tableName struct{} `pg:"fevm_block_header"` // nolint: structcheck
13+
tableName struct{} `pg:"fevm_block_headers"` // nolint: structcheck
1414

1515
// Height message was executed at.
1616
Height int64 `pg:",pk,notnull,use_zero"`
@@ -41,7 +41,7 @@ type FEVMBlockHeader struct {
4141
}
4242

4343
func (f *FEVMBlockHeader) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
44-
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_header"))
44+
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_headers"))
4545
metrics.RecordCount(ctx, metrics.PersistModel, 1)
4646
return s.PersistModel(ctx, f)
4747
}
@@ -52,7 +52,7 @@ func (f FEVMBlockHeaderList) Persist(ctx context.Context, s model.StorageBatch,
5252
if len(f) == 0 {
5353
return nil
5454
}
55-
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_header"))
55+
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_block_headers"))
5656
metrics.RecordCount(ctx, metrics.PersistModel, len(f))
5757
return s.PersistModel(ctx, f)
5858
}

model/fevm/receipt.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
type FEVMReceipt struct {
13-
tableName struct{} `pg:"fevm_receipt"` // nolint: structcheck
13+
tableName struct{} `pg:"fevm_receipts"` // nolint: structcheck
1414

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

3636
func (f *FEVMReceipt) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
37-
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_receipt"))
37+
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_receipts"))
3838
metrics.RecordCount(ctx, metrics.PersistModel, 1)
3939
return s.PersistModel(ctx, f)
4040
}
@@ -45,7 +45,7 @@ func (f FEVMReceiptList) Persist(ctx context.Context, s model.StorageBatch, vers
4545
if len(f) == 0 {
4646
return nil
4747
}
48-
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_receipt"))
48+
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_receipts"))
4949
metrics.RecordCount(ctx, metrics.PersistModel, len(f))
5050
return s.PersistModel(ctx, f)
5151
}

model/fevm/transaction.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
type FEVMTransaction struct {
13-
tableName struct{} `pg:"fevm_transaction"` // nolint: structcheck
13+
tableName struct{} `pg:"fevm_transactions"` // nolint: structcheck
1414

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

3838
func (f *FEVMTransaction) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
39-
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_transaction"))
39+
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_transactions"))
4040
metrics.RecordCount(ctx, metrics.PersistModel, 1)
4141
return s.PersistModel(ctx, f)
4242
}
@@ -47,7 +47,7 @@ func (f FEVMTransactionList) Persist(ctx context.Context, s model.StorageBatch,
4747
if len(f) == 0 {
4848
return nil
4949
}
50-
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_transaction"))
50+
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "fevm_transactions"))
5151
metrics.RecordCount(ctx, metrics.PersistModel, len(f))
5252
return s.PersistModel(ctx, f)
5353
}

schemas/v1/26_fevm_rename_table.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package v1
2+
3+
func init() {
4+
patches.Register(
5+
26,
6+
`
7+
ALTER TABLE IF EXISTS {{ .SchemaName | default "public"}}.fevm_block_header RENAME TO fevm_block_headers;
8+
ALTER TABLE IF EXISTS {{ .SchemaName | default "public"}}.fevm_receipt RENAME TO fevm_receipts;
9+
ALTER TABLE IF EXISTS {{ .SchemaName | default "public"}}.fevm_transaction RENAME TO fevm_transactions;
10+
`,
11+
)
12+
}

0 commit comments

Comments
 (0)