how can I create a migration to add a value to an enum in eloquent

Laravel doesn’t provide methods to update an enum column. You can delete and recreate the column but you could loose data during the operation and it’s not really clean.

In this case, I think that the best choice is to write raw SQL into a migration :

public function up()
{
    DB::statement("ALTER TABLE user_status MODIFY COLUMN ENUM('on','off','unknown')");
}

public function down()
{
    DB::statement("ALTER TABLE user_status MODIFY COLUMN ENUM('on','off')");
}

I could have made a mistake in the SQL syntax, I have never used ENUM, but you can see the idea anyway.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)