| Total Complexity | 5 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class UpdateIndexMapping extends AbstractMigration |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * Get validation rules |
||
| 10 | * |
||
| 11 | * @return array |
||
| 12 | */ |
||
| 13 | 5 | public function getValidationRules(): array |
|
| 14 | { |
||
| 15 | return [ |
||
| 16 | 5 | 'index' => 'required|string', |
|
| 17 | 'type' => 'required|string', |
||
| 18 | 'ignore_conflicts' => 'boolean', |
||
| 19 | 'body' => 'required|array', |
||
| 20 | 'body.properties' => 'required|array' |
||
| 21 | ]; |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Pre check |
||
| 26 | * |
||
| 27 | * @param Client $esClient |
||
| 28 | * @param array $params |
||
| 29 | * |
||
| 30 | * @throws \Exception |
||
| 31 | */ |
||
| 32 | 2 | public function preCheck(Client $esClient, array $params) |
|
| 33 | { |
||
| 34 | 2 | $index = $params['index']; |
|
| 35 | 2 | if (!$esClient->indices()->exists(['index' => $index])) { |
|
| 36 | 1 | throw new \Exception(sprintf("Index not exist: %s", $index)); |
|
| 37 | } |
||
| 38 | 1 | } |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Start migration |
||
| 42 | * |
||
| 43 | * @param Client $esClient |
||
| 44 | * @param array $params |
||
| 45 | */ |
||
| 46 | 1 | public function startMigration(Client $esClient, array $params) |
|
| 47 | { |
||
| 48 | 1 | $esClient->indices()->putMapping($params); |
|
| 49 | 1 | } |
|
| 50 | |||
| 51 | /** |
||
| 52 | * Post check |
||
| 53 | * |
||
| 54 | * @param Client $esClient |
||
| 55 | * @param array $params |
||
| 56 | * |
||
| 57 | * @throws \Exception |
||
| 58 | */ |
||
| 59 | 1 | public function postCheck(Client $esClient, array $params) |
|
| 61 | // |
||
| 62 | 1 | } |
|
| 63 | } |
||
| 64 |