<p>I was able to fix this by re-running the db migration <code>cardano-db-tool run-migrations --mdir /cardano-db-sync/schema/</code></p>

CC BY-SA 4.0
2023-01-06T17:10:35.707Z
2023-01-06T17:10:35.707Z
relik
<p>I'm currently running <code>cardano-node</code> version 1.35.0 and <code>rosetta-server</code> 1.8.2. The node is synced and I have blocks in postgres, however each query to rosetta throws an error:</p>
<pre><code>curl -vvv -X POST 'http://&lt;node-url&gt;:8080/network/status' -H 'Content-Type: application/json' -d '{&quot;network_identifier&quot;: {&quot;blockchain&quot;: &quot;cardano&quot;, &quot;network&quot;: &quot;mainnet&quot;}}' | jq

{
  &quot;code&quot;: 5000,
  &quot;message&quot;: &quot;An error occurred&quot;,
  &quot;retriable&quot;: true,
  &quot;details&quot;: {
    &quot;message&quot;: &quot;An error occurred for request 9149: column b.previous_id does not exist&quot;
  }
}
</code></pre>
<p>The log shows an issue with the query, specifically the join.</p>
<pre><code>2022-12-13T21:50:05Z 2022-12-13 21:50:05.011 UTC [11737] postgres@cexplorer STATEMENT:
2022-12-13T21:50:05Z    SELECT
2022-12-13T21:50:05Z      b.hash as hash,
2022-12-13T21:50:05Z      b.block_no as number,
2022-12-13T21:50:05Z      (b.time at time zone 'utc') as &quot;createdAt&quot;,
2022-12-13T21:50:05Z      CASE
2022-12-13T21:50:05Z        WHEN b2.block_no IS NOT NULL THEN b2.block_no
2022-12-13T21:50:05Z        WHEN b3.block_no IS NOT NULL THEN b3.block_no
2022-12-13T21:50:05Z        ELSE 0
2022-12-13T21:50:05Z      END AS &quot;previousBlockNumber&quot;,
2022-12-13T21:50:05Z      CASE
2022-12-13T21:50:05Z        WHEN b2.block_no IS NOT NULL THEN b2.hash
2022-12-13T21:50:05Z        WHEN b3.block_no IS NOT NULL THEN b3.hash
2022-12-13T21:50:05Z        WHEN b.block_no = 1 THEN b3.hash -- block 1
2022-12-13T21:50:05Z {&quot;level&quot;:50,&quot;time&quot;:1670968205012,&quot;pid&quot;:125,&quot;hostname&quot;:&quot;coin-node-ada-kilo-coin-node-ada-kilo-0&quot;,&quot;reqId&quot;:8544,&quot;length&quot;:112,&quot;name&quot;:&quot;error&quot;,&quot;severity&quot;:&quot;ERROR&quot;,&quot;code&quot;:&quot;42703&quot;,&quot;position&quot;:&quot;684&quot;,&quot;file&quot;:&quot;parse_relation.c&quot;,&quot;line&quot;:&quot;3393&quot;,&quot;routine&quot;:&quot;errorMissingColumn&quot;,&quot;msg&quot;:&quot;[errorHandler] An error ocurred and will be sent as response&quot;,&quot;stack&quot;:&quot;error: column b.previous_id does not exist\n    at Parser.parseErrorMessage (/cardano-rosetta-server/node_modules/pg-protocol/dist/parser.js:278:15)\n    at Parser.handlePacket (/cardano-rosetta-server/node_modules/pg-protocol/dist/parser.js:126:29)\n    at Parser.parse (/cardano-rosetta-server/node_modules/pg-protocol/dist/parser.js:39:38)\n    at Socket.&lt;anonymous&gt; (/cardano-rosetta-server/node_modules/pg-protocol/dist/index.js:8:42)\n    at Socket.emit (events.js:400:28)\n    at addChunk (internal/streams/readable.js:293:12)\n    at readableAddChunk (internal/streams/readable.js:267:9)\n    at Socket.Readable.push (internal/streams/readable.js:206:10)\n    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)&quot;,&quot;type&quot;:&quot;Error&quot;,&quot;v&quot;:1}
2022-12-13T21:50:05Z        ELSE b.hash -- genesis
2022-12-13T21:50:05Z      END AS &quot;previousBlockHash&quot;,
2022-12-13T21:50:05Z      b.tx_count as &quot;transactionsCount&quot;,
2022-12-13T21:50:05Z      s.description as &quot;createdBy&quot;,
2022-12-13T21:50:05Z      b.size as size,
2022-12-13T21:50:05Z      b.epoch_no as &quot;epochNo&quot;,
2022-12-13T21:50:05Z      b.slot_no as &quot;slotNo&quot;
2022-12-13T21:50:05Z    FROM
2022-12-13T21:50:05Z      block b
2022-12-13T21:50:05Z      LEFT JOIN slot_leader s ON b.slot_leader_id = s.id
2022-12-13T21:50:05Z      LEFT JOIN block b2 ON b.previous_id = b2.id
2022-12-13T21:50:05Z      LEFT JOIN block b3 ON b2.previous_id = b3.id
2022-12-13T21:50:05Z    WHERE
2022-12-13T21:50:05Z      b.block_no = $1 AND
2022-12-13T21:50:05Z      $2 = $2
2022-12-13T21:50:05Z    LIMIT 1
2022-12-13T21:50:05Z null
</code></pre>
<p>I'm using this Dockerfile: <a href="https://github.com/input-output-hk/cardano-rosetta/blob/master/Dockerfile" rel="nofollow noreferrer">https://github.com/input-output-hk/cardano-rosetta/blob/master/Dockerfile</a></p>
<p>I have tried syncing from scratch to no avail. Not sure what else I can do to make this work.</p>

<cardano-node><cardano-db-sync>
Column does not exist when querying Rosetta endpoint
# Column does not exist when querying Rosetta endpoint

(Asked by: username_0 on 2022-12-16)

I'm currently running cardano-node version 1.35.0 and rosetta-server 1.8.2. The node is synced and I have blocks in postgres, however each query to rosetta throws an error:
curl -vvv -X POST 'http://:8080/network/status' -H 'Content-Type: application/json' -d '{"network_identifier": {"blockchain": "cardano", "network": "mainnet"}}' | jq

{
  "code": 5000,
  "message": "An error occurred",
  "retriable": true,
  "details": {
    "message": "An error occurred for request 9149: column b.previous_id does not exist"
  }
}

The log shows an issue with the query, specifically the join.
2022-12-13T21:50:05Z 2022-12-13 21:50:05.011 UTC [11737] postgres@cexplorer STATEMENT:
2022-12-13T21:50:05Z    SELECT
2022-12-13T21:50:05Z      b.hash as hash,
2022-12-13T21:50:05Z      b.block_no as number,
2022-12-13T21:50:05Z      (b.time at time zone 'utc') as "createdAt",
2022-12-13T21:50:05Z      CASE
2022-12-13T21:50:05Z        WHEN b2.block_no IS NOT NULL THEN b2.block_no
2022-12-13T21:50:05Z        WHEN b3.block_no IS NOT NULL THEN b3.block_no
2022-12-13T21:50:05Z        ELSE 0
2022-12-13T21:50:05Z      END AS "previousBlockNumber",
2022-12-13T21:50:05Z      CASE
2022-12-13T21:50:05Z        WHEN b2.block_no IS NOT NULL THEN b2.hash
2022-12-13T21:50:05Z        WHEN b3.block_no IS NOT NULL THEN b3.hash
2022-12-13T21:50:05Z        WHEN b.block_no = 1 THEN b3.hash -- block 1
2022-12-13T21:50:05Z {"level":50,"time":1670968205012,"pid":125,"hostname":"coin-node-ada-kilo-coin-node-ada-kilo-0","reqId":8544,"length":112,"name":"error","severity":"ERROR","code":"42703","position":"684","file":"parse_relation.c","line":"3393","routine":"errorMissingColumn","msg":"[errorHandler] An error ocurred and will be sent as response","stack":"error: column b.previous_id does not exist\n    at Parser.parseErrorMessage (/cardano-rosetta-server/node_modules/pg-protocol/dist/parser.js:278:15)\n    at Parser.handlePacket (/cardano-rosetta-server/node_modules/pg-protocol/dist/parser.js:126:29)\n    at Parser.parse (/cardano-rosetta-server/node_modules/pg-protocol/dist/parser.js:39:38)\n    at Socket. (/cardano-rosetta-server/node_modules/pg-protocol/dist/index.js:8:42)\n    at Socket.emit (events.js:400:28)\n    at addChunk (internal/streams/readable.js:293:12)\n    at readableAddChunk (internal/streams/readable.js:267:9)\n    at Socket.Readable.push (internal/streams/readable.js:206:10)\n    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)","type":"Error","v":1}
2022-12-13T21:50:05Z        ELSE b.hash -- genesis
2022-12-13T21:50:05Z      END AS "previousBlockHash",
2022-12-13T21:50:05Z      b.tx_count as "transactionsCount",
2022-12-13T21:50:05Z      s.description as "createdBy",
2022-12-13T21:50:05Z      b.size as size,
2022-12-13T21:50:05Z      b.epoch_no as "epochNo",
2022-12-13T21:50:05Z      b.slot_no as "slotNo"
2022-12-13T21:50:05Z    FROM
2022-12-13T21:50:05Z      block b
2022-12-13T21:50:05Z      LEFT JOIN slot_leader s ON b.slot_leader_id = s.id
2022-12-13T21:50:05Z      LEFT JOIN block b2 ON b.previous_id = b2.id
2022-12-13T21:50:05Z      LEFT JOIN block b3 ON b2.previous_id = b3.id
2022-12-13T21:50:05Z    WHERE
2022-12-13T21:50:05Z      b.block_no = $1 AND
2022-12-13T21:50:05Z      $2 = $2
2022-12-13T21:50:05Z    LIMIT 1
2022-12-13T21:50:05Z null

I'm using this Dockerfile: https://github.com/input-output-hk/cardano-rosetta/blob/master/Dockerfile
I have tried syncing from scratch to no avail. Not sure what else I can do to make this work.

**Tags:** cardano-node, cardano-db-sync

---

## 1 answers

### Answer by username_0 on 2023-01-06. Score: 0 | Accepted answer

I was able to fix this by re-running the db migration `cardano-db-tool run-migrations --mdir /cardano-db-sync/schema/`


---

