From dfee2b0ce450e34440f9c42d181a2faa33762dc7 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 Jan 2024 10:39:12 +0100 Subject: [PATCH] refs #6718 fix: loggable and sql --- db/changes/240401/00-revokeItem.sql | 2 +- db/changes/{240201 => 240401}/00-ticketSmsToClientSms.sql | 0 .../{235001 => 240401}/00-updateACL_Role_VnRole.sql | 2 +- db/changes/240401/01-saleGroupDetailDefaultSize.sql | 4 ++-- db/changes/240401/01-supplierAccount.sql | 8 ++++---- db/changes/240401/02-invoiceOutConfig_refLen.sql | 2 +- loopback/server/connectors/vn-mysql.js | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) rename db/changes/{240201 => 240401}/00-ticketSmsToClientSms.sql (100%) rename db/changes/{235001 => 240401}/00-updateACL_Role_VnRole.sql (59%) diff --git a/db/changes/240401/00-revokeItem.sql b/db/changes/240401/00-revokeItem.sql index 2b75d67cf0..5f6a30620d 100644 --- a/db/changes/240401/00-revokeItem.sql +++ b/db/changes/240401/00-revokeItem.sql @@ -1,4 +1,4 @@ REVOKE UPDATE ON TABLE `vn`.`item` FROM `employee`; -GRANT UPDATE(id, equivalent, stems, minPrice, isToPrint, family, box, category, doPhoto, image, inkFk, intrastatFk, hasMinPrice, created, comment, typeFk, generic, producerFk, description, density, relevancy, expenseFk, isActive, subName, tag5, value5, tag6, value6, tag7, value7, tag8, value8, tag9, value9, tag10, value10, minimum, upToDown, supplyResponseFk, hasKgPrice, isFloramondo, isFragile, numberOfItemsPerCask, embalageCode, quality, stemMultiplier, itemPackingTypeFk, packingOut, genericFk, packingShelve, isLaid, lastUsed, weightByPiece, weightByPiece, editorFk, recycledPlastic, nonRecycledPlastic, minQuantity) ON TABLE vn.item TO employee; +GRANT UPDATE(id, equivalent, stems, minPrice, isToPrint, family, box, category, doPhoto, image, inkFk, intrastatFk, hasMinPrice, created, comment, typeFk, generic, producerFk, description, density, relevancy, expenseFk, isActive, subName, tag5, value5, tag6, value6, tag7, value7, tag8, value8, tag9, value9, tag10, value10, minimum, upToDown, supplyResponseFk, hasKgPrice, isFloramondo, isFragile, numberOfItemsPerCask, embalageCode, quality, stemMultiplier, itemPackingTypeFk, packingOut, genericFk, packingShelve, isLaid, lastUsed, weightByPiece, weightByPiece, editorFk, recycledPlastic, nonRecycledPlastic, minQuantity) ON TABLE `vn`.`item` TO `employee`; diff --git a/db/changes/240201/00-ticketSmsToClientSms.sql b/db/changes/240401/00-ticketSmsToClientSms.sql similarity index 100% rename from db/changes/240201/00-ticketSmsToClientSms.sql rename to db/changes/240401/00-ticketSmsToClientSms.sql diff --git a/db/changes/235001/00-updateACL_Role_VnRole.sql b/db/changes/240401/00-updateACL_Role_VnRole.sql similarity index 59% rename from db/changes/235001/00-updateACL_Role_VnRole.sql rename to db/changes/240401/00-updateACL_Role_VnRole.sql index b08a44138e..5d108ac446 100644 --- a/db/changes/235001/00-updateACL_Role_VnRole.sql +++ b/db/changes/240401/00-updateACL_Role_VnRole.sql @@ -1,4 +1,4 @@ -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalType,principalId) VALUES ('VnRole','*','READ','ALLOW','ROLE','employee'), ('VnRole','*','WRITE','ALLOW','ROLE','it'); diff --git a/db/changes/240401/01-saleGroupDetailDefaultSize.sql b/db/changes/240401/01-saleGroupDetailDefaultSize.sql index 12f17c5e71..34529ba788 100644 --- a/db/changes/240401/01-saleGroupDetailDefaultSize.sql +++ b/db/changes/240401/01-saleGroupDetailDefaultSize.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.productionConfig ADD itemPreviousDefaultSize int NULL COMMENT 'Altura por defecto para los artículos de previa'; -UPDATE IGNORE vn.productionConfig SET itemPreviousDefaultSize = 40 WHERE id = 1; +ALTER TABLE `vn`.`productionConfig` ADD itemPreviousDefaultSize int NULL COMMENT 'Altura por defecto para los artículos de previa'; +UPDATE IGNORE `vn`.`productionConfig` SET itemPreviousDefaultSize = 40 WHERE id = 1; diff --git a/db/changes/240401/01-supplierAccount.sql b/db/changes/240401/01-supplierAccount.sql index 1c0f1ef439..21ce7c71e1 100644 --- a/db/changes/240401/01-supplierAccount.sql +++ b/db/changes/240401/01-supplierAccount.sql @@ -1,9 +1,9 @@ -UPDATE vn.supplierAccount sa - JOIN vn.country c ON sa.countryFk = c.id AND c.code = 'FR' +UPDATE `vn`.`supplierAccount` sa + JOIN `vn`.`country` c ON sa.countryFk = c.id AND c.code = 'FR' SET countryFk = c.id WHERE iban = 'FR7630003012690002801121597'; -UPDATE vn.supplierAccount sa - JOIN vn.country c ON sa.countryFk = c.id AND c.code = 'PT' +UPDATE `vn`.`supplierAccount` sa + JOIN `vn`.`country` c ON sa.countryFk = c.id AND c.code = 'PT' SET countryFk = c.id WHERE iban = 'PT50001000005813059150168'; diff --git a/db/changes/240401/02-invoiceOutConfig_refLen.sql b/db/changes/240401/02-invoiceOutConfig_refLen.sql index 8b91889f24..a5f5c20887 100644 --- a/db/changes/240401/02-invoiceOutConfig_refLen.sql +++ b/db/changes/240401/02-invoiceOutConfig_refLen.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.invoiceOutConfig +ALTER TABLE `vn`.`invoiceOutConfig` ADD IF NOT EXISTS refLen TINYINT UNSIGNED DEFAULT 5 NOT NULL COMMENT 'Invoice reference identifier length'; diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 40ad78bde0..1f71695015 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -270,8 +270,8 @@ class VnMySQL extends MySQL { isLoggable(model) { const Model = this.getModelDefinition(model).model; - const settings = Model.definition.settings; - return settings.base && settings.base === 'Loggable'; + const {settings} = Model.definition; + return settings?.mixins?.Loggable; } invokeMethod(method, args, model, ctx, opts, cb) { @@ -291,7 +291,7 @@ class VnMySQL extends MySQL { } try { - const userId = opts.httpCtx && opts.httpCtx.active.accessToken.userId; + const userId = opts.httpCtx && opts.httpCtx.active?.accessToken?.userId; if (userId) { const user = await Model.app.models.VnUser.findById(userId, {fields: ['name']}, opts); await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);