1
我使用標準配置(SQLite 3)開發了我的應用程序。我想在heroku上部署,並且必須更改爲postgresql。錯誤:將SQLite遷移到Postgres
但是當我試圖遷移我的數據庫模式時遇到了這個錯誤。
rake db:migrate
rake aborted!
/Users/adrianschnell/Sites/bills_cmd/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end
...sion_store :cookie_store, key: '_bills_cmd_session'
^
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/engine.rb:588
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/engine.rb:587:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/engine.rb:587
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `run_initializers'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `send'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/adrianschnell/Sites/bills_cmd/config/environment.rb:8
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:297:in `initialize_tasks'
Tasks: TOP => db:migrate => environment
我不知道我現在要做什麼。 我的寶石文件包括了「PG」和我的database.yml的樣子:
# PostgreSQL v0.8.x
# gem install pg
development:
adapter: postgresql
encoding: unicode
database: bills_cmd_dev
pool: 5
username: adrianschnell
password:
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: unicode
database: bills_cmd_test
pool: 5
username: adrianschnell
password:
運行PostgreSQL - 通過終端我可以訪問它。
編輯: 我注意到,我在嘗試創建postgre數據庫時出現以下錯誤:
rake db:create:all
rake aborted!
syntax error on line 18, col 11: `'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application/configuration.rb:115:in `database_configuration'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:25
Tasks: TOP => db:create:all => db:load_config
(See full trace by running task with --trace)
其中之一,這兩個錯誤都是rails中的語法錯誤,並且與Postgres無關。關於第一個錯誤 - config/initializers/session_store.rb的第三行是什麼?至於第二個,看起來像輸出中只列出了核心文件 - 是否有更多的跟蹤或任何其他有關該錯誤的信息? – 2013-02-14 20:24:23
session_store中的第3行是「BillsCmd :: Application.config.session_store:cookie_store,key:'_bills_cmd_session'」。是的,我認爲這只是製造麻煩的紅寶石。在1.9上更新ruby的最佳方式是什麼?使用rvm命令「rvm install current && rvm use current」? – Adrian 2013-02-14 20:56:42
這並不容易......但我得到了Ruby 1.9.3的安裝。我現在手動創建了postgre,並通過輕敲進行遷移。但是當我嘗試運行這個RoR應用程序時,我收到了一條新的錯誤消息 - 我粘貼了[pastebin](http://pastebin.com/QkiKcFS6)。我甚至在「軟件包安裝」和「軟件包更新」之後收到此消息 – Adrian 2013-02-14 21:33:10