问题:

我有一个在Postgres上运行的rails应用程序。

我有两台服务器:一台用于测试,另一台用于生产。

我经常需要在测试服务器上克隆生产数据库。

我通过弗拉德跑的命令是:

rake RAILS_ENV='test_server' db:drop db:create

我遇到的问题是我收到以下错误:

ActiveRecord::StatementInvalid: PGError: ERROR: database <database_name> is being accessed by other users DROP DATABASE IF EXISTS <database_name>

如果有人最近通过网络访问了该应用程序(postgres保持“会话”打开),就会发生这种情况

有什么方法可以终止postgres DB上的会话吗?

谢谢。

编辑

我可以使用phppgadmin的界面删除数据库,但不能使用rake任务删除数据库。

如何使用rake任务复制phppgadmin的drop?

I have a rails application running over Postgres.I have two servers: one for testing and the other for production.Very often I need to clone the production DB on the test server.The command I’m runnig via Vlad is:The problem I’m having is that I receive the following error:This happens if someone has accessed the application via web recently (postgres keeps a “session” opened)Is there any way that I can terminate the sessions on the postgres DB?Thank you.EditI can delete the database using phppgadmin’s interface but not with the rake task.How can I replicate phppgadmin’s drop with a rake task?

问题:

我刚安装了Rails 4.0.2 ,在创建新应用程序时,在捆绑阶段我得到:

Installing pg (0.17.1) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/Dee/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

我该如何解决?

I just installed Rails 4.0.2 and when creating a new app, in the bundle stage I get:How do I fix this?

问题:

Jupitor$ bundle exec rake db:create db:migrate
APP_development already exists
rake aborted!
PG::Error: ERROR:  invalid value for parameter "TimeZone": "UTC"
: SET time zone 'UTC'

尝试迁移到我的postgres数据库时,我一直收到此错误。 帮助将不胜感激!

I keep getting this error when trying to migrate to my postgres database.help would be much appreciated!

问题:

GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;

只读用户可以连接,请参阅表,但是当尝试进行简单选择时,它会得到:

ERROR: permission denied for relation mytable
SQL state: 42501

这是在PostgreSQL 9.1上发生的

我做错了什么?

The readonly user can connect, see the tables but when it tries to do a simple select it gets:This is happening on PostgreSQL 9.1What I did wrong?

问题:

有没有一种方法可以指定在执行sql脚本时,遇到脚本上的第一个错误时它将停止,无论先前的错误如何,该脚本通常都会继续。

谢谢

Is there a way to specify that when executing a sql script it stops when encountering the first error on the script, it usually continues, regardless of previous errors.Thanks