mirror of
https://github.com/alexgo-io/stacks-blockchain-api.git
synced 2026-01-12 22:43:34 +08:00
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:
15
migrations/1673632140730_pox_state_fix.js
Normal file
15
migrations/1673632140730_pox_state_fix.js
Normal 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'
|
||||
});
|
||||
}
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user