"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
whereusers
.deleted_at
is null) asexists
)
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.
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
Related Questions
- → I can't do a foreign key, constraint error
- → How to implement DbDongle::convertTimestamps as workaround of invalid timestamps with MySql strict
- → MySQL error "Foreign key constraint is incorrectly formed"
- → Eloquent Multitable query
- → "Laravel 5.1" add user and project with userId
- → Database backup with custom code in laravel 5 and get the data upto 10 rows from per table in database
- → Laravel 5.1 QueryException when trying to delete a project
- → Using Array in '->where()' for Laravel Query Building
- → Chaining "Count of Columns" of a Method to Single Query Builder
- → Laravel Eloquent Joining Strange query
- → convert time using mysql laravel 5
- → How to update a column after an expiration date in MySQL?
- → Foreign key constraint fails on existing key