Make column not nullable in a Laravel migration

前端 未结 4 741
醉酒成梦
醉酒成梦 2020-12-12 17:32

I\'m writing a migration to make certain columns in a table nullable right now. For the down function, I of course want to make those columns not nullable

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-12 18:28

    As of Laravel 5, it's possible to reverse this natively - simply pass false as an argument to nullable().

    e.g.

    $table -> string('foo') -> nullable(false) -> change();
    

提交回复
热议问题