4

I tried the following code to migrate a field "exp" to datatype tinyint(2), i want to make visible-length 2 with datatype tinyint.

$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

D Coder
  • 331
  • 2
  • 10
  • please do not down vote, i went through the docs provided by phinx, but did not find any answer to this query. – D Coder May 10 '18 at 11:07
  • Note: Without `ZEROFILL` there is no difference between `TINYINT(2)` and `TYNYINT(4)`. – Paul Spiegel May 10 '18 at 11:12
  • I understand you point @PaulSpiegel you are right but, since the ZEROFILL is not provided in the new table structure i have not mentioned it.I checked the phinx docs, there is no option for ZEROFILL as well. – D Coder May 10 '18 at 11:37

1 Answers1

1

Try plain query:

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