Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment on Heroku #11

Closed
dedman opened this issue Aug 9, 2016 · 8 comments
Closed

Deployment on Heroku #11

dedman opened this issue Aug 9, 2016 · 8 comments

Comments

@dedman
Copy link

dedman commented Aug 9, 2016

First of all, awesome gem!

I just tried to deploy to Heroku, and the migration returned this error.

ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR: permission denied to set parameter "logidze.disabled" CONTEXT: SQL statement "ALTER DATABASE ***DB_NAME*** SET logidze.disabled TO off"

Any ideas on how this might be fixed?

@palkan
Copy link
Owner

palkan commented Aug 9, 2016

Logidze uses custom database variables (to conditionally track changes and responsible users) and thus requires superuser privileges (unless 9.6 haven't been released).

And Heroku doesn't provide superuser access (or other ways to alter databases or roles).

So, I had no idea how we can fix this for 9.5 so far. Sorry(
I need a little bit more time for investigation.

@nobodyzzz
Copy link

Face the same issue on Amazon RDS, as workaround use this:

require 'active_record/connection_adapters/postgresql_adapter'

ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.set_callback :checkout, :after do
  execute("SELECT set_config('logidze.disabled', 'off', false)")
  execute("SELECT set_config('logidze.responsible', 'off', false)")
end

(Put to config/initializers/logidze_workaround.rb)

@palkan
Copy link
Owner

palkan commented Nov 17, 2016

@nobodyzzz Thanks for the workaround! Added to the readme.

I just want to add that you still have to remove "ALTER DATABASE ..." statements from the installation migration.

@palkan
Copy link
Owner

palkan commented Nov 17, 2016

@dedman
I've updated the gem (version 0.3.1), now should work on Heroku with PostgreSQL 9.6 without any tweak.

@palkan palkan closed this as completed Nov 17, 2016
@dedman
Copy link
Author

dedman commented Nov 17, 2016

Thanks @palkan!

@Frexuz
Copy link
Contributor

Frexuz commented May 4, 2018

Then why is the alter database statements still in the generated migration template if it's not needed? 🤔
https://github.com/palkan/logidze/blob/master/lib/generators/logidze/install/templates/migration.rb.erb#L10

@palkan
Copy link
Owner

palkan commented May 4, 2018

These statements are only included for PostgreSQL <9.6 where we need them (see #11 (comment))

@Frexuz
Copy link
Contributor

Frexuz commented May 4, 2018

Ah, my mistake :) Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants