cakephp / cakephp/phinx

Non-set keys should not be altered

Open
#1,221 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Moved https://github.com/cakephp/migrations/issues/330 over to here.

Currently

		$table->changeColumn('status', 'string', [
			'encoding' => 'utf8mb4',
			'collation' => 'utf8mb4_unicode_ci',
		]);

Kills most other settings like

			'null' => true,
			'default' => null,

Silently changing the other table field properties here now makes inserts impossible without specifying these now non-null-default values.

One always needs to check and add all those into every changeColumn, instead of just altering what is defined here in the migration file.
This leads to some really dangerous DB regressions.
Maybe we can merge with existing scheme before applying?

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

Start at the changeColumn entry point shown in the issue and reproduce the migration that changes only the column type while existing null and default settings are present. Trace how the current column definition is built and applied, then verify that unspecified properties remain unchanged and that inserts still work without explicitly supplying them.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.