@kipicore/dbcore 1.1.292 → 1.1.293
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -104,34 +104,55 @@ module.exports = {
|
|
|
104
104
|
if (newActions.length > 0) {
|
|
105
105
|
await queryInterface.bulkInsert('feature_actions', newActions, { transaction });
|
|
106
106
|
}
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
// )[0];
|
|
107
|
+
// const modulesToDelete = existingModules.filter(m => !allModulesListCode.modules.has(m.code)).map(m => m.code);
|
|
108
|
+
// // Find features to delete
|
|
109
|
+
// const featuresToDelete = existingFeatures.filter(f => !allModulesListCode.features.has(f.code)).map(f => f.code);
|
|
110
|
+
// // Find actions to delete
|
|
111
|
+
// const actionsToDelete = existingActions.filter(a => !allModulesListCode.actions.has(a.code)).map(a => a.code);
|
|
112
|
+
// if (actionsToDelete.length) {
|
|
113
|
+
// await queryInterface.sequelize.query(`DELETE FROM feature_actions WHERE code IN (:codes)`, {
|
|
114
|
+
// replacements: { codes: actionsToDelete },
|
|
115
|
+
// transaction,
|
|
116
|
+
// });
|
|
118
117
|
// }
|
|
118
|
+
// if (featuresToDelete.length) {
|
|
119
|
+
// await queryInterface.sequelize.query(`DELETE FROM module_features WHERE code IN (:codes)`, {
|
|
120
|
+
// replacements: { codes: featuresToDelete },
|
|
121
|
+
// transaction,
|
|
122
|
+
// });
|
|
123
|
+
// }
|
|
124
|
+
// if (modulesToDelete.length) {
|
|
125
|
+
// await queryInterface.sequelize.query(`DELETE FROM modules WHERE code IN (:codes)`, {
|
|
126
|
+
// replacements: { codes: modulesToDelete },
|
|
127
|
+
// transaction,
|
|
128
|
+
// });
|
|
129
|
+
// }
|
|
130
|
+
async function findOldCodes(queryInterface, table, validCodes) {
|
|
131
|
+
if (validCodes.length === 0) {
|
|
132
|
+
// If no codes in the new list, return all old ones
|
|
133
|
+
return (await queryInterface.sequelize.query(`SELECT code FROM ${table} WHERE is_default=true`, { raw: true, transaction }))[0];
|
|
134
|
+
}
|
|
135
|
+
return (await queryInterface.sequelize.query(`SELECT code FROM ${table} WHERE is_default=true AND code NOT IN (:codes)`, {
|
|
136
|
+
replacements: { codes: validCodes },
|
|
137
|
+
raw: true,
|
|
138
|
+
}))[0];
|
|
139
|
+
}
|
|
119
140
|
// ✅ Delete old entries not in allModulesListCode
|
|
120
|
-
await queryInterface.sequelize.query(`DELETE FROM feature_actions WHERE code NOT IN (:codes)`, {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
124
|
-
await queryInterface.sequelize.query(`DELETE FROM module_features WHERE code NOT IN (:codes)`, {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
});
|
|
128
|
-
await queryInterface.sequelize.query(`DELETE FROM modules WHERE code NOT IN (:codes)`, {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
141
|
+
// await queryInterface.sequelize.query(`DELETE FROM feature_actions WHERE code NOT IN (:codes)`, {
|
|
142
|
+
// replacements: { codes: [...allModulesListCode.actions] },
|
|
143
|
+
// transaction,
|
|
144
|
+
// });
|
|
145
|
+
// await queryInterface.sequelize.query(`DELETE FROM module_features WHERE code NOT IN (:codes)`, {
|
|
146
|
+
// replacements: { codes: [...allModulesListCode.features] },
|
|
147
|
+
// transaction,
|
|
148
|
+
// });
|
|
149
|
+
// await queryInterface.sequelize.query(`DELETE FROM modules WHERE code NOT IN (:codes)`, {
|
|
150
|
+
// replacements: { codes: [...allModulesListCode.modules] },
|
|
151
|
+
// transaction,
|
|
152
|
+
// });
|
|
153
|
+
await findOldCodes(queryInterface, 'feature_actions', [...allModulesListCode.actions]);
|
|
154
|
+
await findOldCodes(queryInterface, 'module_features', [...allModulesListCode.features]);
|
|
155
|
+
await findOldCodes(queryInterface, 'modules', [...allModulesListCode.modules]);
|
|
135
156
|
// 2️⃣ Log them (or handle however you want)
|
|
136
157
|
// console.log('🚨 Old Actions not in new list:', oldActionsNotInNew);
|
|
137
158
|
// console.log('🚨 Old Features not in new list:', oldFeaturesNotInNew);
|
package/package.json
CHANGED