migrations icon indicating copy to clipboard operation
migrations copied to clipboard

migration_diff generates incorrect code for decimal column definition change

Open thonhaus opened this issue 2 years ago • 2 comments

This is a (multiple allowed):

  • [x] bug

  • CakePHP Version: 4.4.16

  • Migrations plugin version: 3.9.0

  • Bake plugin version (if relevant): 2.9.3

  • Database server (MySQL, SQLite, Postgres): MariaDB

I have a MariaDB with a table containing a decimal column (e.g., defined as DECIMAL(4,2)). A migration snapshot was taken of this. If the definition is then changed (e.g., to DECIMAL(6,2)) and a migration diff is created, this leads to incorrect code.

The resulting code is

$this->table('mytable')
    ->changeColumn('mycolumn', 'decimal', [
        'default' => null,
        'limit' => 6,
        'null' => true,
])

and should be

$this->table('mytable')
    ->changeColumn('mycolumn', 'decimal', [
        'default' => null,
        'precision' => 6,
        'scale' => 2,
        'null' => true,
])

thonhaus avatar Nov 10 '23 13:11 thonhaus

Might this be fixed by https://github.com/cakephp/migrations/pull/571 ?

dereuromark avatar Nov 10 '23 15:11 dereuromark

Also those seem related:

  • https://github.com/cakephp/phinx/issues/1481
  • https://github.com/cakephp/migrations/issues/314

dereuromark avatar Nov 10 '23 15:11 dereuromark