I am trying to migrate:rollback
a users table and am receiving this error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'AddSortable' not found
When I do migrate:reset I get the same error and when I try to migrate I get
[Illuminate\Database\QueryException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create t
able `users` (`id` int unsigned not null auto_increment primary key, `name` varchar(255) not null, `
email` varchar(255) not null, `password` varchar(255) not null, `remember_token` varchar(100) null,
`created_at` timestamp null, `updated_at` timestamp null) default character set utf8 collate utf8_un
icode_ci)
[PDOException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists
this is my users table
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
and here is the code for mysql in database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
any help would be much appreciated!
You've probably setup the users table in an earlier migration.
On the other hand I have to say I always seem to break my migrations when rolling back. I've resorted to just manually dropping the tables in my DB and then running artisan migrate
again.
It's far from optimal, but I haven't found why it happens. Searched Google every now and then for over half a year, but haven't seem to have found any proper answers.
EDIT: Searching the internet again gives the same suggestion I've come up with. Also try running composer update dump-autoload
like the other answer says. Check here for some info on the Laravel forums
Seems to me like you either deleted or renamed a migration that was called AddSortable
Run composer dump-autoload to have it remake the classes cache and try to run the rollback again.