4

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! :)

Christian Baumann
  • 3,188
  • 3
  • 20
  • 37
MagAdmin
  • 41
  • 1
  • 3
  • You might have forgotten to run your migrations. https://jetstream.laravel.com/1.x/installation.html#installing-jetstream. Though migrations are only for new installs, are you trying to add this to an existing Laravel app? – miken32 Oct 09 '20 at 16:37

2 Answers2

9

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.

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
SouthernBoy
  • 223
  • 2
  • 5
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/27441780) – Derek Pollard Oct 21 '20 at 20:39
  • 2
    If this is on local it absolutely fixes the problem. However, if it's on a production server he will have to manually add the column to the users table. – SouthernBoy Oct 23 '20 at 13:08
  • I just want to elaborate here a bit further. I ran the command "php artisan migrate:fresh" which worked for me and thankfully its a brand new app that I just started developing on a local web server with so I am not worried about loosing data this point in the development cycle. The reason why @SouthernBoy mentioned that you will need to add this column manually if on a production server is cause this will dump all data in the database where you have migrations and recreate the tables. You will not have any data in them so please backup any data if you are worried before you begin dev work. – rapid3642 Jan 18 '21 at 02:58
  • @rapid3642 As the documentation said (https://jetstream.laravel.com/2.x/installation.html#installing-jetstream) : New Applications Only Jetstream should only be installed into new Laravel applications. Attempting to install Jetstream into an existing Laravel application will result in unexpected behavior and issues. – bumerang Nov 01 '21 at 14:39
0

Please goto phpmyadmin dashboard & find the users table.

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

Thanks

Waqar Akram
  • 107
  • 5
  • Just wanting to elaborate here a bit further. If you do end up wanting to manually create this column in the user table then here are the standard info that Laravel tries to create the column with: [Name - current_team_id] [Type - bigint(20)] [Attributes - UNSIGNED] [Null - Yes] [Default - NULL] – rapid3642 Jan 18 '21 at 03:01