我尝试了以下代码来迁移字段" 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'
]);
答案 0 :(得分:0)
尝试简单查询:
$this->execute('ALTER TABLE `table_name` ADD COLUMN `exp` TINYINT(2) NOT NULL DEFAULT 0');