diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /doc/development/search/advanced_search_migration_styleguide.md | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'doc/development/search/advanced_search_migration_styleguide.md')
-rw-r--r-- | doc/development/search/advanced_search_migration_styleguide.md | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/doc/development/search/advanced_search_migration_styleguide.md b/doc/development/search/advanced_search_migration_styleguide.md index d7c0dddee7b..10c4fa3dcc6 100644 --- a/doc/development/search/advanced_search_migration_styleguide.md +++ b/doc/development/search/advanced_search_migration_styleguide.md @@ -6,13 +6,25 @@ info: To determine the technical writer assigned to the Stage/Group associated w # Advanced search migration style guide -## Creating a new advanced search migration - -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/234046) in GitLab 13.6. +## Create a new advanced search migration NOTE: This functionality is only supported for indices created in GitLab 13.0 and later. +### With a script + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/414674) in GitLab 16.3. + +Execute `scripts/elastic-migration` and follow the prompts to create: + +- A migration file to define the migration: `ee/elastic/migrate/YYYYMMDDHHMMSS_migration_name.rb` +- A spec file to test the migration: `ee/spec/elastic/migrate/YYYYMMDDHHMMSS_migration_name_spec.rb` +- A dictionary file to identify the migration: `ee/elastic/docs/YYYYMMDDHHMMSS_migration_name.yml` + +### Manually + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/234046) in GitLab 13.6. + In the [`ee/elastic/migrate/`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/ee/elastic/migrate) folder, create a new file with the filename format `YYYYMMDDHHMMSS_migration_name.rb`. This format is the same for Rails database migrations. ```ruby @@ -198,6 +210,27 @@ class MigrationName < Elastic::Migration end ``` +#### `Search::Elastic::MigrationReindexBasedOnSchemaVersion` + +Reindexes all documents in the index that stores the specified document type and updates `schema_version`. + +Requires the `DOCUMENT_TYPE` and `NEW_SCHEMA_VERSION` constants. +The index mapping must have a `schema_version` integer field in a `YYMM` format. + +```ruby +class MigrationName < Elastic::Migration + include Search::Elastic::MigrationReindexBasedOnSchemaVersion + + batched! + batch_size 9_000 + throttle_delay 1.minute + + DOCUMENT_TYPE = WorkItem + NEW_SCHEMA_VERSION = 23_08 + UPDATE_BATCH_SIZE = 100 +end +``` + #### `Elastic::MigrationHelper` Contains methods you can use when a migration doesn't fit the previous examples. |