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

arturd's avatar

Why can't Laravel do the migration of tables if in a controller it shows the records correctly?

I have a laravel 7 with postgres 9.5, when I try to show some records the answer is ok, works well. But when i try to do a migration with php artisan migrate, I have an driver error. Composer is updated. (In laravel 8 the same thing happens)

Test query controller, response ok with the records in the view:

object(Illuminate\Support\Collection)#284 (1) { ["items":protected]=> array(2) { [0]=> object(stdClass)#286 (3) { ["id"]=> int(1) ["title"]=> string(5) "aaaaaaa" ["title2"]=> string(4) "bbbbbbb" } } }

The error: php artisan migrate response:

Illuminate\Database\QueryException could not find driver (SQL: select * from information_schema.tables where table_schema = myschema and table_name = migrations and table_type = 'BASE TABLE')

I already tried these commands, without success.

php artisan cache:clear php artisan config:cache php artisan optimize:clear

I don't understand how laravel can access the records in a controller but not access to do the migration

I accept ideas of all colors. Thanks!

0 likes
6 replies
Sinnbeck's avatar

How are you running laravel? Docker by any chance?

arturd's avatar

@Sinnbeck unfortunately I can't use docker, it's a classic ubuntu server. A production server. Thanks!

Sinnbeck's avatar

@arturd try php -m. Does it show pdo_pgsql?

If not try installing it again (replace with correct version)

sudo apt install php7. 4-pgsql
1 like
arturd's avatar

@Sinnbeck openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix readline you are right !!, but the strange thing is that I can see doing select from a controller. I will see how I can touch php.ini. testing... Thanks sinnbeck

arturd's avatar

@Sinnbeck I'm going to try, I'm going slowly because it's a production server. Thanks!!

jlrdw's avatar

@arturd I would suggest backing up your data before doing any migrations on a live production server.

2 likes

Please or to participate in this conversation.