-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Dropping a primary key in PostgreSQL does not take into account the table prefix #48189
Comments
Hey 👋 I was trying to reproduce this issue, but no luck s far. Can you please share your migration code + version of Postgres ? |
Hey there, thanks for reporting this issue. We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.
Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue. Thanks! |
Thanks for looking into it. Just hook that up to a postgres DB and run I don't think this is relevant, but I will mention it just in case. I am on an M1 mac, and Postgres is still not natively supported on Homestead-ARM, so I have been using Docker with Rosetta to use Postgres locally. |
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
I can confirm this but can't immediately find a good solution. Would appreciate any help here. Using |
@driesvints Please let me know if my solution works 👀 |
Hey there, v10.21.1 with the relevant changes has been released, please try again and open up a new issue if you're still experiencing this problem. |
Laravel Version
10.20.0
PHP Version
8.2.2
Database Driver & Version
No response
Description
When you create a primary key index in Postgres it is given the name
"{$table}_pkey"
. This is added by postgres so the name has the table prefix automatically.When you drop the primary key, the prefix is not added to the SQL so it fails. The code is in
src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
line 430:The
wrap
method does not automatically add the prefix to the string. It requires a second argument ($prefixAlias = true
) I think. But I'm not to confident with this code, so I don't know what sort of effect that will have. There may be a better way to do it.Steps To Reproduce
database
configThe text was updated successfully, but these errors were encountered: