无法回滚laravel迁移

时间:2014-11-29 11:18:18

标签: php laravel migration rollback

我已成功为CreateUserTable创建了迁移。

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user', function(Blueprint $table)
        {
            $table->increments('id');
            $table->string('email')->unique;
            $table->string('password', 60);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('user');
    }

}

但我无法回滚:

$ php artisan migrate:rollback
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'CreateUserTable' not found","file":"C:\\xampp\\htdocs\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Migrations\\Migrator.php","line":301}}

有人建议在下面运行,但它给了我另一个错误:

$ composer dump-autoload
Composer could not find the config file: C:\ProgramData\ComposerSetup\bin
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section

任何回滚的解决方案并避免与composer.json相关的第二个错误?我正在使用Laravel 4进行全新安装。

1 个答案:

答案 0 :(得分:1)

回滚通常要求您先运行composer dumpautoload。我在Laravel 5.1中遇到了同样的问题。

在你的情况下,dumpautoload应该用一个词 - 这样它对我有用。

当然composer应该在包含composer.json文件的文件夹中运行。这将是您的Laravel项目文件夹。