I have found this question very similar to mine Make column not nullable in a Laravel migration though it is almost 3 years old and it surely does not belong to Laravel 5
My problem is that I have a migration which in the up
function it modifies a column to make it nullable.
Now, in the down
function I want to make it not nullable again.
/**
* 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();
});
}
I could achieve that using raw SQL, but I would like to do it using Laravel methods if it is possible... but I couldn't find it, probably it hasn't been implemented it in the version 5 either.