Skip to content

Commit

Permalink
chore: Change the pkey of fevm_traces and refine the previous migrati…
Browse files Browse the repository at this point in the history
…on script (#1259)
  • Loading branch information
Terryhung authored Aug 30, 2023
1 parent 01a3ec2 commit 64d32f4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions model/fevm/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ type FEVMTrace struct {
// Height message was executed at.
Height int64 `pg:",pk,notnull,use_zero"`
// StateRoot message was applied to.
MessageStateRoot string `pg:",pk,notnull"`
MessageStateRoot string `pg:",notnull"`
// On-chain message triggering the message.
MessageCid string `pg:",pk,notnull"`
// On-chain message ETH transaction hash
TransactionHash string `pg:",notnull"`

// Cid of the trace.
TraceCid string `pg:",pk,notnull"`
TraceCid string `pg:",notnull"`
// ETH Address of the sender.
From string `pg:",notnull"`
// ETH Address of the receiver.
Expand All @@ -47,7 +47,7 @@ type FEVMTrace struct {
// Returns value of message receipt encode in eth bytes.
Returns string `pg:",notnull"`
// Index indicating the order of the messages execution.
Index uint64 `pg:",notnull,use_zero"`
Index uint64 `pg:",pk,notnull,use_zero"`
// Params contained in message.
ParsedParams string `pg:",type:jsonb"`
// Returns value of message receipt.
Expand Down
4 changes: 2 additions & 2 deletions schemas/v1/30_fevm_actor_dumps.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func init() {
actor_name TEXT,
PRIMARY KEY(height, actor_id, nonce)
);
CREATE INDEX fevm_actor_dumps_actor_id_idx ON {{ .SchemaName | default "public"}}.fevm_actor_dumps USING hash (actor_id);
CREATE INDEX fevm_actor_dumps_eth_address_idx ON {{ .SchemaName | default "public"}}.fevm_actor_dumps USING hash (eth_address);
CREATE INDEX IF NOT EXISTS fevm_actor_dumps_actor_id_idx ON {{ .SchemaName | default "public"}}.fevm_actor_dumps USING hash (actor_id);
CREATE INDEX IF NOT EXISTS fevm_actor_dumps_eth_address_idx ON {{ .SchemaName | default "public"}}.fevm_actor_dumps USING hash (eth_address);
`,
)
}
10 changes: 10 additions & 0 deletions schemas/v1/32_change_the_fevm_trace_pkey.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package v1

func init() {
patches.Register(
32,
`
ALTER TABLE {{ .SchemaName | default "public"}}.fevm_traces DROP CONSTRAINT IF EXISTS fevm_traces_pkey CASCADE, ADD PRIMARY KEY(height, index, message_cid)
`,
)
}

0 comments on commit 64d32f4

Please sign in to comment.