-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added db migration scripts for fx
- Loading branch information
Showing
10 changed files
with
406 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <email>. | ||
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* INFITX | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
'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() | ||
This comment has been minimized.
Sorry, something went wrong. |
||
t.string('hash', 256).notNullable() | ||
t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable() | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
exports.down = function (knex) { | ||
return knex.schema.dropTableIfExists('fxTransferDuplicateCheck') | ||
} |
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,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 <email>. | ||
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* INFITX | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
'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') | ||
} |
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,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 <email>. | ||
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* INFITX | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
'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') | ||
}) | ||
} |
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,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 <email>. | ||
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* INFITX | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
'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') | ||
} |
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,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 <email>. | ||
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* INFITX | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
'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') | ||
}) | ||
} |
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,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 <email>. | ||
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* INFITX | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
'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') | ||
} |
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,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 <email>. | ||
* Gates Foundation | ||
- Name Surname <[email protected]> | ||
* INFITX | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
'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') | ||
}) | ||
} |
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,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]> | ||
* INFITX | ||
- Vijay Kumar Guthi <[email protected]> | ||
-------------- | ||
******/ | ||
|
||
'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') | ||
} |
Oops, something went wrong.
maybe, it's better to have the same table structure as
transferDuplicateCheck
(usetransferId
field instead oncommitRequestId
)?Or even use the same table (just add a new optional boolean field
isFx
)