-
Notifications
You must be signed in to change notification settings - Fork 10
Feature/hck 4566 bbva sequences definition for postgresql re fro #91
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
Merged
ArzamastsevVladyslav
merged 13 commits into
main
from
Feature/HCK-4566--bbva-sequences-definition-for-postgresql-re-fro
Mar 5, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
561b7ea
RE: add handling of schema sequences
serhii-filonenko fc62f77
FE: add alter script generation for modified schema sequences
serhii-filonenko e328c1b
FE: FE: add alter script generation for deleted schema sequences
serhii-filonenko 2bf9a34
FE: FE: add alter script generation for added schema sequences
serhii-filonenko a17801b
FE: define types for sequence helper
serhii-filonenko 375be3d
FE: fix changing of sequence type
serhii-filonenko 2d8a070
FE: add schema name for sequence owned by option column name
serhii-filonenko 5f10454
RE: fix duplicating of sequences in SELECT query
serhii-filonenko 6c1487a
RE: update passing arguments in functions
serhii-filonenko 0ce878c
Add missed types
serhii-filonenko c0a2ea2
Merge branch 'main' into Feature/HCK-4566--bbva-sequences-definition-…
serhii-filonenko a51f3c9
RE: fix incorrect argument passing
serhii-filonenko f945803
Merge branch 'main' into Feature/HCK-4566--bbva-sequences-definition-…
serhii-filonenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
forward_engineering/alterScript/alterScriptHelpers/containerHelpers/sequencesHelper.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| const { AlterScriptDto } = require('../../types/AlterScriptDto'); | ||
| const { App } = require('../../../types/coreApplicationTypes'); | ||
| const sequencesCompModKey = 'sequences'; | ||
|
|
||
| /** | ||
| * @param {{ app: App }} | ||
| * @return {({ container }: { container: object }) => AlterScriptDto[]} | ||
| * */ | ||
| const getAddContainerSequencesScriptDtos = ({ app }) => ({ container }) => { | ||
| const _ = app.require('lodash'); | ||
| const ddlProvider = require('../../../ddlProvider')(null, null, app); | ||
| const { getDbName } = require('../../../utils/general')(_); | ||
| const schemaName = getDbName([container.role]); | ||
|
|
||
| return (container.role?.sequences || []) | ||
| .map((sequence) => ddlProvider.createSchemaSequence({ schemaName, sequence })) | ||
| .map((script) => AlterScriptDto.getInstance([script], true, false)) | ||
| .filter(Boolean); | ||
| }; | ||
|
|
||
| /** | ||
| * @param {{ app: App }} | ||
| * @return {({ container }: { container: object }) => AlterScriptDto[]} | ||
| * */ | ||
| const getModifyContainerSequencesScriptDtos = ({ app }) => ({ container }) => { | ||
| const _ = app.require('lodash'); | ||
| const ddlProvider = require('../../../ddlProvider')(null, null, app); | ||
| const { getDbName, getGroupItemsByCompMode } = require('../../../utils/general')(_); | ||
|
|
||
| const schemaName = getDbName([container.role]); | ||
| const sequencesCompMod = container.role?.compMod?.[sequencesCompModKey] || {}; | ||
| const { new: newItems = [], old: oldItems = [] } = sequencesCompMod; | ||
|
|
||
| const { removed, added, modified } = getGroupItemsByCompMode({ | ||
| newItems, | ||
| oldItems, | ||
| }); | ||
|
|
||
| const removedScriptDtos = removed | ||
| .map((sequence) => { | ||
| return ddlProvider.dropSchemaSequence({ schemaName, sequence }); | ||
| }) | ||
| .map((script) => AlterScriptDto.getInstance([script], true, true)); | ||
| const addedScriptDtos = added | ||
| .map((sequence) => | ||
| ddlProvider.createSchemaSequence({ schemaName, sequence }) | ||
| ) | ||
| .map((script) => AlterScriptDto.getInstance([script], true, false)); | ||
|
|
||
| const modifiedScriptDtos = modified | ||
| .map((sequence) => { | ||
| const oldSequence = _.find(oldItems, { id: sequence.id }) || {}; | ||
| return ddlProvider.alterSchemaSequence({ | ||
| schemaName, | ||
| sequence, | ||
| oldSequence, | ||
| }); | ||
| }) | ||
| .map((script) => AlterScriptDto.getInstance([script], true, false)); | ||
|
|
||
| return [ | ||
| ...modifiedScriptDtos, | ||
| ...removedScriptDtos, | ||
| ...addedScriptDtos, | ||
| ].filter(Boolean); | ||
| }; | ||
|
|
||
| /** | ||
| * @param {{ app: App }} | ||
| * @return {({ container }: { container: object }) => AlterScriptDto[]} | ||
| * */ | ||
| const getDeleteContainerSequencesScriptDtos = ({ app }) => ({ container }) => { | ||
| const _ = app.require('lodash'); | ||
| const ddlProvider = require('../../../ddlProvider')(null, null, app); | ||
| const { getDbName } = require('../../../utils/general')(_); | ||
| const schemaName = getDbName([container.role]); | ||
|
|
||
| return (container.role?.sequences || []) | ||
| .map((sequence) => ddlProvider.dropSchemaSequence({ schemaName, sequence })) | ||
| .map((script) => AlterScriptDto.getInstance([script], true, true)) | ||
| .filter(Boolean); | ||
| }; | ||
|
|
||
| module.exports = { | ||
| getAddContainerSequencesScriptDtos, | ||
| getModifyContainerSequencesScriptDtos, | ||
| getDeleteContainerSequencesScriptDtos, | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.