Skip to content

Commit 77bd2f8

Browse files
authored
fix: make tx_total_size column nullable (#2207)
1 parent ac7c41b commit 77bd2f8

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

migrations/1737567411419_block-tx-total-size.js

-10
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,8 @@ exports.up = pgm => {
66
pgm.addColumn('blocks', {
77
tx_total_size: {
88
type: 'int',
9-
notNull: true,
10-
default: 0,
119
},
1210
});
13-
pgm.sql(`
14-
UPDATE blocks
15-
SET tx_total_size = (
16-
SELECT SUM(OCTET_LENGTH(raw_tx))
17-
FROM txs
18-
WHERE index_block_hash = blocks.index_block_hash
19-
)
20-
`);
2111
};
2212

2313
exports.down = pgm => {

src/datastore/common.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface DbBlock {
2222
execution_cost_runtime: number;
2323
execution_cost_write_count: number;
2424
execution_cost_write_length: number;
25-
tx_total_size: number;
25+
tx_total_size: number | null;
2626
tx_count: number;
2727
block_time: number;
2828
signer_bitvec: string | null;
@@ -863,7 +863,7 @@ export interface BlockQueryResult {
863863
execution_cost_runtime: string;
864864
execution_cost_write_count: string;
865865
execution_cost_write_length: string;
866-
tx_total_size: number;
866+
tx_total_size: number | null;
867867
tx_count: number;
868868
signer_bitvec: string | null;
869869
tenure_height: number | null;
@@ -1289,7 +1289,7 @@ export interface BlockInsertValues {
12891289
execution_cost_runtime: number;
12901290
execution_cost_write_count: number;
12911291
execution_cost_write_length: number;
1292-
tx_total_size: number;
1292+
tx_total_size: number | null;
12931293
tx_count: number;
12941294
signer_bitvec: string | null;
12951295
signer_signatures: PgBytea[] | null;

0 commit comments

Comments
 (0)