You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The deployer creates versioned physical indexes and tracks their lifecycle in the `opensearch_deployments` table. Applications remain responsible for backfilling and validating candidate documents.
141
+
142
+
First, create a stable alias for the index in a migration:
143
+
144
+
```php
145
+
Index::putAlias('posts', 'posts_search');
146
+
```
147
+
148
+
Start a deployment with the latest mapping and settings:
149
+
150
+
```php
151
+
use DirectoryTree\OpenSearchAdapter\Indices\Mapping;
152
+
use DirectoryTree\OpenSearchAdapter\Indices\Settings;
153
+
use DirectoryTree\OpenSearchMigrations\Deployer;
154
+
155
+
$deployer = app(Deployer::class);
156
+
157
+
$deployment = $deployer->start(
158
+
name: 'posts',
159
+
alias: 'posts_search',
160
+
configure: function (Mapping $mapping, Settings $settings) {
161
+
$mapping->text('title');
162
+
$mapping->text('body');
163
+
},
164
+
);
165
+
```
166
+
167
+
The returned deployment exposes the physical candidate index for backfilling:
168
+
169
+
```php
170
+
$deployment->candidateIndex;
171
+
```
172
+
173
+
While backfilling, send live writes and deletions to every deployment write index:
174
+
175
+
```php
176
+
$deployment->writeIndexes();
177
+
```
178
+
179
+
After application-specific validation succeeds, mark the candidate ready and atomically move the alias:
180
+
181
+
```php
182
+
$deployer->markReady('posts');
183
+
$deployer->cutover('posts');
184
+
```
185
+
186
+
Cancel and delete a candidate that should not be promoted:
187
+
188
+
```php
189
+
$deployer->cancel('posts');
190
+
```
191
+
192
+
The previous index remains in the deployment's write indexes during the rollback window:
193
+
194
+
```php
195
+
$deployer->rollback('posts');
196
+
```
197
+
198
+
Once the new index is verified in production, delete the previous physical index and complete the deployment:
199
+
200
+
```php
201
+
$deployer->retire('posts');
202
+
```
203
+
204
+
`opensearch:migrate:fresh` deletes all deployment records because it drops all physical indexes. Migration reset and refresh commands refuse to run while managed deployments exist.
205
+
127
206
## Credits
128
207
129
208
This package builds on a lot of the foundation and prior work from [Ivan Babenko](https://github.com/babenkoivan) and his Elasticsearch Laravel ecosystem packages.
0 commit comments