diff --git a/migrations/600100_fxTransferDuplicateCheck.js b/migrations/600100_fxTransferDuplicateCheck.js new file mode 100644 index 000000000..e7260830a --- /dev/null +++ b/migrations/600100_fxTransferDuplicateCheck.js @@ -0,0 +1,42 @@ +/***** + 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. + 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 . + * Gates Foundation + - Name Surname + + * INFITX + - Vijay Kumar Guthi + -------------- + ******/ + + 'use strict' + +exports.up = async (knex) => { + return await knex.schema.hasTable('fxTransferDuplicateCheck').then(function(exists) { + if (!exists) { + return knex.schema.createTable('fxTransferDuplicateCheck', (t) => { + t.string('commitRequestId', 36).primary().notNullable() + t.string('hash', 256).notNullable() + t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable() + }) + } + }) +} + +exports.down = function (knex) { + return knex.schema.dropTableIfExists('fxTransferDuplicateCheck') +} diff --git a/migrations/600200_fxTransfer.js b/migrations/600200_fxTransfer.js new file mode 100644 index 000000000..161b4e27b --- /dev/null +++ b/migrations/600200_fxTransfer.js @@ -0,0 +1,51 @@ +/***** + 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. + 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 . + * Gates Foundation + - Name Surname + + * INFITX + - Vijay Kumar Guthi + -------------- + ******/ + + 'use strict' + +exports.up = async (knex) => { + return await knex.schema.hasTable('fxTransfer').then(function(exists) { + if (!exists) { + return knex.schema.createTable('fxTransfer', (t) => { + t.string('commitRequestId', 36).primary().notNullable() + t.foreign('commitRequestId').references('commitRequestId').inTable('fxTransferDuplicateCheck') + t.string('determiningTransferId', 36).defaultTo(null).nullable() + t.decimal('sourceAmount', 18, 4).notNullable() + t.decimal('targetAmount', 18, 4).notNullable() + t.string('sourceCurrency', 3).notNullable() + t.foreign('sourceCurrency').references('currencyId').inTable('currency') + t.string('targetCurrency', 3).notNullable() + t.foreign('targetCurrency').references('currencyId').inTable('currency') + t.string('ilpCondition', 256).notNullable() + t.dateTime('expirationDate').notNullable() + t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable() + }) + } + }) +} + +exports.down = function (knex) { + return knex.schema.dropTableIfExists('fxTransfer') +} diff --git a/migrations/600201_fxTransfer-indexes.js b/migrations/600201_fxTransfer-indexes.js new file mode 100644 index 000000000..541c8fb02 --- /dev/null +++ b/migrations/600201_fxTransfer-indexes.js @@ -0,0 +1,40 @@ +/***** + 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. + 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 . + * Gates Foundation + - Name Surname + + * INFITX + - Vijay Kumar Guthi + -------------- + ******/ + +'use strict' + +exports.up = function (knex) { + return knex.schema.table('fxTransfer', (t) => { + t.index('sourceCurrency') + t.index('targetCurrency') + }) +} + +exports.down = function (knex) { + return knex.schema.table('fxTransfer', (t) => { + t.dropIndex('sourceCurrency') + t.dropIndex('targetCurrency') + }) +} diff --git a/migrations/600400_fxTransferStateChange.js b/migrations/600400_fxTransferStateChange.js new file mode 100644 index 000000000..bd028ab5e --- /dev/null +++ b/migrations/600400_fxTransferStateChange.js @@ -0,0 +1,46 @@ +/***** + 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. + 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 . + * Gates Foundation + - Name Surname + + * INFITX + - Vijay Kumar Guthi + -------------- + ******/ + +'use strict' + +exports.up = async (knex) => { + return await knex.schema.hasTable('fxTransferStateChange').then(function(exists) { + if (!exists) { + return knex.schema.createTable('fxTransferStateChange', (t) => { + t.bigIncrements('fxTransferStateChangeId').primary().notNullable() + t.string('commitRequestId', 36).notNullable() + t.foreign('commitRequestId').references('commitRequestId').inTable('fxTransfer') + t.string('transferStateId', 50).notNullable() + t.foreign('transferStateId').references('transferStateId').inTable('transferState') + t.string('reason', 512).defaultTo(null).nullable() + t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable() + }) + } + }) +} + +exports.down = function (knex) { + return knex.schema.dropTableIfExists('fxTransferStateChange') +} diff --git a/migrations/600401_fxTransferStateChange-indexes.js b/migrations/600401_fxTransferStateChange-indexes.js new file mode 100644 index 000000000..03ffdb66f --- /dev/null +++ b/migrations/600401_fxTransferStateChange-indexes.js @@ -0,0 +1,40 @@ +/***** + 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. + 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 . + * Gates Foundation + - Name Surname + + * INFITX + - Vijay Kumar Guthi + -------------- + ******/ + +'use strict' + +exports.up = function (knex) { + return knex.schema.table('fxTransferStateChange', (t) => { + t.index('commitRequestId') + t.index('transferStateId') + }) +} + +exports.down = function (knex) { + return knex.schema.table('fxTransferStateChange', (t) => { + t.dropIndex('commitRequestId') + t.dropIndex('transferStateId') + }) +} diff --git a/migrations/600501_fxWatchList.js b/migrations/600501_fxWatchList.js new file mode 100644 index 000000000..79de1194d --- /dev/null +++ b/migrations/600501_fxWatchList.js @@ -0,0 +1,44 @@ +/***** + 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. + 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 . + * Gates Foundation + - Name Surname + + * INFITX + - Vijay Kumar Guthi + -------------- + ******/ + + 'use strict' + +exports.up = async (knex) => { + return await knex.schema.hasTable('fxWatchList').then(function(exists) { + if (!exists) { + return knex.schema.createTable('fxWatchList', (t) => { + t.bigIncrements('fxWatchListId').primary().notNullable() + t.string('commitRequestId', 36).notNullable() + t.foreign('commitRequestId').references('commitRequestId').inTable('fxTransfer') + t.string('transferId', 36).notNullable() + t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable() + }) + } + }) +} + +exports.down = function (knex) { + return knex.schema.dropTableIfExists('fxWatchList') +} diff --git a/migrations/600502_fxWatchList-indexes.js b/migrations/600502_fxWatchList-indexes.js new file mode 100644 index 000000000..6f4000b3e --- /dev/null +++ b/migrations/600502_fxWatchList-indexes.js @@ -0,0 +1,40 @@ +/***** + 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. + 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 . + * Gates Foundation + - Name Surname + + * INFITX + - Vijay Kumar Guthi + -------------- + ******/ + +'use strict' + +exports.up = function (knex) { + return knex.schema.table('fxWatchList', (t) => { + t.index('commitRequestId') + t.index('transferId') + }) +} + +exports.down = function (knex) { + return knex.schema.table('fxWatchList', (t) => { + t.dropIndex('commitRequestId') + t.dropIndex('transferId') + }) +} diff --git a/migrations/610200_fxTransferParticipant.js b/migrations/610200_fxTransferParticipant.js new file mode 100644 index 000000000..a49ae8a43 --- /dev/null +++ b/migrations/610200_fxTransferParticipant.js @@ -0,0 +1,50 @@ +/***** + 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. + 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 . + * Gates Foundation + - Name Surname + + * INFITX + - Vijay Kumar Guthi + -------------- + ******/ + +'use strict' + +exports.up = async (knex) => { + return await knex.schema.hasTable('fxTransferParticipant').then(function(exists) { + if (!exists) { + return knex.schema.createTable('fxTransferParticipant', (t) => { + t.bigIncrements('fxTransferParticipantId').primary().notNullable() + t.string('commitRequestId', 36).notNullable() + t.foreign('commitRequestId').references('commitRequestId').inTable('fxTransfer') + t.integer('participantCurrencyId').unsigned().notNullable() + t.foreign('participantCurrencyId').references('participantCurrencyId').inTable('participantCurrency') + t.integer('transferParticipantRoleTypeId').unsigned().notNullable() + t.foreign('transferParticipantRoleTypeId').references('transferParticipantRoleTypeId').inTable('transferParticipantRoleType') + t.integer('ledgerEntryTypeId').unsigned().notNullable() + t.foreign('ledgerEntryTypeId').references('ledgerEntryTypeId').inTable('ledgerEntryType') + t.decimal('amount', 18, 4).notNullable() + t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable() + }) + } + }) +} + +exports.down = function (knex) { + return knex.schema.dropTableIfExists('fxTransferParticipant') +} diff --git a/migrations/610201_fxTransferParticipant-indexes.js b/migrations/610201_fxTransferParticipant-indexes.js new file mode 100644 index 000000000..3f413afff --- /dev/null +++ b/migrations/610201_fxTransferParticipant-indexes.js @@ -0,0 +1,44 @@ +/***** + 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. + 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 . + * Gates Foundation + - Name Surname + + * INFITX + - Vijay Kumar Guthi + -------------- + ******/ + +'use strict' + +exports.up = function (knex) { + return knex.schema.table('fxTransferParticipant', (t) => { + t.index('commitRequestId') + t.index('participantCurrencyId') + t.index('transferParticipantRoleTypeId') + t.index('ledgerEntryTypeId') + }) +} + +exports.down = function (knex) { + return knex.schema.table('fxTransferParticipant', (t) => { + t.dropIndex('commitRequestId') + t.dropIndex('participantCurrencyId') + t.dropIndex('transferParticipantRoleTypeId') + t.dropIndex('ledgerEntryTypeId') + }) +} diff --git a/seeds/transferParticipantRoleType.js b/seeds/transferParticipantRoleType.js index 296493bc5..c260f0240 100644 --- a/seeds/transferParticipantRoleType.js +++ b/seeds/transferParticipantRoleType.js @@ -20,6 +20,7 @@ * Georgi Georgiev * Shashikant Hirugade + * Vijay Kumar Guthi -------------- ******/ @@ -45,6 +46,14 @@ const transferParticipantRoleTypes = [ { name: 'DFSP_POSITION', description: 'Indicates the position account' + }, + { + name: 'INITIATING_FSP', + description: 'Identifier for the FSP who is requesting a currency conversion' + }, + { + name: 'COUNTER_PARTY_FSP', + description: 'Identifier for the FXP who is performing the currency conversion' } ]