Skip to content

Commit d954b28

Browse files
HCK-12459: fix the order of alter statements (#161)
* HCK-12459: fix the order of alter statements * HCK-12459: fix the order of alter statements * HCK-12459: fix the order of alter statements
1 parent dde680c commit d954b28

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

forward_engineering/helpers/alterScriptFromDeltaHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ module.exports = _ => {
375375
'deleteUdtScriptsDtos',
376376
'createUdtScriptsDtos',
377377
'createCollectionsScriptsDtos',
378-
'modifyCollectionScriptsDtos',
379378
'addColumnScriptsDtos',
379+
'modifyCollectionScriptsDtos',
380380
'modifyColumnScriptDtos',
381381
'createViewsScriptsDtos',
382382
'modifiedViewsScriptsDtos',

forward_engineering/helpers/keyHelper.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ module.exports = app => {
121121
};
122122

123123
const getKeys = (keys, jsonSchema) => {
124+
const newProperties = getSchemaNewProperties(jsonSchema);
125+
const properties = { ...newProperties, ...jsonSchema.properties };
126+
124127
return keys.map(key => {
125128
return {
126-
name: findName(key.keyId, jsonSchema.properties),
129+
name: findName(key.keyId, properties),
127130
order: key.type === 'descending' ? 'DESC' : 'ASC',
128-
isActivated: checkIfActivated(key.keyId, jsonSchema.properties),
131+
isActivated: checkIfActivated(key.keyId, properties),
129132
};
130133
});
131134
};
@@ -246,6 +249,26 @@ module.exports = app => {
246249
return [primaryKeyConstraint, ...uniqueKeyConstraints].filter(Boolean);
247250
};
248251

252+
/**
253+
* @param {JsonSchema} jsonSchema
254+
* @returns {JsonSchema}
255+
*/
256+
const getSchemaNewProperties = jsonSchema => {
257+
if (!Array.isArray(jsonSchema.compMod?.newProperties)) {
258+
return {};
259+
}
260+
261+
return jsonSchema.compMod.newProperties.reduce((properties, property) => {
262+
return {
263+
...properties,
264+
[property.code || property.name]: {
265+
...property,
266+
GUID: property.id,
267+
},
268+
};
269+
}, {});
270+
};
271+
249272
return {
250273
getTableKeyConstraints,
251274
isInlineUnique,

0 commit comments

Comments
 (0)