File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
cardano-db/src/Cardano/Db/Statement Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -192,12 +192,13 @@ queryBlockNoAndEpochStmt =
192192 -- (where DrepDistr will be inserted). Using the previous block's epoch ensures
193193 -- DrepDistr for the current epoch gets deleted, preventing duplicates
194194 -- when replaying through the epoch boundary.
195+ -- For genesis (block 0), there's no previous block, so use the current epoch.
195196 sql =
196197 TextEnc. encodeUtf8 $
197198 Text. concat
198- [ " SELECT curr.id, prev.epoch_no"
199+ [ " SELECT curr.id, COALESCE( prev.epoch_no, curr.epoch_no) "
199200 , " FROM " <> tableName (Proxy @ a ) <> " curr"
200- , " JOIN " <> tableName (Proxy @ a ) <> " prev ON prev.block_no = $1 - 1"
201+ , " LEFT JOIN " <> tableName (Proxy @ a ) <> " prev ON prev.block_no = $1 - 1"
201202 , " WHERE curr.block_no = $1"
202203 ]
203204
You can’t perform that action at this time.
0 commit comments