无法使用CHAR数据类型更新Laravel 5.1中的列属性

Deb*_*sad 5 doctrine doctrine-orm laravel laravel-5.1

这是我的迁移代码:

public function up()
{
    Schema::table('companies', function (Blueprint $table) {
        $table->char('default_unit_for_weight', 2)->default('kg')->after('notes')->change();
        $table->char('default_currency', 3)->default('EUR')->after('default_unit_for_weight')->change();
    });
}
Run Code Online (Sandbox Code Playgroud)

运行迁移时,出现以下错误:

[Doctrine\DBAL\DBALException] Unknown column type "char" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgot to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information.

当我检查\Doctrine\DBAL\Types\Type课程时,发现以下代码:

const TARRAY = 'array';
const SIMPLE_ARRAY = 'simple_array';
const JSON_ARRAY = 'json_array';
const BIGINT = 'bigint';
const BOOLEAN = 'boolean';
const DATETIME = 'datetime';
const DATETIMETZ = 'datetimetz';
const DATE = 'date';
const TIME = 'time';
const DECIMAL = 'decimal';
const INTEGER = 'integer';
const OBJECT = 'object';
const SMALLINT = 'smallint';
const STRING = 'string';
const TEXT = 'text';
const BINARY = 'binary';
const BLOB = 'blob';
const FLOAT = 'float';
const GUID = 'guid';
Run Code Online (Sandbox Code Playgroud)

这意味着Doctrine不支持数据类型CHAR。有什么方法可以使用CHAR数据类型更改Laravel 5.1中的列属性吗?

zak*_*ius 0

您可以使用原始查询来迁移(DB::statement('query')),但我不确定 Eloquent 是否不会恐慌,但它不应该