Rails 8.1.3 does not recognize pgvector extension vector columns on PostgreSQL 18
Author: da-vinci-noobCreated Jun 14, 2026Updated Sep 13, 2026
Labelsstale
Steps to reproduce
PostgreSQL 18.4 with pgvector extension 0.8.2
Migration:
class EnableVector < ActiveRecord::Migration[8.1]
def change
enable_extension "vector"
execute <<~SQL
CREATE TABLE items (
id bigserial PRIMARY KEY,
embedding vector(1536)
)
SQL
end
end
Model:
class Item < ApplicationRecord
self.table_name = "items"
end
Console:
Item.columns_hash["embedding"]
Actual behavior
Rails logs:
unknown OID XXXXX: failed to recognize type of 'embedding'
Column metadata shows:
@sql_type = "vector(1536)"
@type = nil
Expected behavior
Rails should recognize the column as a vector type and map it using ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Vector.
Additional information
The vector type exists:
SELECT oid, typname, typelem, typtype
FROM pg_type
WHERE typname = 'vector';
Result:
typname = vector
typelem = 0
typtype = b
Rails includes:
ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Vector
but the OID is not registered.
System configuration
Rails version: Rails 8.1.3
Ruby version: Ruby 4.0.5
Source: rails/rails