Skip to content

A platform for community discussion. Free, open, simple.

DEV: Resolve 'unknown OID' warnings for pgvector columns (#35393)

David Taylor6247fdc255d2
diff --git a/plugins/discourse-ai/plugin.rb b/plugins/discourse-ai/plugin.rb
index ce3ce0695f4..bd4ff213421 100644
--- a/plugins/discourse-ai/plugin.rb
+++ b/plugins/discourse-ai/plugin.rb
@@ -72,6 +72,9 @@ DiscourseAi::Configuration::Module::NAMES.each do |module_name|
end
after_initialize do
+ # No ActiveRecord for these models. Avoids the "unknown OID" warnings.
+ ActiveRecord.schema_cache_ignored_tables.push(*DiscourseAi::Embeddings::Schema::EMBEDDING_TABLES)
+
if defined?(Rack::MiniProfiler)
Rack::MiniProfiler.config.skip_paths << "/discourse-ai/ai-bot/artifacts"
end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index bb2b3234565..ff5f2ba1160 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -740,26 +740,8 @@ RSpec.configure do |config|
# To work around this problem, we are going to preload all the model schemas before running any system tests so that
# the lock in ActiveRecord::ModelSchema is not acquired at runtime. This is a temporary workaround while we report
# the issue to the Rails.
-
- # TODO: halfvec in AI embedding tables is not supported by Rails
- # it causes a noisy stderr warning cause it is missing from the PG
- # typemap.
- #
- # This workaround will suppress the noise until Rails adds support
- suppress_embedding_warnings =
- proc do |&blk|
- stderr_orig = $stderr
- $stderr = StringIO.new
- blk.call
- warning = $stderr.string
- if warning.present? && !warning.include?("failed to recognize type of 'embeddings'")
- stderr_orig.print warning
- end
- $stderr = stderr_orig
- end
-
ActiveRecord::Base.connection.data_sources.map do |table|
- suppress_embedding_warnings.call { ActiveRecord::Base.connection.schema_cache.add(table) }
+ ActiveRecord::Base.connection.schema_cache.add(table)
end
system_tests_initialized = true