From bfe36b128497dbacec005635a45e236b6ad91188 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 3 May 2023 19:46:40 +0200 Subject: [PATCH] refs #4823 Removed prefix for table names --- README.md | 4 ++-- models/conf/clientConfig.js | 2 +- models/conf/sequenceNumber.js | 2 +- models/supplier/connections.js | 2 +- models/supplier/suppliers.js | 13 ++++++------ models/supplyLine/supplyLine.js | 2 +- models/supplyLine/volumePrices.js | 2 +- models/tradeItem/botanicalNames.js | 2 +- models/tradeItem/characteristics.js | 2 +- models/tradeItem/countryOfOriginIsoCodes.js | 2 +- models/tradeItem/package.js | 2 +- models/tradeItem/packingConfigurations.js | 2 +- models/tradeItem/photos.js | 2 +- models/tradeItem/seasonalPeriod.js | 2 +- models/tradeItem/tradeItem.js | 2 +- utils.js | 23 ++++++++++----------- 16 files changed, 33 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index fc0d38a..c693e0a 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ SYNC_TRADEITEM = true ### Foo.js ```javascript -import { Sequelize } from "sequelize"; +import { Sequelize } from 'sequelize'; const bar = { barCharacteristicOne: { @@ -83,7 +83,7 @@ const bar = { export default (sequelize) => { const Foo = sequelize.define( - "FDfoo", + "foo", bar, { timestamps: false, diff --git a/models/conf/clientConfig.js b/models/conf/clientConfig.js index 0888525..f81ad31 100644 --- a/models/conf/clientConfig.js +++ b/models/conf/clientConfig.js @@ -25,7 +25,7 @@ const clientConfig = { export default (sequelize) => { const ClientConfig = sequelize.define( - 'FDClientConfig', + 'clientConfig', clientConfig, { timestamps: false, diff --git a/models/conf/sequenceNumber.js b/models/conf/sequenceNumber.js index e29b4c7..d68e811 100644 --- a/models/conf/sequenceNumber.js +++ b/models/conf/sequenceNumber.js @@ -23,7 +23,7 @@ const sequenceNumber = { export default (sequelize) => { const sequenceNumbers = sequelize.define( - 'FDsequenceNumber', + 'sequenceNumber', sequenceNumber, { timestamps: false, diff --git a/models/supplier/connections.js b/models/supplier/connections.js index 39cf292..5eb0a75 100644 --- a/models/supplier/connections.js +++ b/models/supplier/connections.js @@ -14,7 +14,7 @@ const connections = { export default (sequelize) => { const connection = sequelize.define( - 'FDconnections', + 'connections', connections, { timestamps: false, diff --git a/models/supplier/suppliers.js b/models/supplier/suppliers.js index e778eba..a53c1d8 100644 --- a/models/supplier/suppliers.js +++ b/models/supplier/suppliers.js @@ -4,6 +4,12 @@ const suppliers = { sequenceNumber: { type: Sequelize.INTEGER, allowNull: false, + primaryKey: true, + }, + organizationId: { + type: Sequelize.STRING, + allowNull: false, + primaryKey: true, }, companyGln: { type: Sequelize.STRING, @@ -13,7 +19,6 @@ const suppliers = { }, commercialName: { type: Sequelize.STRING, - allowNull: false, }, email: { type: Sequelize.STRING, @@ -24,10 +29,6 @@ const suppliers = { website: { type: Sequelize.STRING, }, - organizationId: { - type: Sequelize.STRING, - primaryKey: true, - }, rfhRelationId: { type: Sequelize.INTEGER, }, @@ -50,7 +51,7 @@ const suppliers = { }; export default (sequelize) => { - const Suppliers = sequelize.define('FDsuppliers', suppliers, { + const Suppliers = sequelize.define('suppliers', suppliers, { timestamps: false, freezeTableName: true, }); diff --git a/models/supplyLine/supplyLine.js b/models/supplyLine/supplyLine.js index 23f8986..a6ae2c5 100644 --- a/models/supplyLine/supplyLine.js +++ b/models/supplyLine/supplyLine.js @@ -55,7 +55,7 @@ const supplyLine = { export default (sequelize) => { - const SupplyLine = sequelize.define('FDsupplyLine', supplyLine, { + const SupplyLine = sequelize.define('supplyLine', supplyLine, { timestamps: false, freezeTableName: true, }); diff --git a/models/supplyLine/volumePrices.js b/models/supplyLine/volumePrices.js index 2462aa0..103d078 100644 --- a/models/supplyLine/volumePrices.js +++ b/models/supplyLine/volumePrices.js @@ -15,7 +15,7 @@ const volumePrices = { }; export default (sequelize) => { - const VolumePrices = sequelize.define('FDvolumePrices', volumePrices, { + const VolumePrices = sequelize.define('volumePrices', volumePrices, { timestamps: false, freezeTableName: true, }); diff --git a/models/tradeItem/botanicalNames.js b/models/tradeItem/botanicalNames.js index abd03a1..478c4b4 100644 --- a/models/tradeItem/botanicalNames.js +++ b/models/tradeItem/botanicalNames.js @@ -7,7 +7,7 @@ const botanicalNames = { }; export default (sequelize) => { - const BotanicalNames = sequelize.define('FDbotanicalNames', botanicalNames, { + const BotanicalNames = sequelize.define('botanicalNames', botanicalNames, { timestamps: false, freezeTableName: true, }); diff --git a/models/tradeItem/characteristics.js b/models/tradeItem/characteristics.js index 20e1658..f5c9d36 100644 --- a/models/tradeItem/characteristics.js +++ b/models/tradeItem/characteristics.js @@ -11,7 +11,7 @@ const characteristics = { export default (sequelize) => { const Characteristics = sequelize.define( - 'FDcharacteristics', + 'characteristics', characteristics, { timestamps: false, diff --git a/models/tradeItem/countryOfOriginIsoCodes.js b/models/tradeItem/countryOfOriginIsoCodes.js index c8f0049..c4bfbfc 100644 --- a/models/tradeItem/countryOfOriginIsoCodes.js +++ b/models/tradeItem/countryOfOriginIsoCodes.js @@ -8,7 +8,7 @@ const countryOfOriginIsoCodes = { export default (sequelize) => { const CountryOfOriginIsoCodes = sequelize.define( - 'FDcountryOfOriginIsoCodes', + 'countryOfOriginIsoCodes', countryOfOriginIsoCodes, { timestamps: false, diff --git a/models/tradeItem/package.js b/models/tradeItem/package.js index b629a4c..b8a4a0e 100644 --- a/models/tradeItem/package.js +++ b/models/tradeItem/package.js @@ -10,7 +10,7 @@ const PackageModel = { }; export default (sequelize) => { - const Package = sequelize.define('FDpackage', PackageModel, { + const Package = sequelize.define('package', PackageModel, { timestamps: false, freezeTableName: true, }); diff --git a/models/tradeItem/packingConfigurations.js b/models/tradeItem/packingConfigurations.js index 3a92f55..3f1fc47 100644 --- a/models/tradeItem/packingConfigurations.js +++ b/models/tradeItem/packingConfigurations.js @@ -36,7 +36,7 @@ const packingConfigurations = { export default (sequelize) => { const PackingConfigurations = sequelize.define( - 'FDpackingConfigurations', + 'packingConfig', packingConfigurations, { timestamps: false, diff --git a/models/tradeItem/photos.js b/models/tradeItem/photos.js index 0958fec..0d5ff16 100644 --- a/models/tradeItem/photos.js +++ b/models/tradeItem/photos.js @@ -17,7 +17,7 @@ const photos = { }; export default (sequelize) => { - const Photos = sequelize.define('FDphotos', photos, { + const Photos = sequelize.define('photos', photos, { timestamps: false, freezeTableName: true, }); diff --git a/models/tradeItem/seasonalPeriod.js b/models/tradeItem/seasonalPeriod.js index fd164b2..5df00df 100644 --- a/models/tradeItem/seasonalPeriod.js +++ b/models/tradeItem/seasonalPeriod.js @@ -15,7 +15,7 @@ const seasonalPeriod = { }; export default (sequelize) => { - const SeasonalPeriod = sequelize.define('FDseasonalPeriod', seasonalPeriod, { + const SeasonalPeriod = sequelize.define('seasonalPeriod', seasonalPeriod, { timestamps: false, freezeTableName: true, }); diff --git a/models/tradeItem/tradeItem.js b/models/tradeItem/tradeItem.js index d7f229f..daa48f2 100644 --- a/models/tradeItem/tradeItem.js +++ b/models/tradeItem/tradeItem.js @@ -38,7 +38,7 @@ const tradeItem = { }; export default (sequelize) => { - const TradeItem = sequelize.define('FDtradeItem', tradeItem, { + const TradeItem = sequelize.define('tradeItem', tradeItem, { timestamps: false, freezeTableName: true, }); diff --git a/utils.js b/utils.js index 1ae8a75..c2b0cc8 100644 --- a/utils.js +++ b/utils.js @@ -273,17 +273,17 @@ export async function syncSuppliers(){ await models.supplier.upsert({ sequenceNumber: supplier.sequenceNumber, companyGln: supplier.companyGln, - name: supplier.name, - commercialName: supplier.commercialName, - email: supplier.email, - phone: supplier.phone, - website: supplier.website, - organizationId: supplier.organizationId, - rfhRelationId: supplier.rfhRelationId, - paymentProviders: `${supplier.paymentProviders}`, - endDate: supplier.endDate, - mailingAddress: supplier.mailingAddress, - physicalAddress: supplier.physicalAddress, + name: supplier.name ? supplier.name : null, + commercialName: supplier.commercialName ? supplier.commercialName : null, + email: supplier.email ? supplier.email : null, + phone: supplier.phone ? supplier.phone : null, + website: supplier.website ? supplier.website : null, + organizationId: supplier.organizationId ? supplier.organizationId : null, + rfhRelationId: supplier.rfhRelationId ? supplier.rfhRelationId : null, + paymentProviders: supplier.paymentProviders.length ? `${supplier.paymentProviders}` : null, + endDate: supplier.endDate ? supplier.endDate : null, + mailingAddress: supplier.mailingAddress ? supplier.mailingAddress : null, + physicalAddress: supplier.physicalAddress ? supplier.physicalAddress : null, }); }; await syncSequence(curSequenceNumber, 'suppliers', maxSequenceNumber); @@ -616,7 +616,6 @@ export async function insertItem(tradeItem, supplier) { }, {transaction: tx}); - let characteristics = tradeItem.characteristics; for (let characteristic of characteristics) {