ruby-on-railsrubypostgresqlamazon-web-servicesrake

ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR: permission denied for relation schema_migrations


I have a local project, with rails and postgres. I threw it up on my AWS Amazon Linux AMI. I have run test projects with rails and postgres on the server. However when I uploaded my local project, and try to run

rake db:migrate

I get the following error:

ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR:  permission denied for relation schema_migrations

I saw some similar issues, but none of them help. I do have the proper role setup and connected.


Solution

  • I'm not sure if you're running rake db:migrate with RAILS_ENV as production or development. Whichever it is (development by default), in your config/database.yml it will say the user, password, and database it is running on. That user must have ALL privileges on the public.schema_migrations table. If it does, and it's still not working, make sure that user has ALL privileges on the public schema.

    Read more about manipulating postgres database privileges here. Postgres has excellent documentation.

    One more thing: if you're creating this database locally, and trying to create the initial database instead of actually running a migration, use rake db:schema:load instead of rake db:migrate. Never run this on production, as it will delete your data!