我用unsigned创建了一个迁移user_id.如何user_id在新迁移中编辑以进行编辑nullable()?
Schema::create('throttle', function(Blueprint $table)
{
$table->increments('id');
// this needs to also be nullable, how should the next migration be?
$table->integer('user_id')->unsigned();
}
Run Code Online (Sandbox Code Playgroud) 我发现这个问题非常类似于我的Make列在Laravel迁移中不可为空,虽然它已经快3岁了,它肯定不属于Laravel 5
我的问题是我有一个迁移,它在up函数中修改了一个列使其可以为空.现在,在down函数中我想让它再次无法为空.
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('mytable', function(Blueprint $table) {
$table->string('mycolumn')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('mytable', function(Blueprint $table) {
/* THIS IS WHAT I WOULD EXPECT TO DO
THOUGH OF COURSE THE FUNCTION notNullable DOES NOT WORK */
$table->string('mycolumn')->notNullable()->change();
});
}
Run Code Online (Sandbox Code Playgroud)
我可以使用原始SQL实现这一点,但我想使用Laravel方法,如果可能的话......但是我找不到它,可能它还没有在版本5中实现它.