Skip to content

Commit 7f1f801

Browse files
authored
Document PostgreSQL index access method reflection (#8277)
1 parent 5756f27 commit 7f1f801

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

docs/en/appendices/5-4-migration-guide.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ version is reported as `unknown`), the header is omitted.
9898
See [Query Builder](../orm/query-builder#advanced-conditions).
9999
- Added `inOrNull()` and `notInOrNull()` methods for combining `IN` conditions with `IS NULL`.
100100
- Added `isDistinctFrom()` and `isNotDistinctFrom()` methods for null-safe comparisons.
101+
- Added PostgreSQL index access method reflection. Non-btree indexes (`gin`,
102+
`gist`, `spgist`, `brin`, `hash`) are now reflected with an `accessMethod`
103+
field and regenerated with the correct `USING` clause. The `Index` class
104+
provides constants (`Index::GIN`, `Index::GIST`, `Index::SPGIST`,
105+
`Index::BRIN`, `Index::HASH`) for these access methods.
106+
See [Reading Indexes and Constraints](../orm/schema-system#reading-indexes-and-constraints).
101107

102108
### I18n
103109

docs/en/orm/schema-system.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,28 @@ $indexes = $schema->indexes()
182182
$index = $schema->index('author_id_idx')
183183
```
184184

185+
#### PostgreSQL Index Access Methods
186+
187+
::: info Added in version 5.4.0
188+
:::
189+
190+
When reflecting indexes on PostgreSQL, non-btree indexes include an
191+
`accessMethod` field identifying the underlying index type (`gin`, `gist`,
192+
`spgist`, `brin`, `hash`). Schemas generated from these reflections will emit
193+
the appropriate `USING` clause when recreating the index.
194+
195+
```php
196+
$schema->addIndex('articles_tags_idx', [
197+
'columns' => ['tags'],
198+
'type' => 'index',
199+
'accessMethod' => 'gin',
200+
]);
201+
```
202+
203+
The `Cake\Database\Schema\Index` class exposes constants for the supported
204+
access methods: `Index::GIN`, `Index::GIST`, `Index::SPGIST`, `Index::BRIN`,
205+
and `Index::HASH`. Btree indexes (the default) omit the `accessMethod` field.
206+
185207
### Adding Table Options
186208

187209
Some drivers (primarily MySQL) support and require additional table metadata. In

0 commit comments

Comments
 (0)