簡體   English   中英

Illuminate\Database\QueryException SQLSTATE[42S22]:未找到列:1054“字段列表”中的未知列“current_team_id”

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM