我在 Laravel 4 中运行了几个迁移。我使用php artisan migrate:rollback
and php 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 来重命名 app/database/migrations 文件中的迁移。示例:将“2014_06_01_190448_create_users.php”重命名为“2014_06_01_190449_create_users.php”
- Run
composer dump-autoload
- 这会将旧的迁移移出系统内存
- Rerun
php artisan migrate
在命令行中
文件系统基本上认为这是一次新的迁移,因此它给了它一个“全新的开始”。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)