Skip to content

Commit 503c5e9

Browse files
committed
fix: compatability with upcoming Laravel 11.30 release
1 parent a14719f commit 503c5e9

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/Schema/BlueprintTypes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function varbit(string $column, ?int $length = null): ColumnDefinition
251251
/**
252252
* Create a new vector column on the table.
253253
*/
254-
public function vector($column, $dimensions): ColumnDefinition
254+
public function vector($column, $dimensions = null): ColumnDefinition
255255
{
256256
return $this->addColumn('vector', $column, compact('dimensions'));
257257
}

src/Schema/Grammars/GrammarTypes.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,10 @@ protected function typeVarbit(Fluent $column): string
315315
*/
316316
protected function typeVector(Fluent $column): string
317317
{
318-
return "vector({$column['dimensions']})";
318+
return match ($column['dimensions']) {
319+
null => 'vector',
320+
default => "vector({$column['dimensions']})",
321+
};
319322
}
320323

321324
/**

tests/Migration/TypesTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,17 @@ public function testVectorTypeIsSupported(): void
375375

376376
$this->getConnection()->statement('CREATE EXTENSION IF NOT EXISTS vector');
377377
$queries = $this->runMigrations(
378-
fnCreate: fn (Blueprint $table) => $table->vector('col', 1536),
379-
fnChange: fn (Blueprint $table) => $table->vector('col', 1536)->change(),
378+
fnCreate: function (Blueprint $table): void {
379+
$table->vector('col1', 1536);
380+
$table->vector('col2');
381+
},
382+
fnChange: function (Blueprint $table): void {
383+
$table->vector('col1', 1536)->change();
384+
$table->vector('col2')->change();
385+
},
380386
);
381387

382-
$this->assertEquals('create table "test" ("col" vector(1536) not null)', $queries[0]['query'] ?? null);
388+
$this->assertEquals('create table "test" ("col1" vector(1536) not null, "col2" vector not null)', $queries[0]['query'] ?? null);
383389
}
384390

385391
public function testXmlTypeIsSupported(): void

0 commit comments

Comments
 (0)