Ad

"Migrate Reset" Not Working When There Is An Error In Code

In basic Laravel application, in User class I added:

use SoftDeletes;

Application is no longer working because there is no 'deleted_at' column in the User table of MySql database. I'm trying to add this column by dropping all tables and recreating them (or by dropping all tables):

artisan migrate:refresh --seed

artisan migrate:reset

artisan migrate:fresh

In all cases I get an error:

Illuminate\Database\QueryException : SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.deleted_at' in 'where clause' (SQL: select exists(select * from users where email = [email protected] and users.deleted_at is null) as exists)

which I don't understand. If I'm reverting migrations, artisan should only call down() method on my User class which is:

public function down()
{
    Schema::dropIfExists('users');
}

and dropping table shouldn't fail if column is not found.

P.S. I'm using docker-compose to run php, mysql, artisan, composer, nginx and nodejs - if that could matter.

Ad

Answer

The original answer given was incorrect as the question is also somewhat incorrect, after discussing in chat, we found that the author had the migrations also in the AppServiceProvider which was preventing actual migrations from happening via the CLI.

You can read the chat here. Removing the artisan calls from AppServiceProvider solved this

Ad
source: stackoverflow.com
Ad