-
Notifications
You must be signed in to change notification settings - Fork 976
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend] Migration to remove representative in DB (#7484)
(cherry picked from commit af5f572)
- Loading branch information
1 parent
7aa1381
commit 9ae038c
Showing
3 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
opencti-platform/opencti-graphql/src/migrations/1718719160224-remove-representative.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,31 @@ | ||
import { logApp } from '../config/conf'; | ||
import { elUpdateByQueryForMigration } from '../database/engine'; | ||
import { READ_DATA_INDICES } from '../database/utils'; | ||
|
||
const message = '[MIGRATION] Remove representative field'; | ||
|
||
export const up = async (next) => { | ||
logApp.info(`${message} > started`); | ||
const updateQuery = { | ||
script: { | ||
params: { fieldToRemove: 'representative' }, | ||
source: 'ctx._source.remove(params.fieldToRemove)', | ||
}, | ||
query: { | ||
bool: { | ||
must: [{ exists: { field: 'representative' } }], | ||
}, | ||
}, | ||
}; | ||
await elUpdateByQueryForMigration( | ||
message, | ||
READ_DATA_INDICES, | ||
updateQuery | ||
); | ||
logApp.info(`${message} > done`); | ||
next(); | ||
}; | ||
|
||
export const down = async (next) => { | ||
next(); | ||
}; |