如何在黄瓜rails中将mysql转换为psql

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在黄瓜rails中将mysql转换为psql相关的知识,希望对你有一定的参考价值。

我正在尝试将mysql2转换为postgres。当我运行rake db:create我收到以下错误。

rake aborted!
Gem::LoadError: You have already activated rake 12.3.0, but your Gemfile requires rake 10.4.2. Prepending bundle exec to your command may solve this.
/home/supranimbus12/.rvm/gems/ruby-2.2.3@global/gems/bundler-1.16.1/lib/bundler/runtime.rb:313:in check_for_activated_spec!' /home/supranimbus12/.rvm/gems/ruby-2.2.3@global/gems/bundler-1.16.1/lib/bundler/runtime.rb:31:inblock in setup'
/home/supranimbus12/.rvm/gems/ruby-2.2.3@global/gems/bundler-1.16.1/lib/bundler/runtime.rb:26:in map' /home/supranimbus12/.rvm/gems/ruby-2.2.3@global/gems/bundler-1.16.1/lib/bundler/runtime.rb:26:insetup'
/home/supranimbus12/.rvm/gems/ruby-2.2.3@global/gems/bundler-1.16.1/lib/bundler.rb:107:in setup' /home/supranimbus12/.rvm/gems/ruby-2.2.3@global/gems/bundler-1.16.1/lib/bundler/setup.rb:10:in<top (required)>'
/home/supranimbus12/tracks-2.3.0/config/boot.rb:4:in <top (required)>' /home/supranimbus12/tracks-2.3.0/config/application.rb:1:in<top (required)>'
/home/supranimbus12/tracks-2.3.0/Rakefile:4:in <top (required)>' /home/supranimbus12/.rvm/gems/ruby-2.2.3@global/gems/rake-12.3.0/exe/rake:27:in<top (required)>'
(See full trace by running task with --trace)
答案

将gem pg添加到Gemfile后。

gem 'pg'
  • 捆绑安装
  • 配置database.yml,
  • 创建新数据库。
  • 迁移数据库
另一答案
bundle exec rake db:create

并迁移

bundle exec rake db:migrate

以上是关于如何在黄瓜rails中将mysql转换为psql的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Rails 中将 Javascript 对象转换为 JSON?

在 Rails 3 中将 UTC 转换为本地时间

将 psql 文本列转换为 tsvector

Ruby on Rails。捆绑器。黄瓜。耙中止!命令失败,状态为 (1)

在rails中将字符串转换为数组

在 Rails 中将文件大小字符串转换为等效千字节