ruby-on-rails - 通过 DATABASE_URL 检查数据库状态

标签 ruby-on-rails postgresql heroku pg heroku-postgres

我已经通过相当奇怪的设置获得了 Heroku 应用程序的访问权。它有一个数据库,但是当我运行 heroku config 时,我得到了不同的 DATABASE_URL 和 HEROKU_POSTGRESQL_BRONZE_URL。 当我运行 heroku pg:info 时,我得到以下结果:

=== HEROKU_POSTGRESQL_BRONZE_URL
Plan:        Dev
Status:      available
Connections: 1
PG Version:  9.2.4
Created:     2013-09-05 11:02 UTC
Data Size:   6.5 MB
Tables:      0
Rows:        0/10000 (In compliance)
Fork/Follow: Unsupported

我意识到我的数据库位于 DATABASE_URL,但我无法访问该数据库,只能通过 heroku run console。所有 heroku pg 命令都失败并显示此消息:

!    Unknown database: DATABASE_URL. Valid options are: HEROKU_POSTGRESQL_BRONZE_URL

如果我运行 heroku pg HEROKU_POSTGRESQL_BRONZE_URL,我可以从上方访问空数据库。

由于我在运行迁移时遇到了一些问题,我认为我的数据库可能已满,我想检查一下。我有什么想法可以做到这一点吗?

这是我运行 heroku run rake db:migrate 后的错误:

PG::Error: ERROR:  permission denied for relation schema_migrations
: INSERT INTO "schema_migrations" ("version") VALUES ('20130918114202')

有关设置的更多信息:

rails 3.2.12

RAILS_ENV:暂存(我无权访问生产环境,但我知道这是“开发”服务器,并且还有真正的“暂存”,此应用程序是从中 fork 出来的)。

最佳答案

我有同样的问题,我已经解决了:

只需从您的数据库中保留一个备份并再次将其还原,步骤如下:

heroku pg:info                 <-- to get the Database Name
heroku addons:add pgbackups    <-- make sure you have the addons for backup
heroku pgbackups:capture       <-- Capture the backup
heroku pgbackups               <-- check your backups and make sure its there 
heroku pg:reset  DATABASE_NAME <-- Reset your database don't worry we have a backup, replace DATABASE_NAME with database name
heroku pgbackups:restore DATABASE_NAME b001 <-- Restore the backup again, replace DATABASE_NAME with database name and b001 with your Database version you can see this version number in heroku pgbackups step
heroku run rake db:migrate     <-- Now you can run your migration and Operate in normal mode. 

关于ruby-on-rails - 通过 DATABASE_URL 检查数据库状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19038265/

相关文章:

ruby-on-rails - 更新记录后,Active Admin 需要强制刷新

python - 刷新Python tkinter TreeView

python - 无法在 Heroku 中运行 Discord bot 命令

ruby-on-rails - Ruby 2.3 - 添加超时错误和通知到网络 :http request

ruby-on-rails - 我可以删除 rvm gemset 中的一些 nokogiri 和 capybara-webkit 文件夹吗?

ruby-on-rails - Rails 3.2.8 模型 before_save 在服务器负载过重的情况下无法正常工作

ruby-on-rails - rspec 期望日期等于

postgresql - 通过 pgAdmin 在 PostgreSQL 中创建关系链接

postgresql - pg_dump 数据库抛出错误 'out of shared memory'

django - 无法连接到服务器 :PostgreSQL -Heroku