Closed ChrisExP closed 1 year ago
Hey 👋
I was trying to reproduce this issue, but no luck s far.
Can you please share your migration code + version of Postgres ? Thank you !
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.
laravel new bug-report --github="--public"
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.
I have been able to reproduce it in this repository: https://github.com/ChrisExP/bug-report
Just hook that up to a postgres DB and run php artisan migrate
. The last migration will fail when it tries to drop the primary key in the test
table.
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 $prefixAlias
on wrap
does not solve it.
@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
config