我一直在關注如何從Rails 3移動到3.1並使其在Heroku上工作的文檔。我使用了這裏給出的手動升級技術:http://webtempest.com/upgrade-rails-3-to-3-1/Heroku - Rails 3到3.1與PosgreSQL的遷移問題:關係「用戶」不存在
我已經取得了一些緩慢的進展,但使它與Heroku一起工作已經非常痛苦。目前,我的應用程序可以在本地正常運行rails 3.1。我應該讓你知道,在開發模式中,我使用的是mysql(僅僅是因爲有選擇使用sequel pro,我還沒有完全想到如何在本地使用postgres)。事情是,我沒有任何問題,推動我的應用程序heroku,而在軌道3.0,並在那裏用postgres和本地與MySQL有史以來。它一直很好。但是,現在我已經轉移到3.1,使用heroku雪松堆棧,我遇到以下問題,同時跟隨heroku文檔:http://devcenter.heroku.com/articles/rails31_heroku_cedar
以下是我試圖遷移或重置我的應用程序的時候碰到的錯誤將代碼推送到heroku後,以及當我重新啓動應用程序。
Running rake db:reset attached to terminal... up, run.9
Couldn't drop hvifyyqdjs : #<ActiveRecord::StatementInvalid: PGError: ERROR: must be owner of database hvifyyqdjs
: DROP DATABASE IF EXISTS "hvifyyqdjs">
hvifyyqdjs already exists
rake aborted!
PGError: ERROR: relation "users" does not exist
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
有關如何解決此問題的任何想法?我正在使用這裏提到的'用戶'的設計插件。我對這個問題的研究使我較早相信我的遷移可能還沒有創建用戶表正常,但是在嘗試重新啓動在Heroku上的應用程序時,我的第一個遷移文件並創建用戶表
class DeviseCreateUsers < ActiveRecord::Migration
def self.up
create_table(:users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.encryptable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.timestamps
end
add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => true
# add_index :users, :confirmation_token, :unique => true
# add_index :users, :unlock_token, :unique => true
# add_index :users, :authentication_token, :unique => true
end
def self.down
drop_table :users
end
end
,這我在日誌中看到的東西
2011-09-28T09:55:08+00:00 app[web.1]: => Booting WEBrick
2011-09-28T09:55:08+00:00 app[web.1]: => Rails 3.1.0 application starting in production on http://0.0.0.0:33603
2011-09-28T09:55:08+00:00 app[web.1]: => Call with -d to detach
2011-09-28T09:55:08+00:00 app[web.1]: => Ctrl-C to shutdown server
2011-09-28T09:55:08+00:00 app[web.1]: Exiting
2011-09-28T09:55:08+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:962:in `async_exec': PGError: ERROR: relation "users" does not exist (ActiveRecord::StatementInvalid)
2011-09-28T09:55:08+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
2011-09-28T09:55:08+00:00 app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2011-09-28T09:55:08+00:00 app[web.1]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2011-09-28T09:55:08+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2011-09-28T09:55:08+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2011-09-28T09:55:08+00:00 app[web.1]: ORDER BY a.attnum
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:962:in `exec_no_cache'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:551:in `block in exec_query'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:550:in `exec_query'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:1061:in `column_definitions'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:740:in `columns'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `block (2 levels) in initialize'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:92:in `block in initialize'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:706:in `yield'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:706:in `default'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:706:in `columns'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:722:in `column_names'
2011-09-28T09:55:08+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base
任何幫助,建議或提示將不勝感激。
hvifyyqdjs錯誤行就在那裏,因爲我使用了reset命令。它不會顯示,當我嘗試重置應用程序或其他任何東西。在所有其他情況下,我被上面提到的「用戶」參考錯誤卡住了。檢查來自heroku的新日誌我剛剛添加以查看重新啓動應用程序時發生的情況。看起來好像有什麼東西與postgresql_adapter.rb – alik
但最終的結果是,您的應用程序無法刪除數據庫,並且無法重新創建它,並且它期望的對象沒有找到或有不同結構。 – wildplasser
我明白了。我的猜測是,'hvifyyqdjs'似乎是與Heroku有關的數據庫,所以我無法完全訪問它。正如Erwin指出的那樣,問題在於'WHERE a.attrelid =''users'':regclass'行使用''users''。引號中的雙引號。爲什麼它正在使用,以及如何改變,這是我不知道,並可以使用幫助。 – alik