Setting scale and precision for MySQL float column
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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