在 VPS 中,我安装了 Postgres 和 2 个 Rails 项目。两者都在生产模式下运行,并将 PG 连接为不同的用户。
现在我想为其中之一设置 CruiseControl.rb。一切都很顺利,除了当 Cruise 试图运行测试时,它会抛出这个错误:
PGError: ERROR: permission denied to create database
: CREATE DATABASE "myProject" ENCODING = 'utf8'
此测试数据库是使用不同的所有者名称创建的,并且它们都在~/.cruise/projects/myProject/work/config/database.yml
.
当我在里面手动运行以下一系列命令时~/.cruise/projects/myProject/work
,它们运行良好。
RAILS_ENV=test rake db:migrate
rake test
我使用以下命令创建了数据库:
create user test_user with password 'abcxyz';
create database test_database TEMPLATE template0 owner test_user;
grant all privileges on database test_database to test_user;
点击Build Now
按钮后,将test_database
被删除,然后尝试再次创建它并抛出该异常。
我很困惑,为什么测试数据库首先被删除?我在这里有什么遗漏吗?