@mojaloop/central-ledger 19.4.2 → 19.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [19.4.3](https://github.com/mojaloop/central-ledger/compare/v19.4.2...v19.4.3) (2025-04-07)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * migration script fix for updating existing databases ([#1163](https://github.com/mojaloop/central-ledger/issues/1163)) ([5f40ad5](https://github.com/mojaloop/central-ledger/commit/5f40ad52e603dd13fcb844568646476bf1adeb3a))
11
+
5
12
  ### [19.4.2](https://github.com/mojaloop/central-ledger/compare/v19.4.1...v19.4.2) (2025-04-07)
6
13
 
7
14
 
@@ -30,10 +30,27 @@
30
30
  'use strict'
31
31
 
32
32
  exports.up = async (knex) => {
33
- return await knex.schema.hasTable('participantPositionChange').then(function(exists) {
33
+ return await knex.schema.hasTable('participantPositionChange').then(async function(exists) {
34
34
  if (exists) {
35
- return knex.schema.alterTable('participantPositionChange', (t) => {
36
- t.integer('participantCurrencyId').unsigned().notNullable()
35
+ // Step 1: Add the column as nullable
36
+ await knex.schema.alterTable('participantPositionChange', (t) => {
37
+ t.integer('participantCurrencyId').unsigned()
38
+ })
39
+
40
+ // Step 2: Populate the column with participantCurrencyId from participantPosition
41
+ await knex('participantPositionChange')
42
+ .update({
43
+ participantCurrencyId: knex.raw(`
44
+ (SELECT pp.participantCurrencyId
45
+ FROM participantPosition pp
46
+ WHERE pp.participantPositionId = participantPositionChange.participantPositionId)
47
+ `)
48
+ })
49
+ .whereNull('participantCurrencyId')
50
+
51
+ // Step 3: Make it NOT NULL and add the foreign key
52
+ await knex.schema.alterTable('participantPositionChange', (t) => {
53
+ t.integer('participantCurrencyId').unsigned().notNullable().alter()
37
54
  t.foreign('participantCurrencyId').references('participantCurrencyId').inTable('participantCurrency')
38
55
  })
39
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/central-ledger",
3
- "version": "19.4.2",
3
+ "version": "19.4.3",
4
4
  "description": "Central ledger hosted by a scheme to record and settle transfers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",