Ruby on Rails: How do I add a not null constraint to an existing column using a migration?

前端 未结 4 1989
南方客
南方客 2021-01-31 07:04

In my Rails (3.2) app, I have a bunch of tables in my database but I forgot to add a few not null constraints. I\'ve googled around but I can\'t find how to write a migration wh

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 07:30

    For Rails 4+, nates' answer (using change_column_null) is better.

    Pre-Rails 4, try change_column.

提交回复
热议问题