jackc / surus

PostgreSQL extensions for ActiveRecord
MIT License
395 stars 35 forks source link

permission denied to create extension "hstore" / Update generator #18

Closed romaind closed 9 years ago

romaind commented 9 years ago

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.

jackc commented 9 years ago

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 https://github.com/jackc/surus/issues/18.