PHPLARA-256 Add Schema::ensureVectorExtensionExists() to check Atlas Search availability - #3558
Draft
GromNaN wants to merge 1 commit into
Draft
PHPLARA-256 Add Schema::ensureVectorExtensionExists() to check Atlas Search availability#3558GromNaN wants to merge 1 commit into
GromNaN wants to merge 1 commit into
Conversation
…Search availability Laravel uses this method to verify the vector extension is installed before creating vector indexes. On MongoDB, vector search indexes require Atlas Search, which is detected by listing the search indexes of a collection.
| try { | ||
| // The collection doesn't need to exist to know whether Atlas Search is available | ||
| $collection->listSearchIndexes(['name' => 'any']); | ||
| } catch (SearchNotSupportedException $exception) { |
| // The collection doesn't need to exist to know whether Atlas Search is available | ||
| $collection->listSearchIndexes(['name' => 'any']); | ||
| } catch (SearchNotSupportedException $exception) { | ||
| throw new RuntimeException($message . $exception->getMessage(), 0, $exception); |
| /** @internal */ | ||
| public static function isAtlasSearchNotSupportedException(ServerException $e): bool | ||
| { | ||
| if ($e instanceof SearchNotSupportedException) { |
There was a problem hiding this comment.
Pull request overview
Adds MongoDB support for Laravel’s Schema::ensureVectorExtensionExists() by treating Atlas Search availability as the “vector extension” prerequisite for creating/searching vector and search indexes.
Changes:
- Implement
MongoDB\Laravel\Schema\Builder::ensureVectorExtensionExists()to detect Atlas Search support vialistSearchIndexes()and throw aRuntimeExceptionwhen unsupported. - Update test infrastructure to skip/target Atlas Search–dependent tests based on server capability, and add coverage for
ensureVectorExtensionExists(). - Update the schema skill reference to document the new “fail early” workflow.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Schema/Builder.php |
Adds ensureVectorExtensionExists() and extends Atlas Search capability detection logic. |
tests/TestCase.php |
Refactors Atlas Search capability checks into reusable helpers for conditional skipping. |
tests/SchemaTest.php |
Adds tests for Schema::ensureVectorExtensionExists() for both supported/unsupported deployments. |
resources/boost/skills/laravel-mongodb/references/schema.md |
Documents calling Schema::ensureVectorExtensionExists() before creating search/vector search indexes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+401
to
+412
| $message = 'Atlas Search is not available on this MongoDB deployment. Use MongoDB Atlas or a local Atlas deployment. '; | ||
|
|
||
| try { | ||
| // The collection doesn't need to exist to know whether Atlas Search is available | ||
| $collection->listSearchIndexes(['name' => 'any']); | ||
| } catch (SearchNotSupportedException $exception) { | ||
| throw new RuntimeException($message . $exception->getMessage(), 0, $exception); | ||
| } catch (ServerException $exception) { | ||
| // mongodb/mongodb 1.x doesn't throw SearchNotSupportedException | ||
| if (self::isAtlasSearchNotSupportedException($exception)) { | ||
| throw new RuntimeException($message . $exception->getMessage(), 0, $exception); | ||
| } |
Comment on lines
+710
to
+712
| $this->expectException(RuntimeException::class); | ||
| $this->expectExceptionMessage('Atlas Search is not available on this MongoDB deployment.'); | ||
|
|
GromNaN
commented
Jul 30, 2026
Member
Author
There was a problem hiding this comment.
I mark this PR as "draft", waiting for PHPLARA-255.
|
|
||
| try { | ||
| // The collection doesn't need to exist to know whether Atlas Search is available | ||
| $collection->listSearchIndexes(['name' => 'any']); |
Member
Author
There was a problem hiding this comment.
We can bump the minimum version of the lib to 2.2, so this exception is always thrown. And not try to catch the exception.
This would be done with PHPLARA-255.
GromNaN
marked this pull request as draft
July 30, 2026 08:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PHPLARA-256
Laravel 12.51 added
Schema::ensureVectorExtensionExists()to verify that the vector extension is installed before creating vector columns and indexes. On PostgreSQL it creates thepgvectorextension; on other connections the base implementation throws "Extensions are only supported by Postgres".On MongoDB, the equivalent requirement for
Blueprint::vectorSearchIndex()is Atlas Search. The method now lists the search indexes of a collection, which does not need to exist, and converts the "not supported" server error into an explicitRuntimeException:MongoDB\Exception\SearchNotSupportedExceptionis caught when the installed version of mongodb/mongodb throws it, with a fallback on the error codes for older versions.