Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg_dump error while running rake db:migrate

I have postgres container and a ruby container. When running docker-compose run web rake db:migrate I got an error like this

rake aborted!
failed to execute:
pg_dump -s -x -O -f /usr/src/app/db/structure.sql --schema=public --schema=partitioning docker_rails_dev

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

/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/tasks/postgresql_database_tasks.rb:90:in `run_cmd'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/tasks/postgresql_database_tasks.rb:55:in `structure_dump'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:183:in `structure_dump'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:279:in `block (3 levels) in <top (required)>'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:53:in `block (2 levels) in <top (required)>'
/usr/local/bundle/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:45:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:structure:dump
(See full trace by running task with --trace)

The pg_dump command is available in the postgres container but not in ruby container but I have linked them together in my docker-compose.yml file.

like image 598
Sushant Bajracharya Avatar asked Jan 10 '17 05:01

Sushant Bajracharya


1 Answers

If you don't actually want the dump (why would you in CI?) put this in your test.rb:

config.active_record.dump_schema_after_migration = false

Now, no more need for PG tools (besides the client driver) in the ruby container.

like image 118
cluesque Avatar answered Oct 29 '22 16:10

cluesque