7430_devToTest #2490

Merged
alexm merged 306 commits from 7430_devToTest into test 2024-05-21 09:15:04 +00:00
3 changed files with 24 additions and 1 deletions
Showing only changes of commit af11bb8663 - Show all commits

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.workerLog
MODIFY COLUMN changedModel enum('Worker','Calendar','WorkerTimeControlMail','Business','WorkerDms','WorkerTimeControl', 'Locker') NOT NULL DEFAULT 'Worker';

View File

@ -0,0 +1,21 @@
module.exports = Self => {
Self.observe('before save', async ctx => {
const models = Self.app.models;
const changes = ctx.data || ctx.instance;
const instance = ctx.currentInstance;
const workerFk = changes?.workerFk || instance?.workerFk;
if (workerFk) {
const locker = await models.Locker.findOne({
where: {workerFk}
}, ctx.options);
if (locker) {
await Self.rawSql(
'UPDATE locker SET workerFk = NULL where workerFk = ?',
[workerFk],
ctx.options);
}
}
});
};

View File

@ -96,7 +96,7 @@
"foreignKey": "workerFk"
},
"locker": {
"type": "hasOne",
"type": "hasMany",
"model": "Locker",
"foreignKey": "workerFk"
}