Skip to content

Commit

Permalink
fix: make tx_total_size column nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Jan 26, 2025
1 parent ac7c41b commit e6faca8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
10 changes: 0 additions & 10 deletions migrations/1737567411419_block-tx-total-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,8 @@ exports.up = pgm => {
pgm.addColumn('blocks', {
tx_total_size: {
type: 'int',
notNull: true,
default: 0,
},
});
pgm.sql(`
UPDATE blocks
SET tx_total_size = (
SELECT SUM(OCTET_LENGTH(raw_tx))
FROM txs
WHERE index_block_hash = blocks.index_block_hash
)
`);
};

exports.down = pgm => {
Expand Down
6 changes: 3 additions & 3 deletions src/datastore/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface DbBlock {
execution_cost_runtime: number;
execution_cost_write_count: number;
execution_cost_write_length: number;
tx_total_size: number;
tx_total_size: number | null;
tx_count: number;
block_time: number;
signer_bitvec: string | null;
Expand Down Expand Up @@ -863,7 +863,7 @@ export interface BlockQueryResult {
execution_cost_runtime: string;
execution_cost_write_count: string;
execution_cost_write_length: string;
tx_total_size: number;
tx_total_size: number | null;
tx_count: number;
signer_bitvec: string | null;
tenure_height: number | null;
Expand Down Expand Up @@ -1289,7 +1289,7 @@ export interface BlockInsertValues {
execution_cost_runtime: number;
execution_cost_write_count: number;
execution_cost_write_length: number;
tx_total_size: number;
tx_total_size: number | null;
tx_count: number;
signer_bitvec: string | null;
signer_signatures: PgBytea[] | null;
Expand Down

0 comments on commit e6faca8

Please sign in to comment.