Laravel 5.1 Unknown database type enum requested
The official Laravel 5.1 documentation states:
Note: Renaming columns in a table with a enum column is not currently supported.
It doesn't matter if you're trying to change another column, if the table contains a enum
anywhere it won't work. It's a Doctrine DBAL issue.
As a workaround you could either drop the column and add a new one (column data will be lost):
public function up()
{
Schema::table('users', function(Blueprint $table)
{
$table->dropColumn('name');
});
Schema::table('users', function(Blueprint $table)
{
$table->text('username');
});
}
or use a DB statement:
public function up()
{
DB::statement('ALTER TABLE projects CHANGE slug url VARCHAR(200)');
}
public function down()
{
DB::statement('ALTER TABLE projects CHANGE url slug VARCHAR(200)');
}
Source: https://github.com/laravel/framework/issues/1186
Laravel db migration - renameColumn error - Unknown database type enum requested
Laravel's documentation says that:
Note: Renaming
enum
column types is not supported.
Here: https://github.com/laravel/framework/issues/1186
You can find some workarounds about this issue. And since you said that this column is not enum
, take a look at @upngo's comment:
"...The issue is renaming ANY column on a table that has an
enum
."
Also I found this article that focuses on this issue and suggest an option that might help you.
http://www.paulbill.com/110/laravel-unknown-database-type-enum-requested-doctrinedbalplatformsmysqlplatform-may-not-support-it
Laravel 5.5 Unknown database type enum requested Doctrine\DBAL may not support it
I added the dependencies to my composer.json
"require": {
"laravel/framework": "5.5.*",
"doctrine/dbal": "^2.5",
}
and run the composer install
command.
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it. Symfony
Couldn't reproduce your issue. But anyway you can set up enum type in doctrine.yaml like
doctrine:
dbal:
.....
mapping_types:
enum: string
Unknown database type enum requested doctrine
Doctrine is not able to reverse engineer the whole model from the database. There are some cases, which can not be handled - like your enums. You will have to define custom types, to tell the doctrine how it have to handle it.
Take a look at this guideline:
-> Scroll to „Solution 2 Defining a Type“
https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/mysql-enums.html#solution-1-mapping-to-varchars
Laravel 5.4 migration ENUM fails in MySQL
Information related strictly to laravel can be found here. I highly advise you read the thread. This is NOT a laravel issue, it's been a bug in Doctrine since forever.
From the issue thread above, user henritoivar
has an interesting idea.
Quoting here:
This worked for me in laravel 5.2 with doctrine/dbal@^2.5 . When you
have an enum on your table and you want to change any of the columns
on the table you will have to:
public function up()
{
Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
Schema::table('jobs', function(Blueprint $table)
{
$table->decimal('latitude', 10, 6)->nullable()->change();
});
}
I have no idea if this will work for you, but it's worth a try.
I would have posted this as a comment, but it's a damn long read.
From the official Doctrine documents:
The type system of Doctrine 2 consists of flyweights, which means
there is only one instance of any given type. Additionally types do
not contain state. Both assumptions make it rather complicated to work
with the Enum Type of MySQL that is used quite a lot by developers.
When using Enums with a non-tweaked Doctrine 2 application you will get errors from the Schema-Tool commands due to the unknown
database type “enum”. By default Doctrine does not map the MySQL enum
type to a Doctrine type. This is because Enums contain state (their
allowed values) and Doctrine types don’t.
Technically speaking this can be solved. See here. But that relates strictly to symfony, on which Laravel is based.
Laravel's docs also stated that it has a problem with enums
:
Renaming any column in a table that also has a column of type enum is >not currently supported.
While this is not an answer, I hope it points you in the right direction or at least gives you an idea of what you're facing.
More related questions:
How to enable ENUMs in Symfony 2 / Doctrine
Laravel 5.1 Unknown database type enum requested
Laravel db migration - renameColumn error - Unknown database type enum requested
Laravel's documentation says that:
Note: Renaming
enum
column types is not supported.
Here: https://github.com/laravel/framework/issues/1186
You can find some workarounds about this issue. And since you said that this column is not enum
, take a look at @upngo's comment:
"...The issue is renaming ANY column on a table that has an
enum
."
Also I found this article that focuses on this issue and suggest an option that might help you.
http://www.paulbill.com/110/laravel-unknown-database-type-enum-requested-doctrinedbalplatformsmysqlplatform-may-not-support-it
Laravel migration uknown database enum requested
I suggest you to use facade of query builder to achieve the same,
DB::statement("ALTER TABLE order CHANGE COLUMN status status
ENUM('CREATED', 'FINISHED', 'CLOSED') NOT NULL DEFAULT 'CREATED'");
By raw migration it is not possible,
NOTE:- Only the following column types can be "changed": bigInteger, binary, boolean, date, dateTime, dateTimeTz, decimal,
integer, json, longText, mediumText, smallInteger, string, text, time,
unsignedBigInteger, unsignedInteger and unsignedSmallInteger.
Unknown database type json requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it. while running php artisan migrate command
try this solution may be this will work for you,
public function __construct()
{
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('json', 'text');
}
For further reading about this issue check Issue #15772 at laravel repo
Related Topics
Sort Array by Length and Then Alphabetically
How to Change Default Redirect Url of Laravel 5 Auth Filter
Check If a Remote Page Exists Using PHP
Is This a PHP Date() Bug, or Is There Something Wrong with My Code
Why Are $_Server["Php_Auth_User"] and $_Server["Php_Auth_Pw"] Not Set
Scrape Web Site Generated by JavaScript
Array Merge on Multidimensional Array
How Is Output(Echo) Array Without Use of JSON_Encode(Codeigniter)
Empty Values Passed to Zend Framework 2 Validators
5.4 Dereferencing to Valid 5.3 Array Call
PHP 7: Missing Vcruntime140.Dll
JSON_Encode/JSON_Decode - Returns Stdclass Instead of Array in PHP
Only Variables Should Be Passed by Reference In... on Line 13 Fail
How to Manually Return or Throw a Validation Error/Exception in Laravel
Multiple Auto Increment in MySQL
Working with Two Entity Managers in the Same Bundle in Symfony2