-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(db migrations): fix subid db (#836)
* Fixed subId foreignkey issue * Bumped up the version and postponed the audits * Fixed integration tests
- Loading branch information
Showing
6 changed files
with
153 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/***** | ||
License | ||
-------------- | ||
Copyright © 2017 Bill & Melinda Gates Foundation | ||
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 | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
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. | ||
Initial contribution | ||
-------------------- | ||
The initial functionality and code base was donated by the Mowali project working in conjunction with MTN and Orange as service provides. | ||
* Project: Mowali | ||
Contributors | ||
-------------- | ||
This is the official list of the Mojaloop project contributors for this file. | ||
Names of the original copyright holders (individuals or organizations) | ||
should be listed with a '*' in the first column. People who have | ||
contributed from an organization can be listed under the organization | ||
that actually holds the copyright for their contributions (see the | ||
Gates Foundation organization for an example). Those individuals should have | ||
their names indented and be marked with a '-'. Email address can be added | ||
optionally within square brackets <email>. | ||
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* ModusBox | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
// Notes: these changes are required for the quoting-service and are not used by central-ledger | ||
'use strict' | ||
|
||
exports.up = (knex) => { | ||
return knex.schema | ||
.table('quoteParty', (t) => { | ||
t.dropForeign('partySubIdOrTypeId') | ||
}) | ||
.alterTable('quoteParty', function(t) { | ||
t.string('partySubIdOrTypeId', 128).defaultTo(null).nullable().comment('A sub-identifier or sub-type for the Party').alter(); | ||
}) | ||
} | ||
|
||
exports.down = (knex) => { | ||
return knex.schema | ||
.alterTable('quoteParty', function(t) { | ||
t.integer('partySubIdOrTypeId').unsigned().defaultTo(null).nullable().comment('A sub-identifier or sub-type for the Party').alter(); | ||
}) | ||
.table('quoteParty', (t) => { | ||
t.foreign('partySubIdOrTypeId').references('partyIdentifierTypeId').inTable('partyIdentifierType') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/***** | ||
License | ||
-------------- | ||
Copyright © 2017 Bill & Melinda Gates Foundation | ||
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 | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
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. | ||
Initial contribution | ||
-------------------- | ||
The initial functionality and code base was donated by the Mowali project working in conjunction with MTN and Orange as service provides. | ||
* Project: Mowali | ||
Contributors | ||
-------------- | ||
This is the official list of the Mojaloop project contributors for this file. | ||
Names of the original copyright holders (individuals or organizations) | ||
should be listed with a '*' in the first column. People who have | ||
contributed from an organization can be listed under the organization | ||
that actually holds the copyright for their contributions (see the | ||
Gates Foundation organization for an example). Those individuals should have | ||
their names indented and be marked with a '-'. Email address can be added | ||
optionally within square brackets <email>. | ||
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* ModusBox | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
// Notes: these changes are required for the quoting-service and are not used by central-ledger | ||
'use strict' | ||
|
||
exports.up = function (knex) { | ||
return knex.raw(` | ||
CREATE OR REPLACE VIEW quotePartyView AS | ||
SELECT | ||
qp.quoteId AS quoteId, | ||
qp.quotePartyId AS quotePartyId, | ||
pt.name AS partyType, | ||
pit.name AS identifierType, | ||
qp.partyIdentifierValue, | ||
qp.partySubIdOrTypeId AS partySubIdOrType, | ||
qp.fspId AS fspId, | ||
qp.merchantClassificationCode AS merchantClassificationCode, | ||
qp.partyName AS partyName, | ||
p.firstName AS firstName, | ||
p.lastName AS lastName, | ||
p.middleName AS middleName, | ||
p.dateOfBirth AS dateOfBirth, | ||
gc.longitude, | ||
gc.latitude | ||
FROM | ||
quoteParty qp | ||
INNER JOIN partyType pt ON pt.partyTypeId = qp.partyTypeId | ||
INNER JOIN partyIdentifierType pit ON pit.partyIdentifierTypeId = qp.partyIdentifierTypeId | ||
LEFT JOIN party p ON p.quotePartyId = qp.quotePartyId | ||
LEFT JOIN geoCode gc ON gc.quotePartyId = qp.quotePartyId | ||
`) | ||
} | ||
|
||
module.exports.down = async function(knex) { | ||
return knex.raw(` | ||
CREATE OR REPLACE VIEW quotePartyView AS | ||
SELECT | ||
qp.quoteId AS quoteId, | ||
qp.quotePartyId AS quotePartyId, | ||
pt.name AS partyType, | ||
pit.name AS identifierType, | ||
qp.partyIdentifierValue, | ||
spit.name AS partySubIdOrType, | ||
qp.fspId AS fspId, | ||
qp.merchantClassificationCode AS merchantClassificationCode, | ||
qp.partyName AS partyName, | ||
p.firstName AS firstName, | ||
p.lastName AS lastName, | ||
p.middleName AS middleName, | ||
p.dateOfBirth AS dateOfBirth, | ||
gc.longitude, | ||
gc.latitude | ||
FROM | ||
quoteParty qp | ||
INNER JOIN partyType pt ON pt.partyTypeId = qp.partyTypeId | ||
INNER JOIN partyIdentifierType pit ON pit.partyIdentifierTypeId = qp.partyIdentifierTypeId | ||
LEFT JOIN party p ON p.quotePartyId = qp.quotePartyId | ||
LEFT JOIN partyIdentifierType spit ON spit.partyIdentifierTypeId = qp.partySubIdOrTypeId | ||
LEFT JOIN geoCode gc ON gc.quotePartyId = qp.quotePartyId | ||
`) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters