简体   繁体   English

heroku运行rake db:migrate不起作用

[英]heroku run rake db:migrate dosn't work

I'm trying to migrate my postgresql database on Heroku. 我正在尝试在Heroku上迁移我的postgresql数据库。 When I run 当我跑步

heroku run rake db:migrate
I got the error: 我得到了错误:

$rake --version
rake, version 10.4.2

the same error when I run bundle exec..., 运行bundle exec时出现相同的错误...,

    source 'https://rubygems.org'


group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor'
end
group :development, :test do 
  gem 'sqlite3'
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
gem 'rake', '0.9.6'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development  

my Gemfile: 我的Gemfile:

  source 'https://rubygems.org' group :production do gem 'pg', '0.15.1' gem 'rails_12factor' end group :development, :test do gem 'sqlite3' end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.8' gem 'rake', '0.9.6' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.0.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring', group: :development 

thank you 谢谢

Run this command 运行此命令

heroku run bundle exec rake db:migrate

This will work. 这将起作用。

if not work, probably you need to uninstall rake so run 如果不行,可能您需要卸载rake,然后运行

gem uninstall rake

then run 然后跑

bundle install

then 然后

bundle exec rake db:migrate

I would leave rake out of the Gemfile unless you specifically need that version. 除非您特别需要该版本,否则我将把rake排除在Gemfile之外。 Bundler will use the correct version. 捆绑软件将使用正确的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM