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
This commit is contained in:
Matthew Little
2023-01-13 20:38:08 +01:00
committed by GitHub
parent 3982bbca1c
commit d3fd685659
2 changed files with 17 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */
exports.up = pgm => {
pgm.alterColumn('pox_state', 'pox_v1_unlock_height', {
type: 'bigint'
});
}
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */
exports.down = pgm => {
pgm.alterColumn('pox_state', 'pox_v1_unlock_height', {
type: 'integer'
});
}

View File

@@ -351,7 +351,7 @@ export class PgStore {
}
async getPox1UnlockHeightInternal(sql: PgSqlClient): Promise<FoundOrNot<number>> {
const query = await sql<{ pox_v1_unlock_height: number }[]>`
const query = await sql<{ pox_v1_unlock_height: string }[]>`
SELECT pox_v1_unlock_height
FROM pox_state
LIMIt 1
@@ -359,7 +359,7 @@ export class PgStore {
if (query.length === 0) {
return { found: false };
}
const unlockHeight = query[0].pox_v1_unlock_height;
const unlockHeight = parseInt(query[0].pox_v1_unlock_height);
if (unlockHeight === 0) {
return { found: false };
}