小编mae*_*bow的帖子

Rails迁移生成默认时间戳(created_at,updated_at)为NULLABLE

前段时间我们将应用程序升级到Rails 4并切换到JRuby.

在此更改之前,迁移会将默认时间戳创建为NOT NULL.在更改之后,缺少NOT NULL.

我们创建这些时间戳(created_at,updated_at)如下:

class Model < ActiveRecord::Migration
  def change
    create_table :model do |t|
      t.belongs_to :user, :null => false

      t.text :content

      t.timestamps
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

我们的应用程序的重要部分是:

  • ruby'1.9.3',:engine =>'jruby',:engine_version =>'1.7.9'
  • 宝石'轨道','4.0.2'
  • gem'activerecord -jdbcpostgresql-adapter','1.3.4'
  • postgresql:稳定9.3.1

您是否知道可能导致问题的原因以及我们如何将默认生成更改回NOT NULL

migration postgresql activerecord ruby-on-rails jruby

11
推荐指数
1
解决办法
8489
查看次数

Lucene - 很少或很多索引

使用起来更好吗?

  • 在Lucene中有很多索引(例如,对于每个用户,因为你的应用程序允许这样做)
  • 或者只是一个,将每个文档都放在int中

......如果你想一想:

  • 性能
  • 磁盘空间
  • 健康

我正在使用elasticsearch,因此我使用的是Lucene.

lucene solr elasticsearch

3
推荐指数
1
解决办法
603
查看次数