【问题标题】:Migrating db in Heroku RoR error在 Heroku RoR 错误中迁移数据库
【发布时间】:2014-11-30 03:30:57
【问题描述】:

您好,提前感谢您抽出宝贵的时间参与这项工作,

我是 RoR 的新手,我正在关注 Michael Hartl 的 RUBY ON RAILS TUTORIAL,当我尝试在 heroku 中迁移数据库时,我真的遇到了这个错误 (我知道语法错误是什么意思(END)但我还是解决不了)

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】:

    发现问题。 问题是我在本地进行更改并且缺少提交更改,将它们推送到 git,然后将它们拉入 heroku 实例。

    一旦我这样做了,我就可以毫无问题地运行数据库迁移。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-13
      • 2015-06-08
      • 2015-04-06
      • 1970-01-01
      • 2018-10-21
      • 2014-05-05
      相关资源
      最近更新 更多