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

问题描述 投票:3回答:1

我尝试了以下代码将字段“ 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

mysql database-migration cakephp-3.x phinx
1个回答
0
投票

尝试普通查询:

$this->execute('ALTER TABLE `table_name` ADD COLUMN `exp` TINYINT(2) NOT NULL DEFAULT 0');
© www.soinside.com 2019 - 2024. All rights reserved.