cakephp / cakephp/phinx

Problem foreign key with table name without prefix

Open
#2,043 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi
I want to connect the foreign key to another table that is not related to the project. What should I do, for example:

phinx config:
table_prefix = 'ac_'

table1 : ac_user
table2 : core_user

ALTER TABLE `ac_user`
ADD CONSTRAINT `ac_user_user_id` FOREIGN KEY (`user_id`) 
REFERENCES `core_user` (`user_id`) 
ON DELETE CASCADE ON UPDATE CASCADE

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 with the Phinx configuration and the table_prefix behavior, then trace how a foreign-key migration generates the shown ALTER TABLE statement for ac_user and core_user. Confirm whether references to a table outside the configured prefix are supported; done means the generated SQL can target core_user without incorrectly applying ac_.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.