From e6faca86778cae2126bad2feab31f71843516a24 Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Sun, 26 Jan 2025 16:41:31 -0600 Subject: [PATCH] fix: make tx_total_size column nullable --- migrations/1737567411419_block-tx-total-size.js | 10 ---------- src/datastore/common.ts | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/migrations/1737567411419_block-tx-total-size.js b/migrations/1737567411419_block-tx-total-size.js index d5d1eb6ea..ca710019e 100644 --- a/migrations/1737567411419_block-tx-total-size.js +++ b/migrations/1737567411419_block-tx-total-size.js @@ -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 => { diff --git a/src/datastore/common.ts b/src/datastore/common.ts index febef3250..78f1f0dd2 100644 --- a/src/datastore/common.ts +++ b/src/datastore/common.ts @@ -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; @@ -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; @@ -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;