如何在cakephp3中使用phinx迁移更改列时设置tinyint,smallint类型的可见长度?

时间:2018-05-10 10:58:25

标签: mysql database-migration cakephp-3.x phinx

我尝试了以下代码来迁移字段" exp"对于数据类型tinyint(2),我想用数据类型tinyint制作可见长度为2。

$table->changeColumn('exp', 'integer', [
            'limit' =>  MysqlAdapter::INT_TINY,
//is there any option to set visible length 2, by default it is taking length 4
//I tried 'length'=>4, but it overrides 'limit' and datatype becomes int(4)
            'null' => false,
            'default' => '0'
        ]);

I want alter the column with this type

1 个答案:

答案 0 :(得分:0)

尝试简单查询:

$this->execute('ALTER TABLE `table_name` ADD COLUMN `exp` TINYINT(2) NOT NULL DEFAULT 0');