# frozen_string_literal: true # Adds a vector column to store text embeddings of the package # description and long description. The vectors are computed by an # external web service and used for nearest neighbor search. # # The pgvector extension is enabled by the InstallNeighborVector migration. class AddEmbeddingToPackages < ActiveRecord::Migration[8.1] def change add_column :packages, :embedding, :vector, limit: 384 # HNSW index for fast approximate nearest neighbor searches add_index :packages, :embedding, using: :hnsw, opclass: :vector_cosine_ops end end