jackc / surus

PostgreSQL extensions for ActiveRecord

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

permission denied to create extension "hstore" / Update generator

romaind opened this issue · comments

In the generator for the migration when Postgresql version is above 9 it uses the command CREATE EXTENSION hstore

In some cases, creating the extension is not allowed by the role of the user used to connect to pg in the rails app. It causes the migration to crash.
But when the extension is already created on the database you're using, you might want this command to just be ignored, even if the pg user it is not allowed to execute it.

I propose to update the generator to provide the command CREATE EXTENSION IF NOT EXISTS hstore instead of CREATE EXTENSION hstore.
If I'm not mistaking, there is no drawbacks regarding this change as it ignores if not needed, if needed it tries to create the extension and then we're back in the previous way of working where it crashes if the user is not authorized.

If it's ok with you, I can provide a pull request quickly.

Seems to be a reasonable change.

Romain Durritçague wrote:

In the generator for the migration when Postgresql version is above 9
it uses the command |CREATE EXTENSION hstore|

In some cases, creating the extension is not allowed by the role of
the user used to connect to pg in the rails app. It causes the
migration to crash.
But when the extension is already created on the database you're
using, you might want this command to just be ignored, even if the pg
user it is not allowed to execute it.

I propose to update the generator to provide the command |CREATE
EXTENSION IF NOT EXISTS hstore| instead of |CREATE EXTENSION hstore|.
If I'm not mistaking, there is no drawbacks regarding this change as
it ignores if not needed, if needed it tries to create the extension
and then we're back in the previous way of working where it crashes if
the user is not authorized.

If it's ok with you, I can provide a pull request quickly.


Reply to this email directly or view it on GitHub
#18.