A platform for community discussion. Free, open, simple.
FIX: Check for pgvector before CREATE EXTENSION (#35070)
Awen Saunders4d20baa8754f
diff --git a/plugins/discourse-ai/db/migrate/20230710171141_enable_pg_vector_extension.rb b/plugins/discourse-ai/db/migrate/20230710171141_enable_pg_vector_extension.rbindex a6acb31902b..b58195c93aa 100644--- a/plugins/discourse-ai/db/migrate/20230710171141_enable_pg_vector_extension.rb+++ b/plugins/discourse-ai/db/migrate/20230710171141_enable_pg_vector_extension.rb@@ -2,17 +2,19 @@class EnablePgVectorExtension < ActiveRecord::Migration[7.0]def change- begin- enable_extension :vector- rescue Exception => e- if DB.query_single("SELECT 1 FROM pg_available_extensions WHERE name = 'vector';").empty?- STDERR.puts "------------------------------DISCOURSE AI ERROR----------------------------------"- STDERR.puts " Discourse AI requires the pgvector extension on the PostgreSQL database."- STDERR.puts " Run a `./launcher rebuild app` to fix it on a standard install."- STDERR.puts " Alternatively, you can remove Discourse AI to rebuild."- STDERR.puts "------------------------------DISCOURSE AI ERROR----------------------------------"+ unless extension_enabled?(:vector)+ begin+ enable_extension :vector+ rescue StandardError => e+ if DB.query_single("SELECT 1 FROM pg_available_extensions WHERE name = 'vector';").empty?+ STDERR.puts "------------------------------DISCOURSE AI ERROR----------------------------------"+ STDERR.puts " Discourse AI requires the pgvector extension on the PostgreSQL database."+ STDERR.puts " Run a `./launcher rebuild app` to fix it on a standard install."+ STDERR.puts " Alternatively, you can remove Discourse AI to rebuild."+ STDERR.puts "------------------------------DISCOURSE AI ERROR----------------------------------"+ end+ raise eend- raise eendendend