Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hck-5358 HCK-5359: Double "Create Index" statement (all cases: new/existing entities) in ALTER script #86

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions forward_engineering/alterScript/alterScriptFromDeltaHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ const getAlterCollectionsScriptDtos = ({

const createCollectionsScriptDtos = createScriptsData.filter(collection => collection.compMod?.created).map(getAddCollectionScriptDto({app, dbVersion, modelDefinitions, internalDefinitions, externalDefinitions}));
const deleteCollectionScriptDtos = deleteScriptsData.filter(collection => collection.compMod?.deleted).map(getDeleteCollectionScriptDto(app));
const modifyCollectionsScriptDtos = modifyScriptsData.filter(collection => collection.compMod?.modified).flatMap(getModifyCollectionScriptDtos({app, dbVersion}))
const modifyCollectionScriptDtos = modifyScriptsData.filter(collection => collection.compMod?.modified).flatMap(getModifyCollectionScriptDtos({app, dbVersion}))
const addColumnScriptDtos = createScriptsData.filter(item => !item?.compMod?.created).flatMap(getAddColumnScriptDtos({app, dbVersion, modelDefinitions, internalDefinitions, externalDefinitions}));
const deleteColumnScriptDtos = deleteScriptsData.filter(item => !item?.compMod?.deleted).flatMap(getDeleteColumnScriptDtos(app));
const modifyColumnScriptDtos = modifyScriptsData.flatMap(getModifyColumnScriptDtos(app, dbVersion));

return [
...createCollectionsScriptDtos,
...deleteCollectionScriptDtos,
...modifyCollectionScriptDtos,
...addColumnScriptDtos,
...deleteColumnScriptDtos,
...modifyColumnScriptDtos,
...modifyCollectionsScriptDtos,
].filter(Boolean);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {AlterScriptDto} = require("../types/AlterScriptDto");
const {getUpdateTypesScriptDtos} = require("./columnHelpers/alterTypeHelper");
const {getRenameColumnScriptDtos} = require("./columnHelpers/renameColumnHelper");
const { getModifyIndexesScriptDtos } = require("./entityHelpers/indexesHelper");
const { getModifyIndexesScriptDtos, getAddedIndexesScriptDtos } = require("./entityHelpers/indexesHelper");

/**
* @return {(collection: AlterCollectionDto) => AlterScriptDto | undefined}
Expand Down Expand Up @@ -131,7 +131,7 @@ const getAddColumnScriptDtos =
* @return {AlterScriptDto[]}
* */
const getIndexesBasedOnNewlyCreatedColumnsScript = ({_, ddlProvider, dbVersion, collection}) => {
const newIndexes = collection?.role?.compMod?.Indxs?.new || collection?.role?.Indxs || []
const newIndexes = collection?.role?.Indxs || []
const newPropertiesIds = Object.values(collection?.properties ?? {}).map(({GUID}) => GUID)

if (newIndexes.length === 0 || newPropertiesIds.length === 0) {
Expand All @@ -144,7 +144,7 @@ const getIndexesBasedOnNewlyCreatedColumnsScript = ({_, ddlProvider, dbVersion,
return []
}

return getModifyIndexesScriptDtos({ _, ddlProvider })({ collection, dbVersion })
return getAddedIndexesScriptDtos({ _, ddlProvider })({ collection })
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const getDeleteIndexScriptDto =
const getAddedIndexesScriptDtos =
({ _, ddlProvider }) =>
({ collection }) => {
const newIndexes = collection?.role?.compMod?.Indxs?.new || collection?.role?.Indxs || [];
const newIndexes = collection?.role?.Indxs || [];
const oldIndexes = collection?.role?.compMod?.Indxs?.old || [];

const addedIndexes = newIndexes.filter(newIndex => {
Expand Down Expand Up @@ -276,4 +276,5 @@ const getModifyIndexesScriptDtos =

module.exports = {
getModifyIndexesScriptDtos,
getAddedIndexesScriptDtos,
};