Add default value to enum type field in schema builder Add default value to enum type field in schema builder laravel laravel

Add default value to enum type field in schema builder


From the MySQL manual:

If an ENUM column is declared to permit NULL, the NULL value is a legal value for the column, and the default value is NULL. If an ENUM column is declared NOT NULL, its default value is the first element of the list of permitted values.

I'm assuming this means you should set 'active' as the first value, remove the default() call, and possibly set NULL permittance manually.


use this :

$table->enum('status',['new', 'active', 'disabled'])->default('active');


I ran into a similar issue, that's what worked for me:

$table->enum('status', array('active', 'new', 'disabled'));

Place the default value as the first element in the array. active is now the default value.