Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mojaloop/#2480): central-ledger migration scripts to configure quote party table utf8 support #862

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
},
"1500|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
"decision": "ignore",
"madeAt": 1628186299076,
"expiresAt": 1630778272338
"madeAt": 1631789414261,
"expiresAt": 1632394199644
},
"1594|@mojaloop/central-services-health>@mojaloop/central-services-shared>axios": {
"decision": "ignore",
Expand Down Expand Up @@ -187,8 +187,8 @@
},
"1675|@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "ignore",
"madeAt": 1628186302231,
"expiresAt": 1630778272338
"madeAt": 1631789415552,
"expiresAt": 1632394199644
},
"1676|@mojaloop/central-services-health>@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "ignore",
Expand All @@ -197,8 +197,8 @@
},
"1676|@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "ignore",
"madeAt": 1628186302231,
"expiresAt": 1630778272338
"madeAt": 1631789415552,
"expiresAt": 1632394199644
},
"1693|@mojaloop/central-services-health>@mojaloop/central-services-shared>shins>sanitize-html>postcss": {
"decision": "ignore",
Expand Down Expand Up @@ -236,6 +236,18 @@
"decision": "ignore",
"madeAt": 1628186340146,
"expiresAt": 1630778312040
},
"1779|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>tar": {
"decision": "fix",
"madeAt": 1631789411221
},
"1780|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>tar": {
"decision": "fix",
"madeAt": 1631789411221
},
"1781|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>tar": {
"decision": "fix",
"madeAt": 1631789411221
}
},
"rules": {},
Expand Down
63 changes: 63 additions & 0 deletions migrations/500601_party-2480.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*****
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 <name.surname@gatesfoundation.com>

* ModusBox
- Miguel de Barros <miguel.debarros@modusbox.com>
--------------
******/

// Notes: these changes are required for the quoting-service and are not used by central-ledger
// This implements [Central-ledger migration scripts should configure the Quote Party table to utf8 character set #2480](https://github.com/mojaloop/project/issues/2480)
// Referencing for MySQL Documentation: https://dev.mysql.com/doc/refman/5.6/en/alter-table.html#alter-table-character-set
'use strict'

const characterSet = 'utf8mb4'
const coalition = 'utf8mb4_unicode_ci'

exports.up = async (knex) => {
console.log(`WARNING: Migration script 500601_party-2480.js is converting PARTY table to use the following character set ${characterSet} with ${coalition} collation`)
return knex.schema.hasTable('party').then(async (exists) => {
if (exists) {
try {
const result = await knex.select(knex.raw(`
CCSA.character_set_name, CCSA.collation_name
FROM information_schema.TABLES T,
information_schema.COLLATION_CHARACTER_SET_APPLICABILITY CCSA
WHERE CCSA.collation_name = T.table_collation
AND T.table_name = "party";
`))
console.log(`WARNING: Migration script 500601_party-2480.js - take note of the current configuration if you wish to revert= ${JSON.stringify(result)}`)
await knex.raw(`
ALTER TABLE party CONVERT TO CHARACTER
SET ${characterSet} COLLATE ${coalition}
`)
} catch (err) {
console.log(`ERROR: Migration script 500601_party-2480.js - converting PARTY table to use the following character set ${characterSet} with ${coalition} collation has failed!`)
console.error(err)
throw err
}
}
})
}

exports.down = (knex) => {
console.log('WARNING: Migration script 500601_party-2480.js must manually be reversed')
}
Loading