Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dkortvelyessy's avatar

Fail to migrate database schema : Issue after upgrade

Greetings all!

History:

I have updated my laravel 8 project to 10.48 as the latest one without breaking changes. The app runs just fine in the browser.

Now I wanted to re-write the app in a vue-tailwind using laravel 11. During the process I discovered, that even though the app runs fine in the browser, I cannot execute any database related actions in the CLI.

Setup:

I use two docker containers. One with the app and one for the pgsql database.

The issue:

If I try to have a fresh database schema using:

sudo docker exec -ti app php artisan migrate

I get the following error:

The mentioned file pgsql-schema.sql exists, however, it is empty.

My expectation, would be that the script just checks for an existing schema and proceeds if it is empty.

I remember that the db:dump needed to have the pgsql client installed in the application container. Might this be a similar issue?

Any ideas appreciated (face-palms accepted if required).

Cheers, Daniel

0 likes
3 replies
LaryAI's avatar
Level 58

The error message you're encountering indicates that the psql command is not found in your application container. This is likely because the PostgreSQL client tools are not installed in the container where you're trying to run the migration. Here's how you can resolve this issue:

  1. Install PostgreSQL Client Tools in the Application Container:

    You need to ensure that the PostgreSQL client tools are installed in your application container. You can do this by modifying your Dockerfile or by directly installing it in the running container.

    If you have access to the Dockerfile for your application container, you can add the following line to install the PostgreSQL client:

    RUN apt-get update && apt-get install -y postgresql-client
    

    If you want to install it directly in the running container, you can execute the following command:

    sudo docker exec -ti app bash -c "apt-get update && apt-get install -y postgresql-client"
    
  2. Verify the Installation:

    After installing the PostgreSQL client, verify that psql is available by running:

    sudo docker exec -ti app psql --version
    

    This should output the version of the PostgreSQL client, confirming that it is installed.

  3. Retry the Migration:

    Once the PostgreSQL client is installed, try running your migration command again:

    sudo docker exec -ti app php artisan migrate
    

By ensuring that the PostgreSQL client tools are installed in your application container, the psql command should be available, and your migration should proceed without the "command not found" error.

dkortvelyessy's avatar

Thank you Lary :)

I made these changes and behold, the command was found, but I ran into other issues.

The point is, that after that trails, I made a fresh laravel 11 installation in another container. This one runs all migrations smoothly, despite not having the postgresql-client installed.

Therefore, I assume it must be a breaking change in my code or in the dependencies. Will post an update, if I find something.

dkortvelyessy's avatar
dkortvelyessy
OP
Best Answer
Level 15

Ok. It appears that I located the issue, but I do not understand why.

There was that empty file at ~/database/schema/pgsql-schema.sql

It appeared in the last commit of the code.

I just deleted that empty SQL file and behold! All migrations run smoothly again, as they should.

Now I have to find out why or who put that file and why the migrations would crash if the file is empty.

Please or to participate in this conversation.