====== 【Laravel】マイグレーションで tinyint のカラム属性の変更 ====== マイグレーションで DB のカラム属性の変更に使う change() は、残念ながら tinyInteger に対応していない。\\ なので、以下のようなマイグレーションを実行しようとすると public function up() { Schema::table('users', function (Blueprint $table) { $table->tinyInteger('number')->nullable()->comment('数値')->change(); }); } 以下のようなエラーが表示されてしまう。 > 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 with \Doctrine\DBAL\Types\Type::getTypesMap(). > If this error occurs during database introspection then you might have forgotten 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. 対処法としては、以下のようにカラム属性を変更する sql 文を直接書くとマイグレーションが通る。 public function up() { Schema::table('users', function (Blueprint $table) { DB::statement('alter table users modify column number tinyint not null comment "数値"'); }); }