Skip to content

Commit e87b09d

Browse files
committed
Revert "Support adding schema validation (#3397)"
This reverts commit 7a0f0bc.
1 parent fe0bb00 commit e87b09d

File tree

2 files changed

+0
-52
lines changed

2 files changed

+0
-52
lines changed

src/Schema/Blueprint.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use MongoDB\Laravel\Connection;
1010

1111
use function array_flip;
12-
use function array_merge;
1312
use function implode;
1413
use function in_array;
1514
use function is_array;
@@ -118,24 +117,6 @@ public function hasIndex($indexOrColumns = null)
118117
return false;
119118
}
120119

121-
public function jsonSchema(
122-
array $schema = [],
123-
?string $validationLevel = null,
124-
?string $validationAction = null,
125-
): void {
126-
$options = array_merge(
127-
[
128-
'validator' => [
129-
'$jsonSchema' => $schema,
130-
],
131-
],
132-
$validationLevel ? ['validationLevel' => $validationLevel] : [],
133-
$validationAction ? ['validationAction' => $validationAction] : [],
134-
);
135-
136-
$this->connection->getDatabase()->modifyCollection($this->collection->getCollectionName(), $options);
137-
}
138-
139120
/**
140121
* @param string|array $indexOrColumns
141122
*

tests/SchemaTest.php

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -63,39 +63,6 @@ public function testCreateWithOptions(): void
6363
$this->assertEquals(1024, $collection['options']['size']);
6464
}
6565

66-
public function testCreateWithSchemaValidator(): void
67-
{
68-
$schema = [
69-
'bsonType' => 'object',
70-
'required' => [ 'username' ],
71-
'properties' => [
72-
'username' => [
73-
'bsonType' => 'string',
74-
'description' => 'must be a string and is required',
75-
],
76-
],
77-
];
78-
79-
Schema::create(self::COLL_2, function (Blueprint $collection) use ($schema) {
80-
$collection->string('username');
81-
$collection->jsonSchema(schema: $schema, validationAction: 'warn');
82-
});
83-
84-
$this->assertTrue(Schema::hasCollection(self::COLL_2));
85-
$this->assertTrue(Schema::hasTable(self::COLL_2));
86-
87-
$collection = Schema::getCollection(self::COLL_2);
88-
$this->assertEquals(
89-
['$jsonSchema' => $schema],
90-
$collection['options']['validator'],
91-
);
92-
93-
$this->assertEquals(
94-
'warn',
95-
$collection['options']['validationAction'],
96-
);
97-
}
98-
9966
public function testDrop(): void
10067
{
10168
Schema::create(self::COLL_1);

0 commit comments

Comments
 (0)