在Heroku RoR错误中迁移数据库

问题描述 投票:0回答:1

你好,谢谢你为此付出的努力,

我是RoR的新手,我正在关注Michael Hartl撰写的RUBY ON RAILS TUTORIAL,当我尝试在heroku中迁移数据库时,我真的陷入了这个错误(我知道语法错误是什么意思(结束),但我仍然无法解决它)

heroku run rake db:migrate

Running `rake db:migrate` attached to terminal... up, run.4787
Migrating to CreateUsers (20141001220747)
rake aborted!
SyntaxError: /app/db/migrate/20141001220747_create_users.rb:10: syntax error, unexpected keyword_end, expecting end-of-input
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `block in require'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in `load_dependency'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:722:in `load_migration'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:718:in `migration'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:712:in `disable_ddl_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:1016:in `use_transaction?'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:1008:in `ddl_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:962:in `execute_migration_in_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:924:in `block in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:920:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:920:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:768:in `up'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/migration.rb:746:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

我已经完成了研究,发现问题出在END的结尾或结尾,但是我尝试添加和删除结尾...没有运气。奇怪的是,即使添加或删除了ENDS,错误也完全相同。这是迁移文件

class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :name
      t.string :email
      t.timestamps
    end
  end
end

非常感谢,希望您能提供帮助。快乐编码

ruby-on-rails ruby database heroku database-migration
1个回答
1
投票

发现了问题。问题是我在本地进行更改,但是缺少提交更改,将其推送到git,然后将其拉到heroku实例中。

一旦完成,就可以毫无问题地运行数据库迁移。

顺便说一句,我在最上面发布的代码是正确的,但是当我第一次推送它时,它在定义类时出现语法错误。

© www.soinside.com 2019 - 2024. All rights reserved.