dongnuo4594 2016-06-16 13:04
浏览 67

尝试回滚laravel中的迁移时出现回退错误

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!

  • 写回答

2条回答 默认 最新

  • duanjuebin2519 2016-06-16 13:18
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大