CakePHP3:tinyintとsmallintのマイグレーションファイル

bakeコマンドでマイグレーションファイルを作成すると、次のような内容が生成されます:

        $this->table('statuses')
            ->addColumn('id', 'tinyinteger', [
                'default' => null,
                'limit' => 3,
                'null' => false,
            ])
            ->addPrimaryKey(['id'])
            ->addColumn('name', 'string', [
                'default' => null,
                'limit' => 255,
                'null' => false,
            ])
            ->create();

これ、migrations migrateしても失敗するので、次のように修正する必要があります。

useの追加

マイグレーションファイルの冒頭に

use Phinx\Db\Adapter\MysqlAdapter;

と追加します

limitの置換

tinyintの場合、'limit' => 3の部分を'limit' => MysqlAdapter::INT_TINYに置き換えます。 smallintの場合はMysqlAdapter::INT_SMALLに置き換えます。

smallintegerとtinyintegerの置換

これらはintegerに置き換えます