gwapo
gwapo

Reputation: 218

Error in Rolling back the tables

When I run php artisan migrate:refresh in the terminal, I get the following error. Why am I getting this error?

[Illuminate\Database\QueryException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'departments' already exists (SQL: create table departments (id int unsigned not null auto_increment primary key, name varchar(191) not null, deleted_at timestamp null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci engine = InnoDB)

[PDOException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'departments' already exists

Upvotes: 0

Views: 199

Answers (2)

Xan Pena
Xan Pena

Reputation: 16

Please, check if you have the down() method configured in your departments migration.

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

Upvotes: 0

David Goloviy
David Goloviy

Reputation: 113

Try to run php artisan migrate:fresh it should help. But the problem is some down method in the migrate does not cancel up method changes or you have changed some migrations after ran php artisan migrate

Upvotes: 1

Related Questions