Skip to content

Commit

Permalink
HCK-5204: adjusted Cassandra Alter Script generation after fix in app (
Browse files Browse the repository at this point in the history
  • Loading branch information
WilhelmWesser authored Apr 16, 2024
1 parent 858bd22 commit e1333ce
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion forward_engineering/helpers/alterScriptBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getCommentedDropScript = (scriptDtos, data) => {
return scriptDtos;
}
return scriptDtos.map((dto = {}) => {
if (!dto?.scripts[0]?.isDropScript || !dto?.scripts[0]?.script) {
if (!dto?.scripts?.[0]?.isDropScript || !dto?.scripts?.[0]?.script) {
return dto;
}
return {
Expand Down
4 changes: 2 additions & 2 deletions forward_engineering/helpers/alterScriptFromDeltaHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ const handleItem = (item, udtMap, generator, data) => {
alterTableScript = Object.keys(itemProperties)
.reduce((alterTableScript, tableKey) => {
const itemCompModData = itemProperties[tableKey].role.compMod;
const codeName = dependencies.lodash.get(itemProperties, `${tableKey}.role.code`, '');
const tableName = codeName.length ? codeName : tableKey;

if (!itemCompModData) {
return alterTableScript;
}

const codeName = dependencies.lodash.get(itemProperties, `${tableKey}.role.code`, '');
const tableName = codeName.length ? codeName : tableKey;
const tableProperties = itemProperties[tableKey].properties || {};

const keyspaceName = itemCompModData.keyspaceName;
Expand Down
7 changes: 4 additions & 3 deletions forward_engineering/helpers/updateHelpers/indexHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,8 @@ const getDropIndexScript = (keyspaceName, tableName, secIndxs = []) => secIndxs.
const getAddSearchIndexScript = data => {
const { keyspaceName, tableName, searchIndex, dataSources, isActivated, dbVersion } = data;
const isExistScript = checkExistsScript(keyspaceName, tableName, 'createSearchIndexes');
const dataIndexScript = { ...scriptData, added: true, script: '' };
if (isExistScript) {
return [dataIndexScript];
return [];
}
setNameCollectionsScript(keyspaceName, tableName, 'createSearchIndexes');
const script = getIndexes(
Expand Down Expand Up @@ -468,9 +467,11 @@ const createDataSources = (item, data) => {
];
};

const getTableNameFromCompMod = table => table.role?.compMod?.collectionName?.new ?? table.role?.compMod?.collectionName?.old

const getIndexTable = (item, data, tableIsChange) => {
const dataSources = createDataSources(item, data);
const tableName = item.role?.code || item.role?.name;
const tableName = item.role?.code || item.role?.name || getTableNameFromCompMod(item);
const keyspaceName = item.role.compMod?.keyspaceName;
const dbVersion = data.modelData[0].dbVersion;
const isActivated = item.role?.isActivated;
Expand Down
2 changes: 1 addition & 1 deletion forward_engineering/helpers/updateHelpers/udtHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const prepareField = (field, property) => {
const getUpdateScript = (item, data, udtMap) => {
const { role = {}, properties } = item;
if (!properties) {
return [scriptData];
return [];
}
const keySpaces = getKeySpaces(role);
const udtName = role.code || role.name;
Expand Down

0 comments on commit e1333ce

Please sign in to comment.