From 44a2be6a4046024d807239e0e3a023cccb96b6eb Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Mon, 17 Jun 2024 09:11:14 -0600 Subject: [PATCH] fix: select correct block hash upon migration --- migrations/1718498685557_inscriptions-block-hash.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/migrations/1718498685557_inscriptions-block-hash.ts b/migrations/1718498685557_inscriptions-block-hash.ts index 4e1c6c1..8ad33f0 100644 --- a/migrations/1718498685557_inscriptions-block-hash.ts +++ b/migrations/1718498685557_inscriptions-block-hash.ts @@ -11,8 +11,12 @@ export function up(pgm: MigrationBuilder): void { }); pgm.sql(` UPDATE inscriptions SET block_hash = ( - SELECT block_hash FROM locations AS l WHERE l.ordinal_number = ordinal_number LIMIT 1 - ) + SELECT block_hash FROM locations AS l + WHERE l.ordinal_number = ordinal_number + AND l.block_height = block_height + AND l.tx_index = tx_index + LIMIT 1 + ) `); pgm.alterColumn('inscriptions', 'block_hash', { notNull: true }); }