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

guicsvcw  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(554)

我尝试了下面的代码来将字段“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'
        ]);

我想用这种类型改变这个列

uxh89sit

uxh89sit1#

尝试普通查询:

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

相关问题