You should not use enum at all. Even with laravel 5.8, problem is not resolved.
Thank's to everyone who reminded that
The official Laravel 5.1 documentation states:
Note: Renaming columns in a table with a enum column is not currently supported.
Plus you will have the same problem when adding available options into enum column declaration.
It brings me to a conclusion that You should use enum with care. or even You should not use enum at all.
I cannot vote up any answer that offer to replace enum with string. NO, you need to create a lookup table and replace enum with unsignedInteger as a foreign key.
It is a lot of work and you'll be upset doing it without previous unit-test coverage, but this is a right solution.
You may be even fired for doing this correctly, because it is taking too long, but, don't worry, you'll find a better job. :)
Here is an example of how difficult would it be adding available options into enum column declaration
say you have this:
Schema::create('blogs', function (Blueprint $table) {
$table->enum('type', [BlogType::KEY_PAYMENTS]);
$table->index(['type', 'created_at']);
...
and you need to make more types available
public function up(): void
{
Schema::table('blogs', function (Blueprint $table) {
$table->dropIndex(['type', 'created_at']);
$table->enum('type_tmp', [
BlogType::KEY_PAYMENTS,
BlogType::KEY_CATS,
BlogType::KEY_DOGS,
])->after('type');
});
DB::statement('update `blogs` as te set te.`type_tmp` = te.`type` ');
Schema::table('blogs', function (Blueprint $table) {
$table->dropColumn('type');
});
Schema::table('blogs', function (Blueprint $table) {
$table->enum('type', [
BlogType::KEY_PAYMENTS,
BlogType::KEY_CATS,
BlogType::KEY_DOGS,
])->after('type_tmp');
});
DB::statement('update `blogs` as te set te.`type` = te.`type_tmp` ');
Schema::table('blogs', function (Blueprint $table) {
$table->dropColumn('type_tmp');
$table->index(['type', 'created_at']);
});
}
enumcolumn?enumit won't work. I'm afraid that you will have to change that manually somehow, or try some rather ugly hacks or workarounds.