为什么schema.rb文件在开发和生产环境之间有所不同?

时间:2012-04-13 10:04:38

标签: ruby-on-rails ruby

我在开发和生产环境中使用了mysql Ver 14.14。我有一个db迁移文件,如:

class ChangeRoleToNodeTemplate < ActiveRecord::Migration
  def up
    rename_table :roles, :node_templates
  end

  def down
    rename_table :node_templates, :roles
  end
end

当我运行'rake db:migrate'命令时,它生成的schema.rb文件是正确的。

但是当我运行'rake db:migrate RAILS_ENV = production'时,它包含具有相同模式的'roles'和'node_templates'表。

任何人都可以给我一个建议吗?感谢。

我使用了Rails 3.1.0

1 个答案:

答案 0 :(得分:1)

不确定为什么以及如何发生这种情况,但我会先尝试完全回滚生产数据库,而不仅仅是加载模式并检查

回滚生产db:

rake db:rollback RAILS_ENV=production STEP=100

加载架构:

rake db:schema:load RAILS_ENV=production