Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions migration/1779834163000-fixStaleSchemaCompat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
* @typedef {import('typeorm').QueryRunner} QueryRunner
*/

/**
* Fixes two stale-schema issues surfaced by an external sync client
* (POST /v1/support/db) that polls with hardcoded table/column names:
*
* 1. `asset` table was renamed to `asset_account` in migration
* 1715583133193-setupFrankencoinPay. The caller still queries
* `SELECT * FROM "asset"`. Fix: create a view alias.
*
* 2. `monitoring_balance.rootstockBalance` column exists but the caller
* sends it unquoted. Postgres case-folds unquoted identifiers to
* lowercase, so it looks for `rootstockbalance` which doesn't match
* the mixed-case `"rootstockBalance"`. The column is no longer used
* by the app (Rootstock integration removed in PR #124).
* Fix: rename to lowercase so both quoted and unquoted access work.
*
* See: https://github.com/LightningDotSpace/api/issues/192
*
* @class
* @implements {MigrationInterface}
*/
module.exports = class FixStaleSchemaCompat1779834163000 {
name = 'FixStaleSchemaCompat1779834163000'

/**
* @param {QueryRunner} queryRunner
*/
async up(queryRunner) {
await queryRunner.query(`CREATE VIEW "asset" AS SELECT * FROM "asset_account"`);
await queryRunner.query(`ALTER TABLE "monitoring_balance" RENAME COLUMN "rootstockBalance" TO "rootstockbalance"`);
}

/**
* @param {QueryRunner} queryRunner
*/
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "monitoring_balance" RENAME COLUMN "rootstockbalance" TO "rootstockBalance"`);
await queryRunner.query(`DROP VIEW "asset"`);
}
}
Loading