【问题标题】:Applied migration entry not presente on schema_migrations tableschema_migrations 表上未显示应用的迁移条目
【发布时间】:2012-01-08 06:22:36
【问题描述】:

我在 heroku 上的生产环境中运行了一个应用,但 schema_migrations 表存在问题。

db/schema.rb 文件中存在上次迁移更改,但schema_migrations 表中没有此迁移的条目。

所以在运行rake db:version 时,我得到了与上次迁移之前执行的迁移相对应的数字。

我认为我应该在 schema_migrations 表上添加一个迁移条目,但我不确定如何在不影响数据库日期和远程 heroku 日期的情况下执行此操作。

【问题讨论】:

    标签: ruby-on-rails-3 heroku migration schema-migration


    【解决方案1】:

    我遇到了类似的问题,我的 schema_migrations 表中没有迁移。所以我不得不运行这个:

    Dir.open('db/migrate').each do |fname|
        i = fname.split('_').first.to_i
        next if i == 0
        ActiveRecord::Base.connection.execute("INSERT INTO schema_migrations (version) VALUES(#{i})")
    end
    

    source

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-13
      • 2013-07-12
      • 2015-12-15
      • 2016-08-07
      • 2014-11-08
      • 1970-01-01
      • 2018-02-25
      相关资源
      最近更新 更多