rake db:structure:在PostgreSQL / Rails 3.2下转储失败(rake db:structure:dump fails under PostgreSQL / Rails

编程入门 行业动态 更新时间:2024-10-10 06:12:55
rake db:structure:在PostgreSQL / Rails 3.2下转储失败(rake db:structure:dump fails under PostgreSQL / Rails 3.2)

我收到此错误消息:

pg_dump: too many command-line arguments (first is "demo_db") Try "pg_dump --help" for more information. rake aborted! Error dumping database Tasks: TOP => db:structure:dump (See full trace by running task with --trace)

这用于在Rails 3.1下工作。 我使用的是Rails 3.2.3和PostgreSQL 9.0.5。 其他任务如db:migrate或db:rollback工作得很好。

I get this error message:

pg_dump: too many command-line arguments (first is "demo_db") Try "pg_dump --help" for more information. rake aborted! Error dumping database Tasks: TOP => db:structure:dump (See full trace by running task with --trace)

This used to work under Rails 3.1. I'm using Rails 3.2.3 and PostgreSQL 9.0.5. Other tasks like db:migrate or db:rollback work just fine.

最满意答案

pg_dump命令在428行的activerecord / lib / active_record / railties / databases.rake中执行 。

`pg_dump -i -s -x -O -f #{Shellwords.escape(filename)} #{search_path} #{Shellwords.escape(config['database'])}`

尝试在那里设置断点并查看正在运行的实际命令。

所有这些选项都适用于Pg9.0.x,所以我怀疑在abcs[Rails.env]['schema_search_path']中有一些有趣的东西混淆了psql的选项解析。 请注意, search_path构造不引用--schema参数,因此具有嵌入空间的search_path_part将作为部分模式名称进行解析,后跟一个没有选项的单词,因此psql会将其解释为数据库名称然后当它到达真正的数据库名称时发出抱怨。

Thanks to dbenhur I found the issue. I have a space in the path of my filename. Changing line 392 of activerecord/lib/active_record/railties/databases.rake to

pg_dump -i -s -x -O -f '#{filename}' #{search_path} #{abcs[Rails.env]['database']}

(adding the single quotes around #{filename}) fixes the issue.

更多推荐

本文发布于:2023-08-07 16:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465305.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:structure   PostgreSQL   rake   db   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!