简体   繁体   中英

Illuminate\Database\QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'current_team_id' in 'field list'

Setup: migrated db from laravel 7 to 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
 */

A column was not found You might have forgotten to run your migrations. You can run your migrations using php artisan migrate.

Pressing the button below will try to run your migrations.

Migration didn´t fix the problem. Wher to put the column in? How to fix?

Thank you guys: :)

It looks like the migrations have missed a field. Usually due to being run in the incorrect order. You can run the command below to recreate your database and it should fix the problem.

WARNING

This command will delete all your data so only run on development.

php artisan migrate:fresh .

Please goto phpmyadmin dashboard & find the users table.

Now in users table add a new column named as current_team_id.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM