Skip to content

Commit d3fd685

Browse files
authored
fix: use pg bigint for pox_v1_unlock_height column (#1521)
* fix: use pg bigint for `pox_v1_unlock_height` column * chore: pg down migration must be manually specified for alterColumn type * fix: `pox_v1_unlock_height` returns as string-quoted integer
1 parent 3982bbc commit d3fd685

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */
2+
exports.up = pgm => {
3+
4+
pgm.alterColumn('pox_state', 'pox_v1_unlock_height', {
5+
type: 'bigint'
6+
});
7+
8+
}
9+
10+
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */
11+
exports.down = pgm => {
12+
pgm.alterColumn('pox_state', 'pox_v1_unlock_height', {
13+
type: 'integer'
14+
});
15+
}

src/datastore/pg-store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,15 @@ export class PgStore {
351351
}
352352

353353
async getPox1UnlockHeightInternal(sql: PgSqlClient): Promise<FoundOrNot<number>> {
354-
const query = await sql<{ pox_v1_unlock_height: number }[]>`
354+
const query = await sql<{ pox_v1_unlock_height: string }[]>`
355355
SELECT pox_v1_unlock_height
356356
FROM pox_state
357357
LIMIt 1
358358
`;
359359
if (query.length === 0) {
360360
return { found: false };
361361
}
362-
const unlockHeight = query[0].pox_v1_unlock_height;
362+
const unlockHeight = parseInt(query[0].pox_v1_unlock_height);
363363
if (unlockHeight === 0) {
364364
return { found: false };
365365
}

0 commit comments

Comments
 (0)