-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend] fix max shareable markings migration (#7392)
- Loading branch information
Showing
3 changed files
with
52 additions
and
14 deletions.
There are no files selected for viewing
24 changes: 15 additions & 9 deletions
24
...rm/opencti-graphql/src/migrations/1713449762001-add-platform-data-sharing-max-markings.js
This file contains 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
This file contains 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
33 changes: 33 additions & 0 deletions
33
...orm/opencti-graphql/src/migrations/1718631740774-remove-platform-data-sharing-markings.js
This file contains 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,33 @@ | ||
import { logApp } from '../config/conf'; | ||
import { elUpdateByQueryForMigration } from '../database/engine'; | ||
import { READ_INDEX_INTERNAL_OBJECTS } from '../database/utils'; | ||
|
||
const message = '[MIGRATION] Remove platform_max_shareable_markings field from Settings'; | ||
|
||
export const up = async (next) => { | ||
logApp.info(`${message} > started`); | ||
const updateQuery = { | ||
script: { | ||
params: { fieldToRemove: 'platform_data_sharing_max_markings' }, | ||
source: 'ctx._source.remove(params.fieldToRemove)', | ||
}, | ||
query: { | ||
bool: { | ||
must: [ | ||
{ term: { 'entity_type.keyword': { value: 'Settings' } } }, | ||
], | ||
}, | ||
}, | ||
}; | ||
await elUpdateByQueryForMigration( | ||
message, | ||
READ_INDEX_INTERNAL_OBJECTS, | ||
updateQuery | ||
); | ||
logApp.info(`${message} > done`); | ||
next(); | ||
}; | ||
|
||
export const down = async (next) => { | ||
next(); | ||
}; |