diff --git a/CHANGELOG.md b/CHANGELOG.md index 810aa28e1..7cf41a146 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ [#692](https://github.com/nextcloud/cookbook/pull/692) @christianlupus - Removed explicit dependency of @nextcloud/capabilities [#693](https://github.com/nextcloud/cookbook/pull/693) @christianlupus +- Add indices to database for all tables + [#698](https://github.com/nextcloud/cookbook/pull/698) @christianlupus ## 0.8.4 - 2021-03-08 diff --git a/lib/Migration/Version000000Date20210427082010.php b/lib/Migration/Version000000Date20210427082010.php new file mode 100644 index 000000000..e25a7540e --- /dev/null +++ b/lib/Migration/Version000000Date20210427082010.php @@ -0,0 +1,52 @@ +getTable('cookbook_names'); + if (! $namesTable->hasPrimaryKey()) { + $namesTable->setPrimaryKey(['recipe_id']); + } + + $categoriesTable = $schema->getTable('cookbook_categories'); + if (! $categoriesTable->hasIndex('categories_recipe_idx')) { + $categoriesTable->addIndex([ + 'user_id', + 'recipe_id', + ], 'categories_recipe_idx'); + } + + $keywordsTable = $schema->getTable('cookbook_keywords'); + if (! $keywordsTable->hasIndex('keywords_recipe_idx')) { + $keywordsTable->addIndex([ + 'user_id', + 'recipe_id', + ], 'keywords_recipe_idx'); + } + + return $schema; + } +}