ruby-on-railspostgresqlmacospostgresql-13pgcrypto

How to install pgcrypto extension on postgres13 on MacOS


I'm using postgres13 and running a somewhat old ruby on rails project, it has a few migrations and one of the first lines on those migration files is: enable_extension "pgcrypto"

All the migrations with that fail.

After looking up online, most answers mention to download postgres-contrib package, which would in turn allow me to go into psql and create the extension.

I was only able to find that package for linux distributions. So I wonder if anyone can help me find a mac version, or some workaround.

I wonder also if I could solve this by installing an older version of postgresql that could come with this pre installed, but I'm not able to find that info anywhere. Any help appreciated.


Solution

  • Are you sure the extensions are not already there? Have you tried it install it with

    CREATE EXTENSION pgcrypto;
    

    To see if the module is available you can connect to your postgres DB and to the internal DB called postgres

    \c postgres
    

    then ask it what extensions are available:

    select * from pg_available_extensions;
    

    When I run this on my instance of Postgres.app running version 13 I get the entire list of extensions, with pgcrypto in there ready to be installed. You could use Postgres.app to do what you need, it's an excellent way to run multiple versions of postgresql on your Mac.