运行rake db:migrate时出现pg_dump错误

时间:2017-01-10 05:43:06

标签: ruby-on-rails postgresql docker

我有postgres容器和红宝石容器。当运行docker-compose运行web rake db:migrate时,出现了类似这样的错误

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)

pg_dump命令在postgres容器中可用,但在ruby容器中没有,但我已在docker-compose.yml文件中将它们链接在一起。

2 个答案:

答案 0 :(得分:0)

如果您实际上并不想 转储(为什么要在CI中使用),请将其放入您的test.rb

config.active_record.dump_schema_after_migration = false

现在,在ruby容器中不再需要PG工具(客户端驱动程序除外)。

答案 1 :(得分:-1)

简短回答:安装你需要的工具 - 内部 - 容器, - 内部 - 容器。

如果你需要在ruby容器内运行pg_dump,请在ruby容器中安装postgress。二进制文件很少以这种方式移植。