我的迁移之一未在Laravel 4中使用php artisan命令运行 [英] One of my migrations is not running with the php artisan command in Laravel 4

查看:73
本文介绍了我的迁移之一未在Laravel 4中使用php artisan命令运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have several migrations I am running in Laravel 4. I use the php artisan migrate:rollback and php artisan migrate commands to populate the tables. Interestingly enough, one of my migrations has stopped working (cannot roll back). All of the others are working fine. I haven't changed anything to my knowledge.

有问题的迁移名为: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');
    }

}

我不知道为什么这不起作用.有什么想法怎么回事?

I have no idea why this isn't working. Any ideas what could be going on?

推荐答案

我遇到了同样的问题,并且做了类似的事情来解决它.这就是对我有用的.

I had the same problem and did something similar to this to fix it. This is what worked for me.

  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
  1. Delete the tables and columns the migration is supposed to create if they are still there.
  2. Rename the migration in the app/database/migrations file by incrementing the last number in the migration file's name by one. Example: rename "2014_06_01_190448_create_users.php" to "2014_06_01_190449_create_users.php"
  3. Run composer dump-autoload - this gets the old migration out of the system's memory
  4. Rerun php artisan migrate in the command line

文件系统基本上认为这是一个新的迁移,因此为它提供了全新的开始".

The file system basically thinks this is a new migration, so it gives it a "fresh start".

这篇关于我的迁移之一未在Laravel 4中使用php artisan命令运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆