Commit Redux with Postgresql in Production
Friday May 09 2025 • 04:06 PM
I think trying to get sqlite3 working with dokku is more trouble than it’s worth because the container has tons of permission issues with the persistent storage. Time to use postgresql in production.
Postgresql dokku plugin
$ dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
Create Postgres db service in dokku
$ dokku postgres:create commit-redux-db
Link service to app
$ dokku postgres:link commit-redux-db commit-redux
This showed an error because I hadn’t added the pg gem to the Gemfile. I also had to fix my environment.rb file.
if ENV['RACK_ENV'] == 'production' set :database, ENV['DATABASE_URL'] else set :database, { adapter: 'sqlite3', database: 'db/development.sqlite3' } end
So with this changed, I ran $ dokku postgres:link commit-redux-db commit-redux
again, but it said the db was already linked.
I ran the migration with $ dokku run commit-redux rake db:migrate
Which showed:
rake aborted! Errno::EACCES: Permission denied @ rb_sysopen - db/schema.rb (Errno::EACCES)
It seems like this was due to how I had configured my environment.rb file, so I fixed it with:
db_config = if ENV['RACK_ENV'] == 'production' { adapter: 'postgresql', url: ENV['DATABASE_URL'] } else { adapter: 'sqlite3', database: 'db/development.sqlite3' } end set :database, db_config
Now let’s hope migrations work 🤞
$ dokku run commit-redux rake db:migrate
and… same issue :-(