Skip to content

Commit

Permalink
chore(csi-632): added migrations to create externalParticipant table (#…
Browse files Browse the repository at this point in the history
…1094)

* refactor(csi-631): added calculateProxyObligation fn

* refactor(csi-631): added forwardPrepare fn

* refactor(csi-631): added forwardPrepare fn

* refactor(csi-631): improved logging in transfer facade

* chore(csi-632): added migrations to create externalParticipant table

* chore(csi-632): added migration to add externalParticipantId FK to fxTransferParticipant

* chore(csi-632): added migration to add externalParticipantId FK to fxTransferParticipant
  • Loading branch information
geka-evk authored Sep 13, 2024
1 parent 6c1050f commit ba2c688
Show file tree
Hide file tree
Showing 6 changed files with 674 additions and 489 deletions.
1 change: 1 addition & 0 deletions .ncurc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ reject: [
"sinon",
# glob >= 11 requires node >= 20
"glob",
"@mojaloop/central-services-shared", ## todo: temporary!!!!
]
47 changes: 47 additions & 0 deletions migrations/960100_create_externalParticipant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*****
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 <email>.
* Gates Foundation
- Name Surname <[email protected]>
* Eugen Klymniuk <[email protected]>
--------------
**********/

exports.up = async (knex) => {
return knex.schema.hasTable('externalParticipant').then(function(exists) {
if (!exists) {
return knex.schema.createTable('externalParticipant', (t) => {
t.bigIncrements('externalParticipantId').primary().notNullable()
t.string('name', 30).notNullable()
t.unique('name')
t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable()
t.integer('proxyId').unsigned().notNullable()
t.foreign('proxyId').references('participantId').inTable('participant')
})
}
})
}

exports.down = function (knex) {
return knex.schema.hasTable('externalParticipant').then(function(exists) {
if (!exists) {
return knex.schema.dropTableIfExists('externalParticipant')
}
})
}
Original file line number Diff line number Diff line change
@@ -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 <email>.
* Gates Foundation
- Name Surname <[email protected]>
* Eugen Klymniuk <[email protected]>
--------------
**********/

const EP_ID_FIELD = 'externalParticipantId'

exports.up = async (knex) => {
return knex.schema.hasTable('transferParticipant').then(function(exists) {
if (exists) {
return knex.schema.alterTable('transferParticipant', (t) => {
t.bigint(EP_ID_FIELD).unsigned().nullable()
t.foreign(EP_ID_FIELD).references(EP_ID_FIELD).inTable('externalParticipant')
t.index(EP_ID_FIELD)
})
}
})
}

exports.down = async (knex) => {
return knex.schema.hasTable('transferParticipant').then(function(exists) {
if (exists) {
return knex.schema.alterTable('transferParticipant', (t) => {
t.dropIndex(EP_ID_FIELD)
t.dropForeign(EP_ID_FIELD)
t.dropColumn(EP_ID_FIELD)
})
}
})
}
Original file line number Diff line number Diff line change
@@ -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 <email>.
* Gates Foundation
- Name Surname <[email protected]>
* Eugen Klymniuk <[email protected]>
--------------
**********/

const EP_ID_FIELD = 'externalParticipantId'

exports.up = async (knex) => {
return knex.schema.hasTable('fxTransferParticipant').then((exists) => {
if (exists) {
return knex.schema.alterTable('fxTransferParticipant', (t) => {
t.bigint(EP_ID_FIELD).unsigned().nullable()
t.foreign(EP_ID_FIELD).references(EP_ID_FIELD).inTable('externalParticipant')
t.index(EP_ID_FIELD)
})
}
})
}

exports.down = async (knex) => {
return knex.schema.hasTable('fxTransferParticipant').then((exists) => {
if (exists) {
return knex.schema.alterTable('fxTransferParticipant', (t) => {
t.dropIndex(EP_ID_FIELD)
t.dropForeign(EP_ID_FIELD)
t.dropColumn(EP_ID_FIELD)
})
}
})
}
Loading

0 comments on commit ba2c688

Please sign in to comment.