Skip to content

Commit

Permalink
feat: change derived_gas_outputs value columns to numerics
Browse files Browse the repository at this point in the history
  • Loading branch information
iand authored and frrist committed Jan 11, 2021
1 parent ebb1099 commit 853cfce
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
18 changes: 9 additions & 9 deletions model/derived/gasoutputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ type GasOutputs struct {
StateRoot string `pg:",pk,notnull"`
From string `pg:",notnull"`
To string `pg:",notnull"`
Value string `pg:",notnull"`
GasFeeCap string `pg:",notnull"`
GasPremium string `pg:",notnull"`
Value string `pg:"type:numeric,notnull"`
GasFeeCap string `pg:"type:numeric,notnull"`
GasPremium string `pg:"type:numeric,notnull"`
GasLimit int64 `pg:",use_zero,notnull"`
SizeBytes int `pg:",use_zero,notnull"`
Nonce uint64 `pg:",use_zero,notnull"`
Method uint64 `pg:",use_zero,notnull"`
ActorName string `pg:",notnull"`
ExitCode int64 `pg:",use_zero,notnull"`
GasUsed int64 `pg:",use_zero,notnull"`
ParentBaseFee string `pg:",notnull"`
BaseFeeBurn string `pg:",notnull"`
OverEstimationBurn string `pg:",notnull"`
MinerPenalty string `pg:",notnull"`
MinerTip string `pg:",notnull"`
Refund string `pg:",notnull"`
ParentBaseFee string `pg:"type:numeric,notnull"`
BaseFeeBurn string `pg:"type:numeric,notnull"`
OverEstimationBurn string `pg:"type:numeric,notnull"`
MinerPenalty string `pg:"type:numeric,notnull"`
MinerTip string `pg:"type:numeric,notnull"`
Refund string `pg:"type:numeric,notnull"`
GasRefund int64 `pg:",use_zero,notnull"`
GasBurned int64 `pg:",use_zero,notnull"`
}
Expand Down
20 changes: 20 additions & 0 deletions storage/migrations/26_use_numberic_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import "github.com/go-pg/migrations/v8"

func init() {
up := batch(`
ALTER TABLE public.derived_gas_outputs ALTER COLUMN value TYPE numeric USING (value::numeric);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN gas_fee_cap TYPE numeric USING (gas_fee_cap::numeric);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN gas_premium TYPE numeric USING (gas_premium::numeric);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN parent_base_fee TYPE numeric USING (parent_base_fee::numeric);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN base_fee_burn TYPE numeric USING (base_fee_burn::numeric);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN over_estimation_burn TYPE numeric USING (over_estimation_burn::numeric);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN miner_penalty TYPE numeric USING (miner_penalty::numeric);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN miner_tip TYPE numeric USING (miner_tip::numeric);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN refund TYPE numeric USING (refund::numeric);
ALTER TABLE public.messages ALTER COLUMN value TYPE numeric USING (value::numeric);
ALTER TABLE public.messages ALTER COLUMN gas_fee_cap TYPE numeric USING (gas_fee_cap::numeric);
ALTER TABLE public.messages ALTER COLUMN gas_premium TYPE numeric USING (gas_premium::numeric);
Expand Down Expand Up @@ -81,6 +91,16 @@ func init() {
;
`)
down := batch(`
ALTER TABLE public.derived_gas_outputs ALTER COLUMN value TYPE text USING (value::text);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN gas_fee_cap TYPE text USING (gas_fee_cap::text);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN gas_premium TYPE text USING (gas_premium::text);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN parent_base_fee TYPE text USING (parent_base_fee::text);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN base_fee_burn TYPE text USING (base_fee_burn::text);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN over_estimation_burn TYPE text USING (over_estimation_burn::text);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN miner_penalty TYPE text USING (miner_penalty::text);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN miner_tip TYPE text USING (miner_tip::text);
ALTER TABLE public.derived_gas_outputs ALTER COLUMN refund TYPE text USING (refund::text);
ALTER TABLE public.messages ALTER COLUMN value TYPE text USING (value::text);
ALTER TABLE public.messages ALTER COLUMN gas_fee_cap TYPE text USING (gas_fee_cap::text);
ALTER TABLE public.messages ALTER COLUMN gas_premium TYPE text USING (gas_premium::text);
Expand Down

0 comments on commit 853cfce

Please sign in to comment.