cakephp / cakephp/phinx

Setting scale and precision for MySQL float column

Open
#1,976 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

I believe I've found an undocumented way to correctly set the float(scale,precision) column type for MySQL using Phinx, but before I make a PR to add it to the documentation, I figured I'd better ask here if this is intended correct behavior, or lucky happenstance.

Example

I have a column with definition float(3,2) and I need to expand it to be float(4,2).

The following appears to work, but is undocumented in both the Phinx and CakePHP documentation.

public function up(): void
{
    $this->table('my_table')
        ->changeColumn('my_column', 'float', ['scale' => 2, 'precision' => 4])
        ->save();
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the documented column-change behavior in the Phinx and CakePHP documentation, using the issue's float(3,2) to float(4,2) example as the starting point. Confirm whether the scale and precision options are intended for MySQL float columns; done means the supported behavior and example are clearly documented, or the issue is resolved with an explicit explanation.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
databases, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.