This commit is contained in:
parent
c0a23a0df8
commit
fda5726f55
|
@ -3,6 +3,7 @@ logRelation: true
|
|||
logMainShowField: false
|
||||
upperCaseTable: true
|
||||
userField: editorFk
|
||||
reasonField: motivation
|
||||
rowExcludeField: logExclude
|
||||
excludeRegex: '__$'
|
||||
showFields:
|
||||
|
|
|
@ -94,9 +94,10 @@ module.exports = class ModelLoader {
|
|||
];
|
||||
const globalProps = [
|
||||
'userField',
|
||||
'rowExcludeField'
|
||||
'rowExcludeField',
|
||||
'reasonField'
|
||||
];
|
||||
|
||||
|
||||
for (const [schema, table, tableInfo] of schemaMap) {
|
||||
const tableConf = tableInfo.conf;
|
||||
|
||||
|
@ -109,20 +110,19 @@ module.exports = class ModelLoader {
|
|||
: conf[prop];
|
||||
|
||||
// Fetch columns & types
|
||||
|
||||
|
||||
const columns = new Set();
|
||||
Object.assign (tableInfo, {
|
||||
castTypes: new Map(),
|
||||
columns
|
||||
});
|
||||
|
||||
|
||||
if (tableConf.types)
|
||||
for (const col in tableConf.types)
|
||||
tableInfo.castTypes.set(col, tableConf.types[col]);
|
||||
|
||||
|
||||
const [dbCols] = await db.query(
|
||||
`SELECT
|
||||
COLUMN_NAME \`col\`,
|
||||
`SELECT COLUMN_NAME \`col\`,
|
||||
DATA_TYPE \`type\`
|
||||
FROM information_schema.\`COLUMNS\`
|
||||
WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?`,
|
||||
|
@ -131,6 +131,7 @@ module.exports = class ModelLoader {
|
|||
|
||||
const exclude = new Set(tableConf.exclude);
|
||||
exclude.add(tableInfo.userField);
|
||||
exclude.add(tableInfo.reasonField);
|
||||
|
||||
for (const {col, type} of dbCols) {
|
||||
const isExcluded =
|
||||
|
|
|
@ -98,7 +98,8 @@ module.exports = class MyLogger {
|
|||
creationDate = ?,
|
||||
oldInstance = ?,
|
||||
changedModelValue = ?,
|
||||
summaryId = ?
|
||||
summaryId = ?,
|
||||
reason = ?
|
||||
WHERE id = ?`
|
||||
);
|
||||
}
|
||||
|
@ -543,6 +544,7 @@ module.exports = class MyLogger {
|
|||
oldInstance,
|
||||
modelValue,
|
||||
summaryId,
|
||||
row[tableInfo.reasonField] ?? null,
|
||||
deleteRow.id
|
||||
]);
|
||||
}
|
||||
|
@ -559,7 +561,8 @@ module.exports = class MyLogger {
|
|||
newI ? JSON.stringify(newI) : null,
|
||||
modelId,
|
||||
modelValue,
|
||||
summaryId
|
||||
summaryId,
|
||||
row[tableInfo.reasonField] ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue