Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Database Association Incompatibilities #17429

Open
umer936 opened this issue Nov 16, 2023 · 2 comments
Open

Show Database Association Incompatibilities #17429

umer936 opened this issue Nov 16, 2023 · 2 comments

Comments

@umer936
Copy link
Contributor

umer936 commented Nov 16, 2023

Description

A few times now I have had where the belongsToManys don't match up and I get the error about it.

e.g. this using the join table was wrong due to foreign key mismatches.

        $this->belongsToMany('Roles', [
            'joinTable' => 'download_layouts_roles',
            'foreignKey' => 'download_layout_id',
            'targetForeignKey' => 'id',
            'dependent' => true,
        ]);
        $this->belongsToMany('DownloadLayouts', [
            'foreignKey' => 'role_id',
            'targetForeignKey' => 'download_layout_id',
            'joinTable' => 'download_layouts_roles',
        ]);

My solution has been to rebake the Models using bin/cake bake model --update and compare with git diff.
But given that there's a check routes, maybe there could be a database check as well? Would be helpful to run as like a CI command when running the PHP testing tools and to be told what to fix.

Unsure if this exists in other frameworks.

CakePHP Version

4.5.0

@LordSimal
Copy link
Contributor

Refs: cakephp/bake#592

@markstory markstory added this to the 4.5.2 milestone Nov 17, 2023
@markstory markstory added the ORM label Nov 17, 2023
@dereuromark
Copy link
Member

Should we close this given that this seems to be more a sattelite issue (plugins or custom solutions?)

@markstory markstory modified the milestones: 4.5.2, 4.5.3 Dec 15, 2023
@markstory markstory modified the milestones: 4.5.3, 4.5.4 Jan 20, 2024
@markstory markstory modified the milestones: 4.5.4, 4.5.5 Mar 6, 2024
@markstory markstory modified the milestones: 4.5.5, 4.5.6 May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants