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

collider's avatar

artisan migrate:install not respecting Postgresql schema on Amazon RDS

I'm trying to deploy an existing project into a new AWS environment, with Postgresql via RDS, and I need Laravel to create the migrations table in the database, so that I can then run my migrations.

When I issue the "php artisan migrate:install" command, I get the following error:

SQLSTATE[3F000]: Invalid schema name: 7 ERROR: no schema has been selected to create in at character 14 (SQL: create table "migrations" ("id" serial primary key not null, "migration" varchar(255) not null, "batch" integer not null))

This is despite the correct schema being specified in config/database.php.

I've also tried setting the search_path for both the database and the role to only include the correct schema but it makes no difference.

I could probably fudge this by editing Laravel's core code to change the table name to "schema.migrations" but that's a nasty kludge and would rather fix this the right way.

I am using Laravel 5.7.

0 likes
2 replies
collider's avatar

I should clarify that I am using a schema other than the default "public" schema and that I do have CREATE and USAGE privileges on the schema.

I am able to create tables with both psql and pgAdmin, using the same connection details, but Artisan always fails with the error above.

hanmari's avatar

Hi Collider, did you ever resolve this issue? I'm experiencing something similar with my Artisan migrate command, where the scripts run just fine in my local docker environment, but when I try to deploy to an environment that implements AWS RDS postgres the migrate script fails when it cannot switch back and forth between the postgres schemas in the same database. In my case, the error message indicates that the migration script cannot locate the migrations table from the original schema after schema and connection switching. I suspect this may be an AWS driver issue with a cached connection, as the scripts have no problem with my standard docker image for postgres.

Please or to participate in this conversation.