I’ve installed the pg_search gem in a Rails project and I got this error:
PG::UndefinedFunction: ERROR: function word_similarity(unknown, text) does not exist
In my dev environment I simply connected to my local DB and executed this command:
CREATE EXTENSION pg_trgm;
I got the same error when deployed to Fly, connected to the DB using fly pg connect --app xxxx and tried to run the same query but with no success this time.
I found the issue: when I run fly pg connect --app xxx it gets connected to the default database. So I installed the extension in that database, not in the one the app is currently using. I had to connect to that database with the \c database_name command and then run the command again.
Also, I had to reboot the database with fly pg restart.