[英]How to fix “Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column”?
[英]Illuminate\Database\QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'current_team_id' in 'field list'
设置:将数据库从 laravel 7 迁移到 laravel 8,Jetstream with Teams (php artisan jetstream:install inertia --teams), inertia.js
Illuminate\Database\Connection::runQueryCallback
vendor/laravel/framework/src/Illuminate/Database/Connection.php:671`
Illuminate\Database\QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'current_team_id' in 'field list' (SQL: update `users` set `current_team_id` = 1, `users`.`updated_at` = 2020-10-08 21:22:00 where `id` = 5)
/* @throws \Illuminate\Database\QueryException */
protected function runQueryCallback($query, $bindings, Closure $callback)
{
// To execute the statement, we'll simply call the callback, which will actually
// run the SQL against the PDO connection. Then we can calculate the time it
// took to execute and log the query SQL, bindings and time in our memory.
try {
$result = $callback($query, $bindings);
}
// If an exception occurs when attempting to run a query, we'll format the error
// message to include the bindings with SQL, which will make this exception a
// lot more helpful to the developer instead of just the database's errors.
catch (Exception $e) {
throw new QueryException(
$query, $this->prepareBindings($bindings), $e
);
}
return $result;
}
/**
* Log a query in the connection's query log.
*
* @param string $query
* @param array $bindings
* @param float|null $time
* @return void
*/
未找到列您可能忘记运行迁移。 您可以使用 php artisan migrate 运行迁移。
按下面的按钮将尝试运行您的迁移。
迁移没有解决问题。 将列放在哪里? 怎么修?
谢谢你们: :)
看起来迁移错过了一个领域。 通常是由于以错误的顺序运行。 您可以运行下面的命令来重新创建您的数据库,它应该可以解决问题。
php artisan migrate:fresh
。
请转到 phpmyadmin 仪表板并找到用户表。
现在在用户表中添加一个名为 current_team_id 的新列。
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.