To create a migration with a vector field when using pgvector and Postgres, you can use the DB::statement() method to execute raw SQL queries in your migration. Here's an example migration that creates a users table with a vector field:
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->vector('embeddings')->nullable();
$table->timestamps();
});
DB::statement('CREATE INDEX users_embeddings_index ON users USING gist(embeddings)');
}
public function down()
{
Schema::dropIfExists('users');
}
}
Note that we're using the vector() method to define the embeddings field, which is not a standard field type for Laravel migrations. We're also creating a GIST index on the embeddings field using the DB::statement() method.
Hope this helps!