Rails 6 with Que and Dockerized PostgreSQL

225 Views Asked by At

I have a Rails 5.2 app on my local Mac with PostgreSQL 9.6 running on Docker. The app uses Que to process background jobs (version 0.12.3).

To make things work, I originally added the following to my ~/.bash_profile (postgres9-6 is the name of the container running PG)

alias pg_dump='docker exec postgres9-6 pg_dump'

With that, everything works fine: I can run migrations and specs.

I'm in the process of upgrading to Rails 6.0, and now things don't work anymore.

After installing Rails 6.0.3.2 and updating some configuration files, I tried to run my RSpec suite (RUBYOPT="-W0" bin/rspec spec) but I got

rails aborted! failed to execute: psql -v ON_ERROR_STOP=1 -q -X -f /Users/sig/Code/traininghub/db/structure.sql traininghub_test

Please check the output above for any errors and make sure that psql is installed in your PATH and has proper permissions.

bin/rails:4:in `' Tasks: TOP => db:test:load_structure (See full trace by running task with --trace) Migrations are pending. To resolve this issue, run:

    rails db:migrate RAILS_ENV=test No examples found.

Not sure why it says migrations are pending which is not true, but I tried to run rails db:migrate RAILS_ENV=test --trace, which produces the followings:

** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:structure:dump (first_time)
** Invoke db:load_config
** Execute db:structure:dump rails aborted! failed to execute: pg_dump -s -x -O -f /Users/sig/Code/traininghub/db/structure.sql traininghub_test

Please check the output above for any errors and make sure that `pg_dump` is installed in your PATH and has proper permissions.

I have tried to run the pg_dump command directly and it doesn't print any errors.

sig$ pg_dump -s -x -O -f /Users/sig/Code/traininghub/db/structure.sql traininghub_test 
sig$

I have also added the following line to my ~/.bash_profile

alias psql='docker exec postgres9-6 psql'

But I get the same error.

I have tried to upgrade que to 0.14.3 (latest stable release) and 1.0 beta4 but the outcome is always the same.

Am I missing anything here?

0

There are 0 best solutions below