@mojaloop/central-ledger 9.2.2 → 15.1.3-snapshot.2
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/.circleci/config.yml +625 -204
- package/.env +3 -2
- package/.ncurc.yaml +9 -0
- package/.nvmrc +1 -1
- package/.versionrc +15 -0
- package/CHANGELOG.md +353 -0
- package/CODEOWNERS +31 -0
- package/Dockerfile +20 -14
- package/LICENSE.md +4 -4
- package/Onboarding.md +0 -7
- package/README.md +99 -22
- package/audit-resolve.json +136 -1
- package/config/default.json +82 -27
- package/docker/central-ledger/default.json +68 -21
- package/docker/ml-api-adapter/default.json +10 -1
- package/docker/wait-for/wait-for-objstore.sh +1 -6
- package/docker/wait-for/wait-for.env +1 -1
- package/docker-compose.integration.yml +8 -5
- package/docker-compose.yml +73 -16
- package/migrations/310203_transferParticipant-indexes.js +38 -0
- package/migrations/310503_participantLimit-indexes-composite.js +38 -0
- package/migrations/{400401_settlementWindowStateChange-indexes.js → 400401_settlmentWindowStateChange-indexes.js} +0 -0
- package/migrations/401301_settlementModel-indexes.js +2 -0
- package/migrations/500401_quote-hotfix-2719.js +58 -0
- package/migrations/500501_feature-fixSubIdRef.js +53 -0
- package/migrations/500601_party-2480.js +63 -0
- package/migrations/501001_quoteExtension-quote-service-174.js +46 -0
- package/migrations/501002_quoteExtension-2522.js +61 -0
- package/migrations/800101_feature-fixSubIdRef.js +90 -0
- package/migrations/910102_hotfix954.js +4 -1
- package/migrations/940100_quotePartyIdInfoExtension.js +52 -0
- package/migrations/940101_quotePartyIdInfoExtension-2522.js +64 -0
- package/migrations/950100_settlementContentAggregation-decimal184.js +40 -0
- package/migrations/950101_transferParticipantStateChange.js +46 -0
- package/migrations/950102_settlementModel-adjustPosition.js +42 -0
- package/migrations/950103_dropTransferParticipantStateChange.js +47 -0
- package/migrations/950104_settlementModel-settlementAccountTypeId.js +79 -0
- package/migrations/950106_unique_settlement_model_ledger_account_currency.js +38 -0
- package/migrations/950107_settlementWindowContent_foreign_settlementModel.js +60 -0
- package/package.json +99 -81
- package/scripts/_wait4_all.js +146 -0
- package/seeds/amountType.js +4 -6
- package/seeds/balanceOfPayments.js +4 -6
- package/seeds/bulkProcessingState.js +4 -6
- package/seeds/bulkTransferState.js +4 -6
- package/seeds/currency.js +4 -6
- package/seeds/endpointType.js +128 -7
- package/seeds/ledgerAccountType.js +11 -10
- package/seeds/ledgerEntryType.js +5 -7
- package/seeds/participant.js +4 -6
- package/seeds/participantLimitType.js +4 -6
- package/seeds/partyIdentifierType.js +4 -6
- package/seeds/partyType.js +4 -6
- package/seeds/settlementDelay.js +4 -6
- package/seeds/settlementGranularity.js +4 -6
- package/seeds/settlementInterchange.js +4 -6
- package/seeds/settlementState.js +4 -6
- package/seeds/settlementWindow1State.js +4 -6
- package/seeds/transactionInitiator.js +4 -6
- package/seeds/transactionInitiatorType.js +4 -6
- package/seeds/transactionScenario.js +4 -6
- package/seeds/transferParticipantRoleType.js +4 -6
- package/seeds/transferState.js +9 -6
- package/src/api/interface/swagger.json +728 -948
- package/src/api/ledgerAccountTypes/handler.js +55 -0
- package/src/api/ledgerAccountTypes/routes.js +63 -0
- package/src/api/metrics/handler.js +2 -2
- package/src/api/metrics/routes.js +1 -1
- package/src/api/participants/handler.js +43 -35
- package/src/api/participants/routes.js +13 -13
- package/src/api/root/routes.js +2 -2
- package/src/api/settlementModels/handler.js +9 -26
- package/src/api/settlementModels/routes.js +4 -4
- package/src/api/transactions/handler.js +46 -0
- package/src/api/transactions/routes.js +45 -0
- package/src/domain/bulkTransfer/index.js +6 -5
- package/src/domain/ledgerAccountTypes/index.js +58 -0
- package/src/domain/participant/index.js +55 -4
- package/src/domain/position/index.js +18 -2
- package/src/domain/settlement/index.js +39 -6
- package/src/domain/transactions/index.js +61 -0
- package/src/domain/transfer/index.js +22 -2
- package/src/domain/transfer/transform.js +3 -3
- package/src/handlers/admin/handler.js +24 -32
- package/src/handlers/bulk/fulfil/handler.js +89 -56
- package/src/handlers/bulk/get/handler.js +203 -0
- package/src/handlers/bulk/index.js +4 -1
- package/src/handlers/bulk/prepare/handler.js +30 -29
- package/src/handlers/bulk/processing/handler.js +61 -32
- package/src/handlers/bulk/shared/validator.js +13 -1
- package/src/handlers/index.js +18 -9
- package/src/handlers/positions/handler.js +67 -46
- package/src/handlers/register.js +7 -7
- package/src/handlers/timeouts/handler.js +9 -4
- package/src/handlers/transfers/handler.js +408 -182
- package/src/handlers/transfers/validator.js +41 -11
- package/src/lib/cache.js +8 -34
- package/src/lib/config.js +5 -7
- package/src/lib/enum.js +22 -22
- package/src/lib/enumCached.js +76 -0
- package/src/lib/healthCheck/subServiceHealth.js +2 -2
- package/src/lib/requestLogger.js +9 -9
- package/src/lib/urlParser.js +1 -1
- package/src/models/bulkTransfer/bulkTransfer.js +6 -6
- package/src/models/bulkTransfer/bulkTransferAssociation.js +3 -3
- package/src/models/bulkTransfer/bulkTransferDuplicateCheck.js +4 -4
- package/src/models/bulkTransfer/bulkTransferExtension.js +2 -2
- package/src/models/bulkTransfer/bulkTransferFulfilmentDuplicateCheck.js +4 -4
- package/src/models/bulkTransfer/bulkTransferStateChange.js +7 -7
- package/src/models/bulkTransfer/facade.js +54 -3
- package/src/models/bulkTransfer/individualTransfer.js +2 -2
- package/src/models/ilpPackets/ilpPacket.js +36 -0
- package/src/models/ledgerAccountType/ledgerAccountType.js +139 -3
- package/src/models/misc/migrationLock.js +1 -1
- package/src/models/misc/segment.js +1 -1
- package/src/models/participant/facade.js +226 -76
- package/src/models/participant/participant.js +6 -5
- package/src/models/participant/participantCached.js +8 -0
- package/src/models/participant/participantCurrency.js +7 -7
- package/src/models/participant/participantCurrencyCached.js +11 -1
- package/src/models/participant/participantLimit.js +13 -13
- package/src/models/participant/participantLimitCached.js +124 -0
- package/src/models/participant/participantPosition.js +34 -5
- package/src/models/participant/participantPositionChange.js +10 -2
- package/src/models/position/facade.js +112 -18
- package/src/models/position/participantPosition.js +6 -6
- package/src/models/settlement/settlementModel.js +92 -17
- package/src/models/settlement/settlementModelCached.js +139 -0
- package/src/models/transfer/facade.js +97 -32
- package/src/models/transfer/ilpPacket.js +4 -4
- package/src/models/transfer/transfer.js +7 -7
- package/src/models/transfer/transferDuplicateCheck.js +21 -5
- package/src/models/transfer/transferError.js +5 -5
- package/src/models/transfer/transferErrorDuplicateCheck.js +4 -4
- package/src/models/transfer/transferExtension.js +4 -4
- package/src/models/transfer/transferFulfilment.js +5 -5
- package/src/models/transfer/transferFulfilmentDuplicateCheck.js +4 -4
- package/src/models/transfer/transferParticipant.js +3 -3
- package/src/models/transfer/transferStateChange.js +11 -11
- package/src/models/transfer/transferTimeout.js +5 -5
- package/src/schema/bulkTransfer.js +4 -4
- package/src/shared/plugins.js +10 -9
- package/src/shared/setup.js +69 -46
- package/test/integration/domain/participant/index.test.js +2 -0
- package/test/integration/handlers/handlers.test.js +605 -166
- package/test/integration/handlers/root.test.js +1 -1
- package/test/integration/helpers/hubAccounts.js +62 -0
- package/test/integration/helpers/ilpPacket.js +1 -1
- package/test/integration/helpers/participantFundsInOut.js +80 -0
- package/test/integration/helpers/participantLimit.js +6 -1
- package/test/integration/helpers/settlementModels.js +88 -0
- package/test/integration/helpers/testConsumer.js +163 -0
- package/test/integration/helpers/testProducer.js +0 -1
- package/test/integration/helpers/transferDuplicateCheck.js +1 -1
- package/test/integration/helpers/transferStateChange.js +1 -1
- package/test/integration/helpers/transferTestHelper.js +3 -5
- package/test/integration/models/transfer/transferStateChange.test.js +6 -0
- package/test/unit/api/ledgerAccountTypes/handler.test.js +126 -0
- package/test/unit/api/ledgerAccountTypes/routes.test.js +52 -0
- package/test/unit/api/participants/handler.test.js +75 -33
- package/test/unit/api/root/handler.test.js +1 -1
- package/test/unit/api/root/routes.test.js +2 -2
- package/test/unit/api/settlementModels/handler.test.js +21 -57
- package/test/unit/api/transactions/handler.test.js +108 -0
- package/test/unit/api/transactions/routes.test.js +38 -0
- package/test/unit/domain/ledgerAccountTypes/index.test.js +197 -0
- package/test/unit/domain/participant/index.test.js +115 -2
- package/test/unit/domain/settlement/index.test.js +199 -29
- package/test/unit/domain/transactions/index.test.js +128 -0
- package/test/unit/domain/transfer/index.test.js +1 -0
- package/test/unit/domain/transfer/transform.test.js +2 -0
- package/test/unit/handlers/admin/handler.test.js +5 -5
- package/test/unit/handlers/bulk/get/handler.test.js +401 -0
- package/test/unit/handlers/index.test.js +6 -0
- package/test/unit/handlers/positions/handler.test.js +26 -0
- package/test/unit/handlers/register.test.js +2 -0
- package/test/unit/handlers/transfers/handler.test.js +491 -36
- package/test/unit/handlers/transfers/validator.test.js +31 -31
- package/test/unit/lib/cache.test.js +0 -64
- package/test/unit/lib/cachingOfEnums.test.js +121 -0
- package/test/unit/lib/config.test.js +34 -0
- package/test/unit/lib/enum.test.js +6 -1
- package/test/unit/lib/enumCached.test.js +82 -0
- package/test/unit/lib/healthCheck/subServiceHealth.test.js +2 -0
- package/test/unit/lib/requestLogger.test.js +14 -12
- package/test/unit/models/ilpPackets/ilpPacket.test.js +89 -0
- package/test/unit/models/ledgerAccountType/ledgerAccountType.test.js +255 -6
- package/test/unit/models/misc/migrationLock.test.js +4 -0
- package/test/unit/models/misc/segment.test.js +5 -0
- package/test/unit/models/participant/facade.test.js +493 -54
- package/test/unit/models/participant/participant.test.js +4 -0
- package/test/unit/models/participant/participantCurrency.test.js +22 -9
- package/test/unit/models/participant/participantCurrencyCached.test.js +1 -1
- package/test/unit/models/participant/participantLimit.test.js +97 -0
- package/test/unit/models/participant/participantLimitCached.test.js +232 -0
- package/test/unit/models/participant/participantPosition.test.js +217 -0
- package/test/unit/models/participant/participantPositionChange.test.js +3 -0
- package/test/unit/models/position/facade.test.js +318 -29
- package/test/unit/models/position/participantPosition.test.js +22 -7
- package/test/unit/models/settlement/settlementModel.test.js +18 -37
- package/test/unit/models/settlement/settlementModelCached.test.js +171 -0
- package/test/unit/models/transfer/facade.test.js +115 -0
- package/test/unit/models/transfer/ilpPacket.test.js +28 -11
- package/test/unit/models/transfer/transfer.test.js +13 -4
- package/test/unit/models/transfer/transferDuplicateCheck.test.js +4 -0
- package/test/unit/models/transfer/transferError.test.js +5 -1
- package/test/unit/models/transfer/transferErrorDuplicateCheck.test.js +4 -0
- package/test/unit/models/transfer/transferExtension.test.js +26 -9
- package/test/unit/models/transfer/transferFulfilment.test.js +14 -5
- package/test/unit/models/transfer/transferFulfilmentDuplicateCheck.test.js +4 -0
- package/test/unit/models/transfer/transferParticipant.test.js +14 -5
- package/test/unit/models/transfer/transferStateChange.test.js +3 -0
- package/test/unit/models/transfer/transferTimeout.test.js +6 -0
- package/test/unit/seeds/amountType.test.js +6 -22
- package/test/unit/seeds/balanceOfPayments.test.js +6 -22
- package/test/unit/seeds/bulkProcessingState.test.js +84 -0
- package/test/unit/{lib/sidecar/nullClient.test.js → seeds/bulkTransferState.test.js} +36 -39
- package/test/unit/seeds/currency.test.js +6 -22
- package/test/unit/seeds/endpointType.test.js +6 -22
- package/test/unit/seeds/ledgerAccountType.test.js +5 -22
- package/test/unit/seeds/ledgerEntryType.test.js +6 -22
- package/test/unit/seeds/participant.test.js +5 -22
- package/test/unit/seeds/participantLimitType.test.js +6 -22
- package/test/unit/seeds/partyIdentifierType.test.js +6 -22
- package/test/unit/seeds/partyType.test.js +6 -22
- package/test/unit/seeds/settlementState.test.js +5 -22
- package/test/unit/seeds/settlementWindow1State.test.js +5 -22
- package/test/unit/seeds/transactionInitiator.test.js +6 -22
- package/test/unit/seeds/transactionInitiatorType.test.js +6 -22
- package/test/unit/seeds/transactionScenario.test.js +6 -22
- package/test/unit/seeds/transferParticipantRoleType.test.js +6 -22
- package/test/unit/seeds/transferState.test.js +6 -22
- package/test/unit/shared/plugins.test.js +31 -1
- package/test/unit/shared/setup.test.js +25 -36
- package/test/util/helpers.js +37 -2
- package/test/util/randomTransfers.js +1 -1
- package/test/util/scripts/env.sh +6 -5
- package/test/util/scripts/populateTestData.sh +204 -181
- package/test/util/scripts/populateTestDataForLegacySimulator.sh +261 -0
- package/test/util/scripts/restartObjStore.sh +1 -1
- package/test-integration.Dockerfile +15 -15
- package/test.Dockerfile +12 -12
- package/.circleci/_set_up_deploy_envs.sh +0 -47
- package/.dockerignore +0 -17
- package/.ncurc.json +0 -3
- package/server.sh +0 -4
- package/sonar-project.properties +0 -17
- package/src/lib/sidecar/index.js +0 -47
- package/src/lib/sidecar/nullClient.js +0 -18
- package/test/.env +0 -8
- package/test/integration-config.json +0 -367
- package/test/integration-runner.env +0 -31
- package/test/integration-runner.sh +0 -264
- package/test/spec-runner.sh +0 -132
- package/test/unit/lib/sidecar/index.test.js +0 -148
- package/test/unit/models/position/participantLimit.test.js +0 -135
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
|
|
9
|
+
Contributors
|
|
10
|
+
--------------
|
|
11
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
12
|
+
Names of the original copyright holders (individuals or organizations)
|
|
13
|
+
should be listed with a '*' in the first column. People who have
|
|
14
|
+
contributed from an organization can be listed under the organization
|
|
15
|
+
that actually holds the copyright for their contributions (see the
|
|
16
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
17
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
18
|
+
optionally within square brackets <email>.
|
|
19
|
+
* Gates Foundation
|
|
20
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
21
|
+
|
|
22
|
+
* ModusBox
|
|
23
|
+
- Miguel de Barros <miguel.debarros@modusbox.com>
|
|
24
|
+
--------------
|
|
25
|
+
******/
|
|
26
|
+
|
|
27
|
+
// Notes: these changes are required for the quoting-service and are not used by central-ledger
|
|
28
|
+
// This implements [Central-ledger migration scripts should configure the Quote Party table to utf8 character set #2480](https://github.com/mojaloop/project/issues/2480)
|
|
29
|
+
// Referencing for MySQL Documentation: https://dev.mysql.com/doc/refman/5.6/en/alter-table.html#alter-table-character-set
|
|
30
|
+
'use strict'
|
|
31
|
+
|
|
32
|
+
const characterSet = 'utf8mb4'
|
|
33
|
+
const coalition = 'utf8mb4_unicode_ci'
|
|
34
|
+
|
|
35
|
+
exports.up = async (knex) => {
|
|
36
|
+
console.log(`WARNING: Migration script 500601_party-2480.js is converting PARTY table to use the following character set ${characterSet} with ${coalition} collation`)
|
|
37
|
+
return knex.schema.hasTable('party').then(async (exists) => {
|
|
38
|
+
if (exists) {
|
|
39
|
+
try {
|
|
40
|
+
const result = await knex.select(knex.raw(`
|
|
41
|
+
CCSA.character_set_name, CCSA.collation_name
|
|
42
|
+
FROM information_schema.TABLES T,
|
|
43
|
+
information_schema.COLLATION_CHARACTER_SET_APPLICABILITY CCSA
|
|
44
|
+
WHERE CCSA.collation_name = T.table_collation
|
|
45
|
+
AND T.table_name = "party";
|
|
46
|
+
`))
|
|
47
|
+
console.log(`WARNING: Migration script 500601_party-2480.js - take note of the current configuration if you wish to revert= ${JSON.stringify(result)}`)
|
|
48
|
+
await knex.raw(`
|
|
49
|
+
ALTER TABLE party CONVERT TO CHARACTER
|
|
50
|
+
SET ${characterSet} COLLATE ${coalition}
|
|
51
|
+
`)
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.log(`ERROR: Migration script 500601_party-2480.js - converting PARTY table to use the following character set ${characterSet} with ${coalition} collation has failed!`)
|
|
54
|
+
console.error(err)
|
|
55
|
+
throw err
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.down = (knex) => {
|
|
62
|
+
console.log('WARNING: Migration script 500601_party-2480.js must manually be reversed')
|
|
63
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Gates Foundation
|
|
19
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
20
|
+
|
|
21
|
+
* ModusBox
|
|
22
|
+
- James Bush <james.bush@modusbox.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = async (knex) => {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Make quoteResponseId column on quoteExtension table nullable.
|
|
32
|
+
* This change comes from quote-service issue #174
|
|
33
|
+
*/
|
|
34
|
+
return await knex.schema.hasTable('quoteExtension').then(function(exists) {
|
|
35
|
+
if (exists) {
|
|
36
|
+
return knex.schema.alterTable('quoteExtension', (t) => {
|
|
37
|
+
t.bigInteger('quoteResponseId').unsigned().nullable().alter()
|
|
38
|
+
t.string('transactionId', 36).nullable().comment('The transaction reference that is part of the initial quote').alter()
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.down = function (knex) {
|
|
45
|
+
return knex.schema.dropTableIfExists('quoteExtension')
|
|
46
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
|
|
9
|
+
Contributors
|
|
10
|
+
--------------
|
|
11
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
12
|
+
Names of the original copyright holders (individuals or organizations)
|
|
13
|
+
should be listed with a '*' in the first column. People who have
|
|
14
|
+
contributed from an organization can be listed under the organization
|
|
15
|
+
that actually holds the copyright for their contributions (see the
|
|
16
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
17
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
18
|
+
optionally within square brackets <email>.
|
|
19
|
+
* Gates Foundation
|
|
20
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
21
|
+
|
|
22
|
+
* ModusBox
|
|
23
|
+
- Miguel de Barros <miguel.debarros@modusbox.com>
|
|
24
|
+
--------------
|
|
25
|
+
******/
|
|
26
|
+
|
|
27
|
+
// Notes: these changes are required for the quoting-service and are not used by central-ledger
|
|
28
|
+
// This implements [Central-ledger migration scripts should configure the Quote Party table to utf8 follow-up #2522](https://github.com/mojaloop/project/issues/2522)
|
|
29
|
+
// Referencing for MySQL Documentation: https://dev.mysql.com/doc/refman/5.6/en/alter-table.html#alter-table-character-set
|
|
30
|
+
'use strict'
|
|
31
|
+
|
|
32
|
+
const characterSet = 'utf8mb4'
|
|
33
|
+
const coalition = 'utf8mb4_unicode_ci'
|
|
34
|
+
|
|
35
|
+
exports.up = async (knex) => {
|
|
36
|
+
console.log(`WARNING: Migration script 501002_quoteExtension-2522.js is converting quoteExtension 'value' column to use the following character set ${characterSet} with ${coalition} collation`)
|
|
37
|
+
return knex.schema.hasTable('quoteExtension').then(async (exists) => {
|
|
38
|
+
if (exists) {
|
|
39
|
+
try {
|
|
40
|
+
const result = await knex.select(knex.raw(`
|
|
41
|
+
table_name, column_name, character_set_name, collation_name
|
|
42
|
+
FROM information_schema.COLUMNS
|
|
43
|
+
WHERE table_name = 'quoteExtension' AND column_name = 'value';
|
|
44
|
+
`))
|
|
45
|
+
console.log(`WARNING: Migration script 501002_quoteExtension-2522.js - take note of the current configuration if you wish to revert= ${JSON.stringify(result)}`)
|
|
46
|
+
await knex.raw(`
|
|
47
|
+
ALTER TABLE quoteExtension
|
|
48
|
+
CHANGE COLUMN \`value\` \`value\` TEXT CHARACTER SET '${characterSet}' COLLATE '${coalition}' NOT NULL;
|
|
49
|
+
`)
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.log(`ERROR: Migration script 501002_quoteExtension-2522.js - converting quoteExtension 'value' column to use the following character set ${characterSet} with ${coalition} collation has failed!`)
|
|
52
|
+
console.error(err)
|
|
53
|
+
throw err
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.down = (knex) => {
|
|
60
|
+
console.log('WARNING: Migration script 501002_quoteExtension-2522.js must manually be reversed')
|
|
61
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
|
|
9
|
+
Initial contribution
|
|
10
|
+
--------------------
|
|
11
|
+
The initial functionality and code base was donated by the Mowali project working in conjunction with MTN and Orange as service provides.
|
|
12
|
+
* Project: Mowali
|
|
13
|
+
|
|
14
|
+
Contributors
|
|
15
|
+
--------------
|
|
16
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
17
|
+
Names of the original copyright holders (individuals or organizations)
|
|
18
|
+
should be listed with a '*' in the first column. People who have
|
|
19
|
+
contributed from an organization can be listed under the organization
|
|
20
|
+
that actually holds the copyright for their contributions (see the
|
|
21
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
22
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
23
|
+
optionally within square brackets <email>.
|
|
24
|
+
* Gates Foundation
|
|
25
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
26
|
+
|
|
27
|
+
* ModusBox
|
|
28
|
+
- Vijay Kumar Guthi <vijaya.guthi@modusbox.com>
|
|
29
|
+
--------------
|
|
30
|
+
******/
|
|
31
|
+
|
|
32
|
+
// Notes: these changes are required for the quoting-service and are not used by central-ledger
|
|
33
|
+
'use strict'
|
|
34
|
+
|
|
35
|
+
exports.up = function (knex) {
|
|
36
|
+
return knex.raw(`
|
|
37
|
+
CREATE OR REPLACE VIEW quotePartyView AS
|
|
38
|
+
SELECT
|
|
39
|
+
qp.quoteId AS quoteId,
|
|
40
|
+
qp.quotePartyId AS quotePartyId,
|
|
41
|
+
pt.name AS partyType,
|
|
42
|
+
pit.name AS identifierType,
|
|
43
|
+
qp.partyIdentifierValue,
|
|
44
|
+
qp.partySubIdOrTypeId AS partySubIdOrType,
|
|
45
|
+
qp.fspId AS fspId,
|
|
46
|
+
qp.merchantClassificationCode AS merchantClassificationCode,
|
|
47
|
+
qp.partyName AS partyName,
|
|
48
|
+
p.firstName AS firstName,
|
|
49
|
+
p.lastName AS lastName,
|
|
50
|
+
p.middleName AS middleName,
|
|
51
|
+
p.dateOfBirth AS dateOfBirth,
|
|
52
|
+
gc.longitude,
|
|
53
|
+
gc.latitude
|
|
54
|
+
FROM
|
|
55
|
+
quoteParty qp
|
|
56
|
+
INNER JOIN partyType pt ON pt.partyTypeId = qp.partyTypeId
|
|
57
|
+
INNER JOIN partyIdentifierType pit ON pit.partyIdentifierTypeId = qp.partyIdentifierTypeId
|
|
58
|
+
LEFT JOIN party p ON p.quotePartyId = qp.quotePartyId
|
|
59
|
+
LEFT JOIN geoCode gc ON gc.quotePartyId = qp.quotePartyId
|
|
60
|
+
`)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports.down = async function(knex) {
|
|
64
|
+
return knex.raw(`
|
|
65
|
+
CREATE OR REPLACE VIEW quotePartyView AS
|
|
66
|
+
SELECT
|
|
67
|
+
qp.quoteId AS quoteId,
|
|
68
|
+
qp.quotePartyId AS quotePartyId,
|
|
69
|
+
pt.name AS partyType,
|
|
70
|
+
pit.name AS identifierType,
|
|
71
|
+
qp.partyIdentifierValue,
|
|
72
|
+
spit.name AS partySubIdOrType,
|
|
73
|
+
qp.fspId AS fspId,
|
|
74
|
+
qp.merchantClassificationCode AS merchantClassificationCode,
|
|
75
|
+
qp.partyName AS partyName,
|
|
76
|
+
p.firstName AS firstName,
|
|
77
|
+
p.lastName AS lastName,
|
|
78
|
+
p.middleName AS middleName,
|
|
79
|
+
p.dateOfBirth AS dateOfBirth,
|
|
80
|
+
gc.longitude,
|
|
81
|
+
gc.latitude
|
|
82
|
+
FROM
|
|
83
|
+
quoteParty qp
|
|
84
|
+
INNER JOIN partyType pt ON pt.partyTypeId = qp.partyTypeId
|
|
85
|
+
INNER JOIN partyIdentifierType pit ON pit.partyIdentifierTypeId = qp.partyIdentifierTypeId
|
|
86
|
+
LEFT JOIN party p ON p.quotePartyId = qp.quotePartyId
|
|
87
|
+
LEFT JOIN partyIdentifierType spit ON spit.partyIdentifierTypeId = qp.partySubIdOrTypeId
|
|
88
|
+
LEFT JOIN geoCode gc ON gc.quotePartyId = qp.quotePartyId
|
|
89
|
+
`)
|
|
90
|
+
}
|
|
@@ -33,5 +33,8 @@ exports.up = async (knex, Promise) => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
exports.down = function (knex) {
|
|
36
|
-
return knex.schema.
|
|
36
|
+
return knex.schema.table('transferError', (t) => {
|
|
37
|
+
// Undo dropping of foreign key
|
|
38
|
+
t.foreign('transferId').references('transferId').inTable('transferErrorDuplicateCheck')
|
|
39
|
+
})
|
|
37
40
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
|
|
9
|
+
Initial contribution
|
|
10
|
+
--------------------
|
|
11
|
+
The initial functionality and code base was donated by the Mowali project working in conjunction with MTN and Orange as service provides.
|
|
12
|
+
* Project: Mowali
|
|
13
|
+
|
|
14
|
+
Contributors
|
|
15
|
+
--------------
|
|
16
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
17
|
+
Names of the original copyright holders (individuals or organizations)
|
|
18
|
+
should be listed with a '*' in the first column. People who have
|
|
19
|
+
contributed from an organization can be listed under the organization
|
|
20
|
+
that actually holds the copyright for their contributions (see the
|
|
21
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
22
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
23
|
+
optionally within square brackets <email>.
|
|
24
|
+
* Gates Foundation
|
|
25
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
26
|
+
|
|
27
|
+
* ModusBox
|
|
28
|
+
- Lazola Lucas <lazola.lucas@modusbox.com>
|
|
29
|
+
--------------
|
|
30
|
+
******/
|
|
31
|
+
|
|
32
|
+
// Notes: these changes are required for the quoting-service and are not used by central-ledger
|
|
33
|
+
'use strict'
|
|
34
|
+
|
|
35
|
+
exports.up = (knex) => {
|
|
36
|
+
return knex.schema.hasTable('quotePartyIdInfoExtension').then((exists) => {
|
|
37
|
+
if (!exists) {
|
|
38
|
+
return knex.schema.createTable('quotePartyIdInfoExtension', (t) => {
|
|
39
|
+
t.bigIncrements('quotePartyIdInfoExtensionId').primary().notNullable()
|
|
40
|
+
t.bigInteger('quotePartyId').unsigned().notNullable().comment('quotePartyId: a common id between the tables quotePartyIdInfoExtension and quoteParty')
|
|
41
|
+
t.foreign('quotePartyId').references('quotePartyId').inTable('quoteParty')
|
|
42
|
+
t.string('key', 128).notNullable()
|
|
43
|
+
t.text('value').notNullable()
|
|
44
|
+
t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable().comment('System dateTime stamp pertaining to the inserted record')
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exports.down = (knex) => {
|
|
51
|
+
return knex.schema.dropTableIfExists('quotePartyIdInfoExtension')
|
|
52
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
|
|
9
|
+
Contributors
|
|
10
|
+
--------------
|
|
11
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
12
|
+
Names of the original copyright holders (individuals or organizations)
|
|
13
|
+
should be listed with a '*' in the first column. People who have
|
|
14
|
+
contributed from an organization can be listed under the organization
|
|
15
|
+
that actually holds the copyright for their contributions (see the
|
|
16
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
17
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
18
|
+
optionally within square brackets <email>.
|
|
19
|
+
* Gates Foundation
|
|
20
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
21
|
+
|
|
22
|
+
* ModusBox
|
|
23
|
+
- Miguel de Barros <miguel.debarros@modusbox.com>
|
|
24
|
+
--------------
|
|
25
|
+
******/
|
|
26
|
+
|
|
27
|
+
// Notes: these changes are required for the quoting-service and are not used by central-ledger
|
|
28
|
+
// This implements [Central-ledger migration scripts should configure the Quote Party table to utf8 follow-up #2522](https://github.com/mojaloop/project/issues/2522)
|
|
29
|
+
// Referencing for MySQL Documentation: https://dev.mysql.com/doc/refman/5.6/en/alter-table.html#alter-table-character-set
|
|
30
|
+
'use strict'
|
|
31
|
+
|
|
32
|
+
const characterSet = 'utf8mb4'
|
|
33
|
+
const coalition = 'utf8mb4_unicode_ci'
|
|
34
|
+
|
|
35
|
+
exports.up = async (knex) => {
|
|
36
|
+
console.log(`WARNING: Migration script 940101_quotePartyIdInfoExtension-2522.js is converting quotePartyIdInfoExtension table to use the following character set ${characterSet} with ${coalition} collation`)
|
|
37
|
+
return knex.schema.hasTable('quotePartyIdInfoExtension').then(async (exists) => {
|
|
38
|
+
if (exists) {
|
|
39
|
+
try {
|
|
40
|
+
const result = await knex.select(knex.raw(`
|
|
41
|
+
CCSA.character_set_name, CCSA.collation_name
|
|
42
|
+
FROM information_schema.TABLES T,
|
|
43
|
+
information_schema.COLLATION_CHARACTER_SET_APPLICABILITY CCSA
|
|
44
|
+
WHERE CCSA.collation_name = T.table_collation
|
|
45
|
+
AND T.table_name = "quotePartyIdInfoExtension";
|
|
46
|
+
`))
|
|
47
|
+
console.log(`WARNING: Migration script 940101_quotePartyIdInfoExtension-2522.js - take note of the current configuration if you wish to revert= ${JSON.stringify(result)}`)
|
|
48
|
+
await knex.raw(`
|
|
49
|
+
ALTER TABLE quotePartyIdInfoExtension CONVERT TO CHARACTER
|
|
50
|
+
SET ${characterSet} COLLATE ${coalition}
|
|
51
|
+
`)
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.log(`ERROR: Migration script 940101_quotePartyIdInfoExtension-2522.js - converting quotePartyIdInfoExtension table to use the following character set ${characterSet} with ${coalition} collation has failed!`)
|
|
54
|
+
console.error(err)
|
|
55
|
+
throw err
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.down = (knex) => {
|
|
62
|
+
console.log('WARNING: Migration script 940101_quotePartyIdInfoExtension-2522.js must manually be reversed')
|
|
63
|
+
}
|
|
64
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Gates Foundation
|
|
19
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
20
|
+
|
|
21
|
+
* ModusBox
|
|
22
|
+
- Neal Donnan <neal.donnan@modusbox.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = async (knex) => {
|
|
29
|
+
return knex.schema.alterTable('settlementContentAggregation', (t) => {
|
|
30
|
+
// Scale should be 4 as per other money columns, otherwise MySQL rounds to 2 decimal places.
|
|
31
|
+
t.decimal('amount', 18, 4).notNullable().alter()
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.down = function (knex) {
|
|
36
|
+
return knex.schema.alterTable('settlementContentAggregation', (t) => {
|
|
37
|
+
// Set the scale back to 2
|
|
38
|
+
t.decimal('amount', 18, 2).notNullable().alter()
|
|
39
|
+
})
|
|
40
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Gates Foundation
|
|
19
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
20
|
+
|
|
21
|
+
* ModusBox
|
|
22
|
+
- Lazola Lucas <lazola.lucas@modusbox.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = async (knex) => {
|
|
29
|
+
return await knex.schema.hasTable('transferParticipantStateChange').then(function(exists) {
|
|
30
|
+
if (!exists) {
|
|
31
|
+
return knex.schema.createTable('transferParticipantStateChange', (t) => {
|
|
32
|
+
t.bigIncrements('transferParticipantStateChangeId').primary().notNullable()
|
|
33
|
+
t.bigInteger('transferParticipantId').notNullable().unsigned()
|
|
34
|
+
t.foreign('transferParticipantId','tt_transferParticipantId_fk').references('transferParticipantId').inTable('transferParticipant')
|
|
35
|
+
t.string('settlementWindowStateId', 50)
|
|
36
|
+
t.foreign('settlementWindowStateId').references('settlementWindowStateId').inTable('settlementWindowState')
|
|
37
|
+
t.string('reason', 512).defaultTo(null).nullable()
|
|
38
|
+
t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable()
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.down = function (knex) {
|
|
45
|
+
return knex.schema.dropTableIfExists('transferParticipantStateChange')
|
|
46
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Gates Foundation
|
|
19
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
20
|
+
|
|
21
|
+
* ModusBox
|
|
22
|
+
- Lazola Lucas <lazola.lucas@modusbox.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = async (knex) => {
|
|
29
|
+
return await knex.schema.hasTable('settlementModel').then(function(exists) {
|
|
30
|
+
if (exists) {
|
|
31
|
+
return knex.schema.alterTable('settlementModel', (t) => {
|
|
32
|
+
t.boolean('adjustPosition').defaultTo(false).notNullable()
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.down = function (knex) {
|
|
39
|
+
return knex.schema.alterTable('settlementModel',(t) => {
|
|
40
|
+
t.dropColumn('adjustPosition')
|
|
41
|
+
})
|
|
42
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Gates Foundation
|
|
19
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
20
|
+
|
|
21
|
+
* ModusBox
|
|
22
|
+
- Deon Botha <deon.botha@@modusbox.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
/* transferParticipantStatechange has been deprecated */
|
|
29
|
+
exports.up = async (knex) => {
|
|
30
|
+
return knex.schema.dropTableIfExists('transferParticipantStateChange')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.down = async function(knex, Promise) {
|
|
34
|
+
return await knex.schema.hasTable('transferParticipantStateChange').then(function(exists) {
|
|
35
|
+
if (!exists) {
|
|
36
|
+
return knex.schema.createTable('transferParticipantStateChange', (t) => {
|
|
37
|
+
t.bigIncrements('transferParticipantStateChangeId').primary().notNullable()
|
|
38
|
+
t.bigInteger('transferParticipantId').notNullable().unsigned()
|
|
39
|
+
t.foreign('transferParticipantId','tt_transferParticipantId_fk').references('transferParticipantId').inTable('transferParticipant')
|
|
40
|
+
t.string('settlementWindowStateId', 50)
|
|
41
|
+
t.foreign('settlementWindowStateId').references('settlementWindowStateId').inTable('settlementWindowState')
|
|
42
|
+
t.string('reason', 512).defaultTo(null).nullable()
|
|
43
|
+
t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable()
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
|
|
9
|
+
Initial contribution
|
|
10
|
+
--------------------
|
|
11
|
+
The initial functionality and code base was donated by the Mowali project working in conjunction with MTN and Orange as service provides.
|
|
12
|
+
* Project: Mowali
|
|
13
|
+
|
|
14
|
+
Contributors
|
|
15
|
+
--------------
|
|
16
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
17
|
+
Names of the original copyright holders (individuals or organizations)
|
|
18
|
+
should be listed with a '*' in the first column. People who have
|
|
19
|
+
contributed from an organization can be listed under the organization
|
|
20
|
+
that actually holds the copyright for their contributions (see the
|
|
21
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
22
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
23
|
+
optionally within square brackets <email>.
|
|
24
|
+
* Gates Foundation
|
|
25
|
+
- Name Surname <name.surname@gatesfoundation.com>
|
|
26
|
+
|
|
27
|
+
* ModusBox
|
|
28
|
+
- Deon Botha <deon.botha@modusbox.com>
|
|
29
|
+
--------------
|
|
30
|
+
******/
|
|
31
|
+
|
|
32
|
+
'use strict'
|
|
33
|
+
|
|
34
|
+
exports.up = async (knex) => {
|
|
35
|
+
await knex.schema.hasTable('settlementModel').then(async function(tableExists) {
|
|
36
|
+
if (tableExists) {
|
|
37
|
+
await knex.schema.hasColumn('settlementModel', 'settlementAccountTypeId')
|
|
38
|
+
.then(async (columnExists) => {
|
|
39
|
+
if (!columnExists){
|
|
40
|
+
await knex.schema.alterTable('settlementModel', (t) => {
|
|
41
|
+
t.integer('settlementAccountTypeId').unsigned().defaultTo(null)
|
|
42
|
+
})
|
|
43
|
+
await knex.transaction(async (trx) => {
|
|
44
|
+
try {
|
|
45
|
+
await knex.select('s.settlementModelId', 's.name', 'lat.name AS latName')
|
|
46
|
+
.from('settlementModel AS s')
|
|
47
|
+
.transacting(trx)
|
|
48
|
+
.innerJoin('ledgerAccountType as lat', 's.ledgerAccountTypeId', 'lat.ledgerAccountTypeId')
|
|
49
|
+
.then(async (models) => {
|
|
50
|
+
for (const model of models) {
|
|
51
|
+
let settlementAccountName
|
|
52
|
+
if (model.latName === 'POSITION') {
|
|
53
|
+
settlementAccountName = 'SETTLEMENT'
|
|
54
|
+
} else {
|
|
55
|
+
settlementAccountName = model.latName + '_SETTLEMENT'
|
|
56
|
+
}
|
|
57
|
+
await knex('settlementModel').transacting(trx).update({ settlementAccountTypeId: knex('ledgerAccountType').select('ledgerAccountTypeId').where('name', settlementAccountName) })
|
|
58
|
+
.where('settlementModelId', model.settlementModelId)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
await trx.commit
|
|
62
|
+
} catch (e) {
|
|
63
|
+
await trx.rollback
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
await knex.schema.alterTable('settlementModel', (t) => {
|
|
67
|
+
t.integer('settlementAccountTypeId').alter().notNullable()
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
exports.down = function (knex) {
|
|
76
|
+
return knex.schema.alterTable('settlementModel',(t) => {
|
|
77
|
+
t.dropColumn('settlementAccountTypeId')
|
|
78
|
+
})
|
|
79
|
+
}
|