尝试在 Laravel 5.2 迁移中将数据列类型更改为tinyInteger:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AlterTableNameTableChangeNotificationSentTinyint extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('table_name', function ($table) {
$table->tinyInteger('column_name')->default(0)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
我收到错误:
Doctrine\DBAL\DBALException]
Unknown column type "tinyinteger" 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 wit
h \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 Abstrac
tPlatform#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 so
me mapping information.
难道我做错了什么?
事实上 Doctrine Dbal 不支持tinyint
你可以从他们的文档中阅读here http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#integer-types
同样不幸的是,laravel 指出tinyint
无法更改。查看here https://laravel.com/docs/5.4/migrations#modifying-columns
我需要有人证明这是错误的,因为我的一个项目由于这个问题而不得不使用smallInteger。我在想也许boolean()
可能是解决方案。不过我还没有尝试过。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)