Alex
Alex

Reputation: 483

SQL Error after runnning composer update

I needed to run composer update to install laravelcollectives. After running it I got:

QueryException in Connection.php line 651: SQLSTATE[42S22]: Column not found: 1054 Field'id' is unknown where clause (SQL: select * from users where id = 4 limit 1)

and:

PDOException in Connection.php line 319: SQLSTATE[42S22]: Column not found: 1054 field'id' is unknown where clause

There was no such error before the update. What could have gone wrong?!

Upvotes: 1

Views: 464

Answers (1)

Pᴇʜ
Pᴇʜ

Reputation: 57683

What you really did wrong is you ran composer update to install a package into a working project.

To install a new package into a already good working environment always use composer require vendor/package:2.* in your case e.g.:

composer require laravelcollective/html:5.2.*

Why never run composer update to install a package?

As the command update already says it updates every package required in your composer.json to the newest version (based on your minimum-stability and version tag). Yes it also installs new packages but if you run into errors after running update you never know what happened. Is it the new package which killed your working project or any of the also updated packages. So only run update if you really want to update and never if you want to install a package. Therefore use composer require as it only installs a new package but never touches existing packages.

Upvotes: 1

Related Questions