0

我终于能够将 MYSQL db 转换为 Postgres,当我第一次打开应用程序时,我得到了这个错误。将不胜感激任何帮助。谢谢!

我的理论是,这是耙的问题,尤其是 pg gem。但我已经安装了它,我相信。

gem install activerecord-postgresql-adapter
Password:
Fetching: activerecord-postgresql-adapter-0.0.1.gem (100%)
Successfully installed activerecord-postgresql-adapter-0.0.1
Parsing documentation for activerecord-postgresql-adapter-0.0.1
Installing ri documentation for activerecord-postgresql-adapter-0.0.1
1 gem installed

宝石文件-

  source 'https://rubygems.org'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'



# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'


group :test, :development do
    gem 'turn'
    gem 'rspec-rails'
    gem 'capybara'
    gem 'guard-rspec'
    gem 'launchy'
    gem 'mysql2'
end

group :production do
  gem  'pg'
end

更新 gemfile 的新错误-

2013-05-10T17:36:13.640826+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2013-05-10T17:36:13.640826+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
2013-05-10T17:36:13.641078+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
2013-05-10T17:36:13.641078+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
2013-05-10T17:36:13.640340+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
2013-05-10T17:36:18.715882+00:00 heroku[web.1]: State changed from starting to crashed
2013-05-10T17:36:18.703121+00:00 heroku[web.1]: Process exited with status 1
2013-05-10T17:36:19.378387+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno= connect= service= status=503 bytes=
2013-05-10T17:36:19.778557+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno= connect= service= status=503 bytes=
2013-05-10T17:45:08.279666+00:00 heroku[slugc]: Slug compilation started
2013-05-10T17:46:03.752569+00:00 heroku[api]: Release v12 created by c@gmail.com
2013-05-10T17:46:03.787515+00:00 heroku[api]: Deploy bf11417 by cat@gmail.com
2013-05-10T17:46:04.205838+00:00 heroku[slugc]: Slug compilation finished
2013-05-10T17:46:04.230012+00:00 heroku[web.1]: State changed from crashed to starting
2013-05-10T17:46:05.557323+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 31543`
2013-05-10T17:46:08.680763+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-05-10T17:46:08.681149+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-05-10T17:46:13.813365+00:00 app[web.1]: => Booting WEBrick
2013-05-10T17:46:13.813365+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:31543
2013-05-10T17:46:13.813365+00:00 app[web.1]: => Call with -d to detach
2013-05-10T17:46:13.813365+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-05-10T17:46:13.813365+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-05-10T17:46:15.500836+00:00 app[web.1]: [2013-05-10 17:46:15] INFO  WEBrick 1.3.1
2013-05-10T17:46:15.501191+00:00 app[web.1]: [2013-05-10 17:46:15] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-05-10T17:46:15.507222+00:00 app[web.1]: [2013-05-10 17:46:15] INFO  WEBrick::HTTPServer#start: pid=2 port=31543
2013-05-10T17:46:15.587362+00:00 heroku[web.1]: State changed from starting to up
2013-05-10T17:46:33.387709+00:00 heroku[api]: Scale to web=0 by cat@gmail.com
2013-05-10T17:46:36.068010+00:00 heroku[api]: Scale to web=1 by ca@gmail.com
2013-05-10T17:46:33.914433+00:00 heroku[web.1]: State changed from up to down
2013-05-10T17:46:38.707975+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 13155`
2013-05-10T17:46:41.953559+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-05-10T17:46:41.953059+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-05-10T17:46:43.194275+00:00 app[web.1]: Started GET "/" for 98.210.56.231 at 2013-05-10 17:46:43 +0000
2013-05-10T17:46:43.706970+00:00 app[web.1]: Processing by SammichesController#index as HTML
2013-05-10T17:46:44.477421+00:00 app[web.1]: => Booting WEBrick
2013-05-10T17:46:44.477421+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:13155
2013-05-10T17:46:44.477421+00:00 app[web.1]: => Call with -d to detach
2013-05-10T17:46:44.477421+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-05-10T17:46:44.477421+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-05-10T17:46:44.628189+00:00 app[web.1]: [2013-05-10 17:46:44] INFO  WEBrick 1.3.1
2013-05-10T17:46:44.628189+00:00 app[web.1]: [2013-05-10 17:46:44] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-05-10T17:46:44.628448+00:00 app[web.1]: [2013-05-10 17:46:44] INFO  WEBrick::HTTPServer#start: pid=2 port=13155
2013-05-10T17:46:45.567056+00:00 heroku[router]: at=info method=GET path=/ host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=1ms service=2395ms 
status=500 bytes=643
2013-05-10T17:46:45.566136+00:00 app[web.1]: 
2013-05-10T17:46:45.564507+00:00 app[web.1]: Completed 500 Internal Server Error in 1856ms
2013-05-10T17:46:45.566136+00:00 app[web.1]:                                         ^
2013-05-10T17:46:45.566136+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-05-10T17:46:45.566136+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-05-10T17:46:45.566136+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-05-10T17:46:45.566136+00:00 app[web.1]:              WHERE a.attrelid = '"sammiches"'::regclass
2013-05-10T17:46:45.566136+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-05-10T17:46:45.566549+00:00 app[web.1]:              ORDER BY a.attnum
2013-05-10T17:46:45.566549+00:00 app[web.1]: ):
2013-05-10T17:46:45.566136+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  relation "sammiches" does not exist
2013-05-10T17:46:45.566136+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"sammiches"'::regclass
2013-05-10T17:46:45.566549+00:00 app[web.1]:   app/controllers/sammiches_controller.rb:3:in `index'
2013-05-10T17:46:45.566549+00:00 app[web.1]: 
2013-05-10T17:46:45.566549+00:00 app[web.1]: 
2013-05-10T17:46:45.566136+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-05-10T17:46:45.929831+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=0ms service=10ms status=200 bytes=0
2013-05-10T17:46:49.553338+00:00 app[web.1]: Started GET "/" for 98.210.56.231 at 2013-05-10 17:46:49 +0000
2013-05-10T17:46:49.761889+00:00 app[web.1]: Processing by SammichesController#index as HTML
2013-05-10T17:46:49.884490+00:00 heroku[router]: at=info method=GET path=/ host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=2ms service=350ms status=500 bytes=643
2013-05-10T17:46:49.888277+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"sammiches"'::regclass
2013-05-10T17:46:49.886724+00:00 app[web.1]: Completed 500 Internal Server Error in 125ms
2013-05-10T17:46:49.888277+00:00 app[web.1]:                                         ^
2013-05-10T17:46:49.888277+00:00 app[web.1]: 
2013-05-10T17:46:49.888277+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  relation "sammiches" does not exist
2013-05-10T17:46:49.888277+00:00 app[web.1]:              WHERE a.attrelid = '"sammiches"'::regclass
2013-05-10T17:46:49.888277+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-05-10T17:46:49.888539+00:00 app[web.1]:              ORDER BY a.attnum
2013-05-10T17:46:49.888539+00:00 app[web.1]: ):
2013-05-10T17:46:49.888277+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-05-10T17:46:49.888277+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-05-10T17:46:49.888539+00:00 app[web.1]:   app/controllers/sammiches_controller.rb:3:in `index'
2013-05-10T17:46:49.888277+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-05-10T17:46:49.888539+00:00 app[web.1]: 
2013-05-10T17:46:49.888277+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-05-10T17:46:49.888539+00:00 app[web.1]: 
2013-05-10T17:46:50.953412+00:00 heroku[router]: at=info method=GET path=/ host=powerful-plateau-7517.herokuapp.com fwd="98.210.56.231" dyno=web.1 connect=1ms service=23ms status=500 bytes=643
2013-05-10T17:46:50.947731+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2013-05-10T17:46:50.948975+00:00 app[web.1]: 
2013-05-10T17:46:50.948975+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::Error: ERROR:  relation "sammiches" does not exist
2013-05-10T17:46:50.948975+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"sammiches"'::regclass
2013-05-10T17:46:50.948975+00:00 app[web.1]:              WHERE a.attrelid = '"sammiches"'::regclass
2013-05-10T17:46:50.948975+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-05-10T17:46:50.948975+00:00 app[web.1]:                                         ^
2013-05-10T17:46:50.948975+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-05-10T17:46:50.948975+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-05-10T17:46:50.944830+00:00 app[web.1]: Processing by SammichesController#index as HTML
2013-05-10T17:46:50.941220+00:00 app[web.1]: Started GET "/" for 98.210.56.231 at 2013-05-10 17:46:50 +0000
2013-05-10T17:46:50.949304+00:00 app[web.1]:              ORDER BY a.attnum
2013-05-10T17:46:50.949304+00:00 app[web.1]: ):
2013-05-10T17:46:50.949304+00:00 app[web.1]:   app/controllers/sammiches_controller.rb:3:in `index'
2013-05-10T17:46:50.949304+00:00 app[web.1]: 
2013-05-10T17:46:50.948975+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-05-10T17:46:50.948975+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-05-10T17:46:50.949304+00:00 app[web.1]: 
2013-05-10T17:46:56.606488+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-05-10T17:46:57.661330+00:00 app[web.1]: [2013-05-10 17:46:57] ERROR SignalException: SIGTERM
2013-05-10T17:46:57.661330+00:00 app[web.1]:    /usr/local/lib/ruby/1.9.1/webrick/server.rb:90:in `select'
4

1 回答 1

1

如果您想pg在所有环境中使用 gem,那么您必须注释掉mysql2gem。否则:

group :test, :development do
  gem 'mysql2'
end

group :production do
  gem  'pg', '~> 0.9.0'
end
于 2013-05-10T16:05:59.083 回答