I'm Running CakePhp 2.7 with Migrations Plugin and a Postgresql DB. Creating a field of type 'number' and specifying length 15,4 (scale 15, precision 4 - or any length) does not actually create the field with that precision and/or scale.
...
'license_fee' => array(
'type' => 'number',
'null' => true,
'length' => '15,6',
'default' => 0
),
...
The field is created with the correct type (numeric) but with no scale/precision here is the Postgres description of the created field.
license_fee | numeric | default 0
What I was expecting to see is this
license_fee | numeric(15,6) | default 0
I also tried using 'type' => 'decimal' but same happened. This might not be supported by the migrations plugin but I just want to know if anyone knows for sure what's going on.
After further investigation and some help from Cake Development Corp. It turns out that the correct to way specify precision and scale is by using "limit" not "length" like I was attempting. So it should be like this:
'license_fee' => array(
'type' => 'number',
'null' => true,
'limit' => '15,6', //this is where I was wrong by using length
'default' => 0
),
This will work also if using 'type' => 'decimal' which is actually the same datatype. The end result is as expected:
license_fee | numeric(15,6) | default 0
I hope this useful for someone.