我在删除 Rails 应用程序的 postgres 数据库时遇到问题 - 最近在部署到 heroku 后从 sqlite 切换。运行我的 rake 任务以聚合数据并填充数据库时, rake db:create db:migrate all 工作,但 db:drop 不工作。运行 rake db:drop db:migrate db:create all 后,我的终端出现以下错误。'all' 是聚合器的 rake 任务。
Couldn't drop something_development : #<PG::Error: FATAL: database "postgres" does not exist
>
Couldn't drop something_test : #<PG::Error: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
>
something_development already exists
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
'这是查看我的 database.yml 文件...`
development:
adapter: postgresql
host: localhost
database: something_development
username: username
test:
adapter: postgresql
database: something_test
pool: 5
timeout: 5000
production:
adapter: postgresql
host: localhost
username: username
database: something_production
这里还有一个来自 psql 命令行的数据库列表:
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------------------+-----------------+----------+---------+-------+-------------------------------------
username | username | UTF8 | en_US | en_US |
something_development | username | UTF8 | en_US | en_US |
template0 | username | UTF8 | en_US | en_US | =c/username+ | | | | | username=CTc/username
template1 | username | UTF8 | en_US | en_US | =c/username + | | | | | username=CTc/username
(4 rows)
编辑 - 在推到 heroku 之前,我试图在开发中做到这一点。我需要为我的用户名添加访问权限吗?我尝试 GRANT UPDATE ON something_development TO username 但收到错误:关系“something_development”不存在。Heroku 会记住这一点 - 谢谢。
有没有人对可能发生的事情或某些资源有任何想法可以为我指明正确的方向?感谢任何帮助-谢谢。