From a14719f193340a52ff60353b054f31b9975f947b Mon Sep 17 00:00:00 2001 From: tpetry Date: Fri, 27 Sep 2024 08:30:41 +0200 Subject: [PATCH] fix: compatability to Laravel 11.25 (resolves #100) --- CHANGELOG.md | 4 ++++ README.md | 3 +++ src/Schema/BlueprintTypes.php | 2 +- tests/Migration/TypesTest.php | 4 ++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c199c0..85bc26b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.0] - 2024-09-27 +### Backward Incompatible Changes +* The dimensions value for the `vector` migration type is now required to copy the behavior of Laravel 11.25.0 + ## [1.1.1] - 2024-09-23 ### Fixed * Support PostgreSQL's `^@` starts with operator. diff --git a/README.md b/README.md index 2013488..296de0c 100644 --- a/README.md +++ b/README.md @@ -1334,6 +1334,9 @@ Schema::create('comments', function (Blueprint $table) { # Breaking Changes +* **2.0.0** + * Laravel 11.25 released a new `vector` migration type so the behaviour had to be aligned with Laravel's implementation: + * The `$dimensions` parameter (formerly with a default of 1536) is now required * **1.0.0** * Laravel 11.17 released a new `whereLike` and `orWhereLike` builder method so the behaviour had to be aligned with Laravel's implementation: * The value is now searched case-insensitive by default instead of case-sensitive diff --git a/src/Schema/BlueprintTypes.php b/src/Schema/BlueprintTypes.php index 3b2bbec..b863bb6 100644 --- a/src/Schema/BlueprintTypes.php +++ b/src/Schema/BlueprintTypes.php @@ -251,7 +251,7 @@ public function varbit(string $column, ?int $length = null): ColumnDefinition /** * Create a new vector column on the table. */ - public function vector(string $column, int $dimensions = 1536): ColumnDefinition + public function vector($column, $dimensions): ColumnDefinition { return $this->addColumn('vector', $column, compact('dimensions')); } diff --git a/tests/Migration/TypesTest.php b/tests/Migration/TypesTest.php index 5ac021b..169c3ed 100644 --- a/tests/Migration/TypesTest.php +++ b/tests/Migration/TypesTest.php @@ -375,8 +375,8 @@ public function testVectorTypeIsSupported(): void $this->getConnection()->statement('CREATE EXTENSION IF NOT EXISTS vector'); $queries = $this->runMigrations( - fnCreate: fn (Blueprint $table) => $table->vector('col'), - fnChange: fn (Blueprint $table) => $table->vector('col')->change(), + fnCreate: fn (Blueprint $table) => $table->vector('col', 1536), + fnChange: fn (Blueprint $table) => $table->vector('col', 1536)->change(), ); $this->assertEquals('create table "test" ("col" vector(1536) not null)', $queries[0]['query'] ?? null);