我對heroku和postgresql有點新東西,不知道如何從mysql轉換到postgresql。 我的申請於MySQL和從Heroku的運行發展我做了一些步驟:1. 增加了gem 'pg'
和gem 'rails_12factor'
這樣的:在heroku上運行rails項目
group :production do
gem 'pg'
gem 'rails_12factor'
end
和捆綁它沒有生產 2.我也改變了我的數據庫。陽明海運到: (我也有問題,我怎麼能在生產中使用的MySQL在devolepment和postgre?)
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
但是! 當我tryed通過Heroku的工作(下載正常工作)我的動態頁面wasnt工作,我得到這個錯誤:
所以,我猜DB只是不遷移,OK,我通過控制檯這個拼命地跑: heroku run rake db:migrate --app name
AAAND我現在我有這個錯誤:
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "schoolings" does not exist
: ALTER TABLE "students" ADD CONSTRAINT "fk_rails_e33c769d03"
FOREIGN KEY ("schooling_id")
REFERENCES "schoolings" ("id")
我的問題:
1.爲什麼會發生?我在部署我的應用程序時錯過了一些步驟嗎?
2.如何在deployment.yml中將生產和開發數據庫分開?
謝謝,任何幫助!
請確保你有所有的遷移文件..檢查使用'bin/rake db:migrate:status'我認爲有一個不好。 – siegy22
我應該在heroku或應用程序上檢查它? – 01ghost13
在你的本地應用程序 – siegy22