Ruby on rails 迁移列未在heroku db上创建,在local-Rails上可见

Ruby on rails 迁移列未在heroku db上创建,在local-Rails上可见,ruby-on-rails,ruby,ruby-on-rails-4,heroku,ruby-on-rails-3.2,Ruby On Rails,Ruby,Ruby On Rails 4,Heroku,Ruby On Rails 3.2,这是迁移文件 class CreateComments < ActiveRecord::Migration def change create_table :comments do |t| t.string :name t.string :email t.text :body t.boolean :spam, default: false t.references

这是迁移文件

class CreateComments < ActiveRecord::Migration
      def change
        create_table :comments do |t|
          t.string :name
          t.string :email
          t.text :body
          t.boolean :spam, default: false
          t.references :post, index: true, foreign_key: true
          t.references :user, index: true, foreign_key: true

          t.timestamps null: false
        end
      end
    end
我尝试了heroku重启,可能它更新了模式或其他东西,但什么都没有


在我的本地环境中,我可以看到并使用用户id列。

尝试以下操作-我想这是您的最后一次迁移-

heroku运行rake db:rollback
以回滚上次迁移


heroku run rake db:migrate
要再次运行该迁移

我想您没有创建新的迁移,而是修改了现有的迁移

您需要做的是
rollback
Heroku上的迁移,然后再
migrate
it

请记住,您必须创建两个回购承诺,一个没有修改,另一个没有修改。这是因为在回滚迁移时,添加的列应该丢失,或者它将尝试删除不存在的列

因此,程序如下:

  • 从迁移中删除修改。提交更改
  • heroku运行rake db:rollback STEP=1
    或需要多少步骤
  • 再次添加修改。提交更改
  • heroku运行rake数据库:迁移
  • Comment(id: integer, name: string, email: string, body: text, post_id: integer, created_at: datetime, updated_at: datetime)