【问题标题】:Schema.rb doesn't include table that existsSchema.rb 不包含存在的表
【发布时间】:2014-07-19 00:46:47
【问题描述】:

我已经运行了所有的迁移,并且我的 schema.rb 没有包含明显应该存在的表的“创建表”行。当我通过相应的 ActiveRecord 类访问该表时,该表实际上也显示在 rails 控制台中。

任何想法为什么会发生这种情况?模式中的这种差异会产生什么后果?该项目似乎运行良好。

【问题讨论】:

    标签: ruby-on-rails postgresql schema database-migration


    【解决方案1】:

    您可以使用此命令更新您的 schema.rb 以镜像数据库。

    bundle exec rake db:schema:dump
    

    Schema.rb 不用于开发或生产,因此它对正在运行的应用程序没有影响。但是,它在设置测试数据库时使用。可以阅读更多http://guides.rubyonrails.org/migrations.html#schema-dumping-and-you

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多