繁体   English   中英

我的一次迁移没有在Laravel 4中使用php artisan命令运行

[英]One of my migrations is not running with the php artisan command in Laravel 4

我在Laravel 4中运行了几次迁移。我使用php artisan migrate:rollbackphp artisan migrate命令来填充表格。 有趣的是,我的一次迁移已停止工作(无法回滚)。 所有其他人都工作正常。 据我所知,我没有改变任何东西。

有问题的迁移命名为: 2013_06_19_050252_create_artists_table.php

它看起来像这样:

    <?php

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

class CreateArtistsTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('artists', function(Blueprint $table) {
            $table->increments('id');
            $table->string('url_tag')->unique();
            $table->string('username');

            $table->timestamps();
        });
    }

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

}

我不知道为什么这不起作用。 什么想法可能会发生什么?

我有同样的问题,做了类似的事情来解决它。 这对我有用。

  1. 删除迁移应该创建的表和列(如果它们仍然存在)。
  2. 通过将迁移文件名称中的最后一个数字递增1来重命名app / database / migrations文件中的迁移。 示例:将“2014_06_01_190448_create_users.php”重命名为“2014_06_01_190449_create_users.php”
  3. 运行composer dump-autoload - 这会将旧迁移从系统内存中取出
  4. 重新运行php artisan migrate在命令行中php artisan migrate

文件系统基本上认为这是一个新的迁移,所以它给了它一个“新的开始”。

当您遇到迁移问题时,有时候会遇到问题

php artisan migrate:refresh

但是,如果您的迁移确实被破坏,并且有时会发生,您可能必须删除所有数据库表,然后再次运行php artisan migrate

使用Illuminate \\ Support \\ Facades \\ Schema;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM