The Wayback Machine - https://web.archive.org/web/20231220065035/https://github.com/laravel/framework/pull/49204
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Get indexes of a table #49204

Merged
merged 5 commits into from Dec 5, 2023

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Dec 1, 2023

This PR adds Schema::getIndexes() method to get indexes' info of the given table.

Usage

Just like Schema::getColumns() added on #48357, the new Schema::getIndexes()method is to inspect the tables' indexes.

Schema::getIndexes()

  • name (string): Name of the index
  • columns (string[]): Array of indexed columns
  • type (?string): Index type.
    • SQLite: null
    • MySQL: btree, fulltext, hash, rtree, spatial
    • PostgreSQL: btree, hash, gist, spgist, gin, brin
    • SQL Server: heap, clustered, nonclustered, xml, spatial, clustered columnstore, nonclustered columnstore, nonclustered hash
  • unique (boolean): Is unique index?
  • primary (boolean): Is primary index?
@hafezdivandari hafezdivandari marked this pull request as ready for review December 1, 2023 00:58
@liamkeily
Copy link
Contributor

Nice work. It would be great to have Schema::hasIndex as well, to go with Schema::hasColumn

@hafezdivandari
Copy link
Contributor Author

@liamkeily thanks for your comment, I totally agree, but these PRs are quite large and I don't want to add too many methods at once, that makes the PR difficult to review. Helper functions like Schema::hasIndex can easily be implemented later.

@hafezdivandari hafezdivandari mentioned this pull request Dec 1, 2023
30 tasks
@taylorotwell taylorotwell merged commit 7d26bfb into laravel:10.x Dec 5, 2023
20 checks passed
@hafezdivandari hafezdivandari deleted the 10.x-indexes-foreign-keys branch December 6, 2023 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants