【发布时间】:2016-08-29 08:42:40
【问题描述】:
我刚刚创建了一个新的迁移文件,用于在现有表中插入一个新列。
文件代码为:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddStatusToPhoto extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('photos', function(Blueprint $table)
{
$table->integer('status');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
但是当我运行 php artisan migrate 时,出现错误消息:
[Illuminate\Database\QueryException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'permission_
role' already exists (SQL: create table `permission_role` (`id` int unsigne
d not null auto_increment primary key, `permission_id` int unsigned not nul
l, `role_id` int unsigned not null, `created_at` timestamp default 0 not nu
ll, `updated_at` timestamp default 0 not null) default character set utf8 c
ollate utf8_unicode_ci)
有人知道是什么问题吗?
【问题讨论】:
-
在您的permission_role迁移脚本中,必须在
down()中添加drop table? -
我注意到permission_role表没有回滚,Aldo我手动删除它时,同样的错误仍然存在。