-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f545ff
commit 9eedd02
Showing
2 changed files
with
35 additions
and
2 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
29 changes: 29 additions & 0 deletions
29
x-pack/plugins/ingest_manager/server/saved_objects/migrations/datasources_v790.ts
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,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { SavedObjectMigrationFn } from 'kibana/server'; | ||
import { cloneDeep } from 'lodash'; | ||
import { Datasource } from '../../types/models'; | ||
|
||
type Pre790Datasource = Exclude< | ||
Datasource, | ||
'created_on' | 'created_by' | 'updated_on' | 'updated_by' | ||
>; | ||
|
||
export const migrateDatasourcesToV790: SavedObjectMigrationFn< | ||
Pre790Datasource, | ||
Datasource | ||
> = doc => { | ||
const updatedDatasource = cloneDeep(doc); | ||
const defDate = new Date().toISOString(); | ||
|
||
updatedDatasource.attributes.created_by = 'system'; | ||
updatedDatasource.attributes.created_on = updatedDatasource?.updated_at ?? defDate; | ||
updatedDatasource.attributes.updated_by = 'system'; | ||
updatedDatasource.attributes.updated_on = updatedDatasource?.updated_at ?? defDate; | ||
|
||
return updatedDatasource; | ||
}; |