cakephp / cakephp/phinx

Alter key support?

Open
#784 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In some conditions keys are not modifiable while you could still modify them using plain sql.

Say you have foreign key. If you want to modify that key by adding another column to the key, you could do it like this way:

ALTER TABLE `records` 
  DROP INDEX `record_types`, 
  ADD UNIQUE `record_types` (`edition_id`, `date`);

However, phinx splits this into two queries and this surely breaks as this key is required and could not be removed.

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

The issue names no files or tests. Start by reproducing a foreign-key key modification using the combined MySQL ALTER TABLE statement and the two statements Phinx generates, then trace the migration path that alters keys. Done means the key can be modified without failing because the required key is removed first.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, 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.