Skip to content

Add PostgreSQL index access method reflection support#19369

Open
dereuromark wants to merge 2 commits into5.nextfrom
feature/postgres-index-access-methods
Open

Add PostgreSQL index access method reflection support#19369
dereuromark wants to merge 2 commits into5.nextfrom
feature/postgres-index-access-methods

Conversation

@dereuromark
Copy link
Copy Markdown
Member

Summary

This adds the ability to reflect PostgreSQL index access methods (gin, gist, spgist, brin, hash) when describing indexes.

Changes:

  • Add accessMethod property to Index class with constants for PostgreSQL access methods (GIN, GIST, SPGIST, BRIN, HASH)
  • Update describeIndexQuery() to join pg_am and fetch amname
  • Update describeIndexes() and convertIndexDescription() to include accessMethod in result for non-btree indexes
  • Update indexSql() to generate USING clause for non-btree indexes

Why:

This enables migrations (cakephp/migrations#1053) to properly reflect and regenerate indexes that use specialized PostgreSQL access methods. Without reflection support, snapshot generation would be lossy - indexes created with GIN/GIST/etc would be reflected as standard btree indexes.

Usage

When an index uses a non-btree access method, the reflected index data will include the accessMethod field:

// Example reflected GIN index
[
    'name' => 'articles_tags_idx',
    'type' => 'index',
    'columns' => ['tags'],
    'accessMethod' => 'gin',
]

The Index class now includes constants for PostgreSQL access methods:

Index::GIN    // 'gin'
Index::GIST   // 'gist'
Index::SPGIST // 'spgist'
Index::BRIN   // 'brin'
Index::HASH   // 'hash'

Refs cakephp/migrations#1053

This adds the ability to reflect PostgreSQL index access methods
(gin, gist, spgist, brin, hash) when describing indexes.

Changes:
- Add `accessMethod` property to Index class with constants for
  PostgreSQL access methods (GIN, GIST, SPGIST, BRIN, HASH)
- Update describeIndexQuery() to join pg_am and fetch amname
- Update describeIndexes() and convertIndexDescription() to include
  accessMethod in result for non-btree indexes
- Update indexSql() to generate USING clause for non-btree indexes

This enables migrations to properly reflect and regenerate indexes
that use specialized PostgreSQL access methods.

Refs cakephp/migrations#1053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant