我的迁移之一未在Laravel 4中使用php artisan命令运行 [英] One of my migrations is not running with the php artisan command in Laravel 4
问题描述
我在Laravel 4中进行了几次迁移.我使用php artisan migrate:rollback
和php 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,在app/database/migrations文件中重命名迁移.示例:将"2014_06_01_190448_create_users.php"重命名为"2014_06_01_190449_create_users.php"
- 运行
composer dump-autoload
-这会将旧的迁移移出系统内存 - 在命令行中重新运行
php artisan migrate
- Delete the tables and columns the migration is supposed to create if they are still there.
- 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"
- Run
composer dump-autoload
- this gets the old migration out of the system's memory - 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屋!