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

Issue with constrained() method used after foreignIdFor(), instead of table name when $table parameter is not passed uses column name #53144

Merged
merged 9 commits into from
Oct 15, 2024

Conversation

granitibrahimi
Copy link
Contributor

When constrained() is used after foreignIdFor() then on the migration query for the constrained instead of the table name uses column name and pluralise it.

$table->foreignIdFor(User::class, 'assigned_at')->nullable()->constrained();

Query produced to add the constrain:

alter table `tasks` add constraint `tasks_assigned_at_foreign` foreign key (`assigned_at`) references `assigned_ats` (`id`);

so instead of references users it produces references assigned_ats pluralised name of the column.

@granitibrahimi granitibrahimi marked this pull request as draft October 13, 2024 17:00
@granitibrahimi granitibrahimi marked this pull request as ready for review October 13, 2024 22:15
@taylorotwell taylorotwell merged commit f69a736 into laravel:11.x Oct 15, 2024
31 checks passed
@morloderex
Copy link
Contributor

This pr broke our migrations.

@crynobone
Copy link
Member

This pr broke our migrations.

Can you submit a bug report with reproducing code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants