settings keys in DB converted to camel case
callback-based settings model replaced by async-based settings model
This commit is contained in:
parent
6c5c47ac2e
commit
d8ee364a4b
22 changed files with 123 additions and 143 deletions
|
@ -3,6 +3,6 @@
|
|||
const config = require('./config');
|
||||
|
||||
module.exports = {
|
||||
client: 'mysql',
|
||||
client: 'mysql2',
|
||||
connection: config.mysql
|
||||
};
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
"use strict";
|
||||
|
||||
function fromDbKey(key) {
|
||||
let prefix = '';
|
||||
if (key.startsWith('_')) {
|
||||
key = key.substring(1);
|
||||
prefix = '_';
|
||||
|
||||
}
|
||||
return prefix + key.replace(/[_-]([a-z])/g, (m, c) => c.toUpperCase());
|
||||
}
|
||||
|
||||
exports.up = (knex, Promise) => (async() => {
|
||||
const rows = await knex('settings');
|
||||
|
||||
for (const row of rows) {
|
||||
await knex('settings').where('id', row.id).update('key', fromDbKey(row.key))
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
||||
exports.down = (knex, Promise) => (async() => {
|
||||
})();
|
|
@ -0,0 +1,9 @@
|
|||
"use strict";
|
||||
|
||||
exports.up = (knex, Promise) => (async() => {
|
||||
await knex('settings').where('key', 'dbSchemaVersion').del();
|
||||
})();
|
||||
|
||||
|
||||
exports.down = (knex, Promise) => (async() => {
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue