You should not use enum at all.
The official Laravel 5.1 documentation states:
Note: Renaming columns in a table with a enum column is not currently supported.
It happens when you have a enum
column in your database table. Whether you are trying to rename
another column, or change another column to nullable
, the bug will appear. It's an issue with Doctrine\DBAL.
Unknown database type enum requested
Even with laravel 5.8, problem is not resolved.
I need to add that 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.
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']);
});
}